Download & Extend

Add more information to the entity display_context array

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Product reference
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

Comments

#1

Status:active» needs review

Patch attached

AttachmentSizeStatusTest resultOperations
commerce-add-view-mode-product-reference-1787728-1.patch664 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).View details

#2

AttachmentSizeStatusTest resultOperations
commerce-add-view-mode-product-reference-1787728-2.patch674 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).View details

#3

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

#4

Status:fixed» closed (fixed)

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