Use Case:
I need to build a normalized report of my product sales for export to a CSV that can be imported to a third-party database.
Issue:
Product Attribute fields are denormalized when included in views, since:
1) they are all concatenated together
2) they are in an html list element (instead of plain text)
3) they always include the attribute label in the field (when it is arguably more appropriate as the field label)
Solution:
1. Add an option to the Product Attribute field handler's options form to allow filtering by Attribute.
(Think of the way Taxonomy field handler allows you to filter by Vocabulary to limit a "Taxonomy: All Terms" field to a particular term or set of terms.)
2. Add an option to the Product Attribute field handler's options form to change switch between an HTML list element and a simple comma-separated list of attribute values (excluding the label).
Limitations
Since attributes and order product attributes are connected only by the attribute label in the database (ie inherently denormalized), there is no completely reliable way to filter attributes. If an attribute label changes, or if an attribute is removed, then this filter will not be able to offer the appropriate filter set.
NB: This patch does not change the behavior of uc_views_attribute unless the user actively edits any related view and changes the field options.
Comments
Comment #1
aaronbaumansmall change: pull attributes from {uc_attributes} instead of {uc_product_attributes}
Comment #2
virtuali1151 commentedThanks for the patch mate.. was exactly what I needed.
Cheers.
Comment #3
halloffame commentedPatch worked great for me! Thanks. This should be in core.
Comment #4
halloffame commentedOnly works for filter and fields, perhaps for arguments as well?