I'm working on a fairly complicated catalog view for a client, and we have some problems that we're run into. The first is that we were unable to use a view relationship for product references, since as soon as we tried to pull in an image or any product specific fields, we ran into obvious issues with more than 1 row per product display being returned. To get around this we switched to using a teaser display with some custom theme templates and preprocess hooks to reach the same effect, loading the first referenced product entity and fetching price and image fields from that to be displayed in the view of teasers.
The 2nd problem is that now the client want to be able to filter the catalog view based on the availability of specific colors, or sizes of products, but that data doesn't exist at the display node level, only product entity.
We're tossing around some possible solutions to this, and one is to skip views and just write some custom code that loads the entities, and then fetches all associated products and does the filtering on fully loaded entities, in PHP, since we don't need to page the view, or sort it in anyway.
The other option that we've been tossing around is trying to write some code that hooks into node and product_entity saves and updates, that would denormalize the data either into multi-value field on the product node (i.e. all the values of $product->field_foo from referenced products would be placed into a multi-value field $node->field_denorm_foo) or it would write the data into an entirely separate set of tables, similar to materialized_views that could be used to filter, or as a base table, for the catalog view.
What would be the recommended way to address this? Is there anything planned for Commerce that would help with this type of task?
Comments
Comment #1
marcus_w commented+1 Subscribing
I have the same problem, did you fix this already?
Comment #2
joachim commentedBetter title.
One way might be to use some form of grouping.
But the table format's grouping isn't right, as what's desired is one apparent row per product node.
Also, the pager results would then be wrong too.
Comment #3
rfayRelated: #1200536-6: View of products with multi-value product reference field show multiple rows per product node
Comment #4
joachim commentedClosing in favour of #1200536: View of products with multi-value product reference field show multiple rows per product node