We have a use case where it would be helpful to be able to filter a View of nodes by node type, only including node types that have product reference fields. This may be possible as a simple extension of the product node type filter that instead of showing checkboxes for each node type just displays which product types it will filter for and doesn't let the user change. It might be nice to have a negation checkbox, though, so you can choose if the View could also display non-product referencing node types.

Files: 
CommentFileSizeAuthor
#7 product_display_views_filters-1031494-7.patch5 KBvasike
PASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).
[ View ]
#6 product_display_type-1031494-6.patch3.42 KBvasike
PASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).
[ View ]

Comments

The use case was building a View to display the most viewed products. Because the view count is associated with the node displaying products, this has to be a Node View instead of a Commerce Product View. However, a module defining this View won't know what product types on the website reference products to include only those node types in the View. Additionally, someone might create a new node type and not know that they need to come update the filter settings on this View. : )

Assigned:Unassigned» bojanz

Sounds useful :)

Status:Active» Needs review

Somebody stole march from me. Or drupal.org is lying that it's april 1st.

In any case:
http://drupalcode.org/sandbox/bojanz/1097750.git/commitdiff/refs/heads/1...

Status:Needs review» Needs work

Hmm, the idea was actually to have more of a boolean filter where it's either filter by "all product types that have a product reference field" or "all product types that don't have a product reference field." The idea is that this filter should work regardless of the actual name of the corresponding node types, so it could be used to create a generic Catalog View that doesn't have to presuppose the name of any particular node type.

Granted, this is functionally equivalent to adding a required relationship through the product reference field, so I guess the idea was really just a simplicity thing.

And just to clarify - the filter itself would function behind the scenes as a regular node type filter, so you'd still have to supply the appropriate node type names... just the customer shouldn't have to specify them all in the settings form for the filter. That's where it should appear as a boolean decision (through radios I'm guessing, actually).

Status:Needs work» Needs review
StatusFileSize
new3.42 KB
PASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).
[ View ]

here is patch for this filter
Added the "Product Display type" filter from the "Commerce Kickstart Content UI" module with some naming changes
'product_display_type' instead of ''product_display' to avoid some conflicts at least till the filter will be romved from Kickstart module.
and
'commerce_product_reference_handler_filter_product_type' instead of 'views_handler_filter_product_type', use the Drupal commerce naming "convention".

With this, Commerce Kickstart requires some changes: some views to be rebuilt, the "old" filter removed.

Title:Add a node filter that filters by node types with product reference fieldsProduct Display views filters: Is Product Display? & Product Displays Content types
Assigned:bojanz» vasike
StatusFileSize
new5 KB
PASSED: [[SimpleTest]]: [MySQL] 3,589 pass(es).
[ View ]

reworked the previous patch.
Created 2 views filters
- Is Product Display? : Whether or not the content is one of product displays.
- Product Displays Content types: Select Content types which are Product Display

Assigned:vasike» rszrama
Issue tags:-dcsprint5

So, we definitely need those two filters for Kickstart v2.
The implementation is insanely simple, thanks to the commerce_product_reference_node_types() function we added previously.

Perhaps commerce_product_reference_handler_filter_is_product_display should be named commerce_product_reference_handler_filter_node_type_is_product_display (clearer, but insanely long)
Letting Ryan bikeshed the class names / labels, if he wants to :)

Issue tags:+kickstart blocker

Tagging.

Assigned:rszrama» Unassigned
Status:Needs review» Fixed

Great start, vasike. Yes, I did change the names to include "node" in the class name, and I also changed the "is a product display" filter to extend views_handler_filter_boolean_operator instead of views_handler_filter_in_operator. This actually reduced its size and avoided having an "in" filter that didn't actually have options.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/39ae75d

Status:Fixed» Closed (fixed)
Issue tags:-kickstart blocker

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