Hey! It would be nice of display suite would provide better support for drupal commerce. I don't know how good you know commerce so a little intro: in commerce you have products and product displays. A product would be a green, medium sized t-shirt. A product display, displays one or more products (one shirt of different sizes etc using the product reference field)

Ok! When editing the display settings of the product display you can't modify the settings of product fields. You have to go to the product entity to change them. The disadvantage is that when having different view modes on product display they all depend on the 'default' view mode of the product. It would be really nice if you setup viewmode X in the product display, you could also add viewmode X in the product and that it uses that settings. Even better would be configuring all settings in the product display :)

Thanks for the module!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel’s picture

This is pretty much related with #1230830: Custom build modes (e.g. through Display Suite) are not working I think - there seems to be problem with view modes in general - although I can't pinpoint exactly where as I haven't used commerce a lot (only installed and played around with it a bit). Commerce and field ui / and in addition DS support seems like a complete separate project. I'm going to try and talk with those guys a bit in london and see if we can come to some sort of battleplan.

muschpusch’s picture

Hey Swentel! I was wrong the only option which isn't working is the restriction of amounts of field duplicates. The rest works!

swentel’s picture

What exactly do you mean with 'restriction of amounts of field duplicates' ? Is that the option to limit the number of values to display if you have a field where you can upload multiple items, say x number of images ? In case so, is that on a commerce field or an a field api field ?

muschpusch’s picture

Is that the option to limit the number of values to display if you have a field where you can upload multiple items, say x number of images ?

sorry it was late. Yes i that's what i mean and it's a field api field

swentel’s picture

Status: Active » Postponed (maintainer needs more info)

Just a quick follow up question, there is a input textfield next to the field in the manage display screen right (note, only works if you have a layout configured). And which field is it, is it related with commerce ? And cardinality is set to unlimited or more than 1 right ?

swentel’s picture

Oh, and in case you're doing this on a custom view mode, that it's really related to that issue I mentioned in #1

muschpusch’s picture

Hey Swentel sorry for the delay. Yes i use the input textfield for cardinality and the bug occurs on the custom and the teaser display. The field is the commerce image field (normal image field i guess)

swentel’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Ok, this won't work at this point, however, you can install http://drupal.org/project/field_multiple_limit - which should do the job fine.

roderik’s picture

Status: Closed (won't fix) » Needs review
FileSize
1.58 KB

[ EDIT: below patch does not apply to the original broader bug report - most of this is solved by Commerce v1.4 / #1230830: Custom build modes (e.g. through Display Suite) are not working. It does apply to the 'limit' discussion after comment #2. ]

Reopening issue because it fits the title... and I'm pretty sure we're debugging the same install at 2 points in time :) *waves at muschpusch*

The issue isn't strictly related to custom view modes. It's related to the way that Commerce pulls in extra fields from the product entity, into the node entity. (I.e. it will also happen in 'teaser' view mode.)

ds_field_attach_view_alter() refuses to apply limit & formatter settings to fields added through field_view_field()... but it could, in most cases. See patch.

For documentation, here's a call tree I jotted down during debugging:

node_build_content
  field_attach_view()
    drupal_alter('field_attach_view')      <- ds_field_attach_view_alter() works
  module_invoke_all('entity_view')
    commerce_product_reference_entity_view()
      field_view_field()
        _field_invoke_default('view')
          _field_invoke()
            field_default_view()           <- (sets stuff that the patch uses)
        drupal_alter('field_attach_view')  <- ds_field_attach_view_alter() bails out... before patch

AFAICS from the git repo, this also still applies to 7.x-2.x, but I haven't tested there.

swentel’s picture

swentel’s picture

And @roderik - wow, that might actually do the trick, I keep forgetting that there's indeed another way to call the rendering of a field, but never fully debugged how commerce was attaching the fields.

swentel’s picture

swentel’s picture

DS 2 branch patch

netsensei’s picture

Help! I'm trapped in view mode inception! ;-) But it looks like something this patch works for me too!

Suppose you have a common text field with multiple values called "Foobar" attached to a product entity:

1: Add a product display node with a few product variations. Per product variation: a few values for the text field. (Beware: Inline Entity Form = wonky!)
2. Activate the "node: full content" view mode on the product entity display and set a one column layout
3. Add the "Foobar" field to the layout and set the cardinality to 2.
4. Go to the product display node display. Activate the "node: full content" view mode and set a one column layout.
5. If all goes well: the fields on the product entity will be exposed separately in the view mode fo the product display node.
6. Disable all product display node fields.
7. Enable the "Product: Foobar field" it will say that you can't change the settings from the node display.

Now, go to the product node view detail page and watch the result.

The field will only show values of the first product variation! Not of all product variations!

So, this patch won't give you control over all the values in all the product variations attached to the product display node!

What the patch imho lacks is a cardinality/limit setting per exposed product entity field on the product display node. The only way you are able to control this now is use the global "Product variations" reference field and then set the corresponding view mode + cardinality.

What this patch does solve: if you're product display node only has 1 product with a multiple valued field, then it will take the field cardinality settings from the corresponding view mode set in the product entity display.

Nonetheless, how the different view modes and fields interoperate between the node and product entities is totally unclear. It's not documented nor is it clear from the Field UI context why it shows 1 value or more values.

roderik’s picture

Heh. I guess the issue subject is broader than the patch :)

It sounds like your report is correct as far as 'fitting within the issue title'. But the scope of the issue being discussed, so far, is not 'introducing any new settings' -- it is only making sure that the already-existing settings actually work.

So I hope that this patch gets in, anyway.

Not sure if your comment is better off as a new issue. I don't have experience with product variations, so it's a little hard for me to wrap my head around the details of your problem, sorry. (If I was sure it could be solved in the same area of code, I would...)

netsensei’s picture

I agree. The patch only treats part of a problem with a much broader scope. I'd add to my previous comment that the patch is a step in the right direction and should be committed.

zmove’s picture

Don't work today + it throws an error :

Notice : Undefined index: #entity_type in ds_field_attach_view_alter() (line 507 in mysite/sites/all/modules/ds/ds.module).
zmove’s picture

Issue summary: View changes
Status: Needs review » Needs work