When you rely on the display_context array that is filled in commerce_product_reference_entity_view, it could be useful to also have the view_mode and/or the langcode of the entity being displayed.
Currently, you only have the entity_type + the entity

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jsacksick’s picture

Status: Active » Needs review
FileSize
664 bytes

Patch attached

jsacksick’s picture

rszrama’s picture

Status: Needs review » Fixed

Yep, this is a great feature. Thanks, Jonathan!

On review, I made two quick changes:

  1. I used $reference_view_mode instead of $view_mode, because what's important for rendering product fields is the name of the view mode on the product type itself. The $view_mode variable is the name of the view mode of the entity the product field is getting injected into.
  2. I used 'language' instead of 'langcode' as that's the key used for the $context array in hook_field_attach_view_alter() that makes it through to the product during the cart attributes refresh.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/0ec3b5d

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.