Problem/Motivation
If you add Product Type as a field on Search API Product Index, and then try to filter a Product Datasource view (catalog page) by Product Type, it doesn't use the search api views handler you would expect (options list). Instead, it is treated as an integer that can only be limited by value.
The same issue existed for node types, here is the issue: https://www.drupal.org/project/search_api/issues/2683259
Proposed resolution
As a workaround, we can implement hook_search_api_views_handler_mapping_alter to let Search API know what views handler to use. However, the best solution would be to solve this on the Search API side (see related issue).
Comment | File | Size | Author |
---|---|---|---|
#4 | 3016759-4.patch | 1.54 KB | ericchew |
|
Comments
Comment #2
ericchew CreditAttribution: ericchew commentedComment #3
ericchew CreditAttribution: ericchew commentedIf possible, the best course of action would be to fix this on the Search API side. In the meantime, the workaround is pretty simple. I will convert the workaround to a patch instead of pasted code on the issue when I get a chance.
Adding related issue from Search API.
Comment #4
ericchew CreditAttribution: ericchew commentedComment #5
mglamanComment #6
AndyD328+1 from me, it's working perfectly. Thanks for the patch!
Comment #7
bojanz CreditAttribution: bojanz at Centarro commentedI hoped Search API would fix this quickly, cause it's super weird for them to not support bundle fields, but oh well.
Let's proceed with the patch.
Use statements are no longer alphabetical.
Returns should be Gets.
There is no such thing as a product type name, so the function should be called commerce_product_type_labels() and document that it returns a list of labels keyed by ID.
We should get the storage on its own line, to shorten the mega-line.
Comment #9
bojanz CreditAttribution: bojanz at Centarro commentedAddressed #7 and committed. Thanks!