build a new formatter for Product reference, "Rendered product" the same as "Rendered entity" formatter for Entity Reference.
This will display the referenced products rendered by entity_view(), using the selected "view mode" of the formatter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vasike’s picture

Status: Active » Needs review
FileSize
5.25 KB

and here is the patch (based on EntityReference code).

jessepinho’s picture

I'd love this feature; however, it'd be nice to have the option to still include the Add to Cart form with it. Perhaps the rendered entity should be pulled in as an extra pseudo-field, rather than as a formatter for the product reference field?

rszrama’s picture

Would it work in your case to use a Views block that renders the product entity, Jesse?

jessepinho’s picture

It may; but I'd need the Views block to be able to be updated when the user changes the value of the Add to Cart dropdown.

jessepinho’s picture

EDIT: Oops, dupe comment. (It gave me an error when I first posted it.)

bojanz’s picture

#2 is a feature request that is off topic for this issue, and even if it was in it's own issue, I'd consider it a won't fix. We inject product fields into the node display just so that you can display anything (product-related) you want before / after the add to cart form.

This change definitely needs to be a formatter, no way around it.

bojanz’s picture

Issue tags: +kickstart blocker

We need this in order to spin off Add to cart confirmation as a contrib module.

rszrama’s picture

This isn't a bug in Commerce as far as I can tell, but are you guys not seeing this when you try to view an entity with a rendered product in its content?

Notice: Undefined variable: url in include() (line 35 of /Users/rszrama/src/git/drupal/entity/entity.tpl.php).
rszrama’s picture

Status: Needs review » Needs work
FileSize
5.29 KB

Additionally, commerce_product_reference_field_formatter_prepare_view() is a little aggressive at the moment, in that it's going to run for any field formatter defined by commerce_product_reference.module and not just the new "Rendered product" display formatter.

Updates should go against the attached patch.

vasike’s picture

Status: Needs work » Needs review
FileSize
5.44 KB

here is a patch that adds an extra check for the display type (formatter) in the commerce_product_reference_field_formatter_prepare_view() function

rszrama’s picture

Assigned: vasike » Unassigned
Category: task » feature
Status: Needs review » Fixed

Excellent. Gave it another option to change the $page parameter passed to entity_view() and added a hook function until a new release comes out for Entity API; see #1601162: Undefined variable: url in entity.tpl.php. Thanks!

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