Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | rendered_product_formatter-1783462-10.patch | 5.44 KB | vasike |
#9 | 1783462-9.rendered_product_formatter.patch | 5.29 KB | rszrama |
#1 | rendered_product_formatter-1783462-2.patch | 5.25 KB | vasike |
Comments
Comment #1
vasikeand here is the patch (based on EntityReference code).
Comment #2
jessepinho CreditAttribution: jessepinho commentedI'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?
Comment #3
rszrama CreditAttribution: rszrama commentedWould it work in your case to use a Views block that renders the product entity, Jesse?
Comment #4
jessepinho CreditAttribution: jessepinho commentedIt 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.
Comment #5
jessepinho CreditAttribution: jessepinho commentedEDIT: Oops, dupe comment. (It gave me an error when I first posted it.)
Comment #6
bojanz CreditAttribution: bojanz commented#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.
Comment #7
bojanz CreditAttribution: bojanz commentedWe need this in order to spin off Add to cart confirmation as a contrib module.
Comment #8
rszrama CreditAttribution: rszrama commentedThis 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?
Comment #9
rszrama CreditAttribution: rszrama commentedAdditionally, 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.
Comment #10
vasikehere is a patch that adds an extra check for the display type (formatter) in the commerce_product_reference_field_formatter_prepare_view() function
Comment #11
rszrama CreditAttribution: rszrama commentedExcellent. 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!