Tyler Kocheff
10/06/2021, 8:07 PMproduct_filters.rb. I found a similar issue here but it was for Spree and it's pretty old. So far I haven't been able to adapt this code to work with current Solidus. We do have a custom searcher based off of Spree::Core::Search::Base already in place, so I have been trying to override add_search_scopes method there. Any recommendations on where to focus my efforts or if there's a better way to go about this?socksman
10/06/2021, 9:17 PMbrand_any and flavor_any chainable, this seems to work:
- Spree::Product.with_property('brand').where(scope)
+ where(id: Spree::Product.with_property('brand').where(scope).pluck(:id))
I’m sure that’s not great because you’re doing a subselect in there but it should move you along. You might also find that search returns duplicate products since there will be cross-talk in your properties, but you can clean that up in the search lib.
I’m not sure if you’d need to override add_search_scopes since that should just be chaining scopes if Product responds to the method.Tyler Kocheff
10/07/2021, 2:04 PMproduct_filters.rb currently and what is working for individual properties. It just returns nothing when multiple separate properties are selected. I'm guessing due to the chaining, but I haven't been able to pinpoint where.
Changing line 45 to Spree::Product.with_property(property.name).where(scope).where(id: Spree::Product.with_property(property.name)).where(scope).pluck(:id) causes an error `undefined method preload' for []:Arraysocksman
10/07/2021, 3:23 PMSpree::Product.with_property(property.name).where(scope).where(id: Spree::Product.with_property(property.name)).where(scope).pluck(:id) I think you just want Spree::Product.where(id: Spree::Product.with_property(property.name)).where(scope).pluck(:id)