When editing "Manage Display" on the "Product display" is it possible to link the "Modify the settings for this field on the product display configuration." text so that the link goes directly to the field in question?

Comments

realityloop’s picture

Note from Ryan: "It would be nice if it also took into account the display mode."

It wouldn't need t llink directly to the field, but the right product type instead of the product list would be great.

attiks’s picture

Status: Active » Needs review

I found a 'fix':
In commerce_product_reference_node_view.module there's a line

$node->content['product:' . $product_field_name] = field_view_field('commerce_product', $product, $product_field_name, 'node_' . $view_mode);

but i think it has to be, at least then it works for me

$node->content['product:' . $product_field_name] = field_view_field('commerce_product', $product, $product_field_name, $view_mode);

Use case: I use a custom view mode in combination with display suite in my views, I define this view mode on both the product and product display, inside views i select my custom view mode and with the fix above it works

Marking as NR for the moment to get fast feedback

rfay’s picture

Status: Needs review » Active

All these weird little rules - "Needs review" is for when there's actually a patch. So you should probably roll a patch and attach it.

attiks’s picture

@rfay, i know, but i wanted fast feedback from the commerce guys ;p to see if this was a possible solution

attiks’s picture

rszrama’s picture

That patch won't work, actually. It's really solving a different problem than this issue intended, so you might open a separate issue. The problem is that I'm defining product view modes to correspond with each node view mode that a product might be referenced from. This are prefixed with node_. By removing that from the check, while it might work for your custom view modes, it looks like it will break for the node view modes. In fact, I think you might just need either a custom module or perhaps a "Display Suite" integration module that can define additional product view modes to correspond to your custom view modes where product fields might be rendered. Alternately, you might be able to resolve the problem by adjusting the weight of your modules so that the Commerce modules are weighted higher than Display Suite.

attiks’s picture

@ryan, forgot to mention: i'm using this in combination with display suite. But you're right, it's another issue, see #733044: Add build modes for products

rszrama’s picture

Actually, it ends up being different from that one, too, because that one's about actually defining new view modes via hook_entity_info(), not supporting unexpected view modes through the product field rendering. I wonder if your problem isn't just a module weight issue... like we need Display Suite to alter the entity info before Commerce does.

liupascal’s picture

For what it worth, i recently installed display suite to have a custom product display 'display mode'. I create a custom display for both "node" and "commerce product" entities, which works perfectly. On top of that I am also using field slideshow to display the multiple field image i created in my Product entity.

But : when i configured my product entity's image field display for my "custom display" (created with display suite) my Product display in "custom display" mode won't take it into account (and would display it on my page as if I was just displaying regular images).

However, when I changed my "default display" in my product, and configured it as "slideshow" rather than "image", my Product display in "custom display" mode would display a slideshow.

It is possible that there is an inconsistency with the display modes created by display suite and the "default" drupal display mode ? I saw that the display mode created b the Display suite is stored in a specific table in the database (table ds_view_modes)

attiks’s picture

#9: i have the same problem, hence my attempt in #5 to fix this, but we need someone with more commerce experience to solve this

sonar_un’s picture

I came across this exact same problem as well. Display Suite won't recognize the use of using other display modes for the product references.

For instance, when setting a Display Mode for an item on a referenced product node, your only option is "Visible". Normally, you would be able to chose a view mode that you have set up in Display Suite.

While digging around this, I have also found that DC is wrapping text fields in a span, which interferes with how Display Mode wraps it's own fields. Because of this, Display Suite seems to ignore the main wrapper for each field and you are stuck with having to use a span. I found where DC puts the span into the fields in the commerce_product_reference module under commerce_product_reference_entity_view.

Also, the Product reference for the Add To Cart form has SKU (no Link), SKU (Link), Title (No Link) and Title (Link), which are the default fields for commerce, but none of the added fields are there. Perhaps there is something to look at as well.

If I were more of a developer, I would love to look at this deeper but unfortunately this is all I can offer.

Stalski’s picture

Yes, this seems like a problem indeed.
I would have expected that we configure the Product Display node's display settings so that we only need to give the referenced products a "Render in :$view_mode".
I did this locally and it works great like that. So I don't know why this is not default behavior.

I would propose (and i am willing to provide a patch) to add a formatter for the reference field "commerce_product_reference".


/**
 * Implements hook_field_formatter_view().
 */
function commerce_product_reference_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
...
  switch ($display['type']) {
   ... new case ...
    // We need to have the $view_mode configured in the field_ui configuration form.
    case 'commerce_product_reference_view_mode':
      foreach ($items as $delta => $item) {
        if (!empty($products[$item['product_id']])) {
          $result[$delta] = commerce_product_build_content($products[$item['product_id']], $view_mode);
        }
      }
      break;
  }
  ...

Locally I only did it for a hard-coded (and in code declared) view_mode for product type T-shirt and a 'preview' view mode.
Create a patch? If maintainers don't like the idea OR it would end up in racing conditions with the "Product:..." fields, let me know.

Summit’s picture

Hi, would love to see a patch on this please? Does this mean display suite - commerce integration?
Greetings, Martijn

bojanz’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

At this point it's too late to change the product rendering logic in D7.