You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apart from the naive approach which would consist of
listing all active virtual categories
for each one of them executing the category query + a filter on the current product added to cart with a page size of 1
and then determine if the product belongs to the category (number of results = 1) or not (number of results = 0)
the best way to do that would be to create a special index to use for percolationrequests :
in a special "virtual_categories" index, all virtual categories are indexed with their built/ready to be executed rule query as the percolate field
in the code executed in the add to cart, you perform a "percolate" request on that index by providing as document to test the queries the representation of the as it's available in the "catalog_product" index (think the "_source" structure)
the percolate request will answer which virtual categories documents have a percolate field (rule query) that the product matches
This feature is not yet available out of the box in Elasticsuite, but we do have something similar in Elasticsuite Premium where we percolate optimizers rules so we can determine which optimizers conditions a product would match.
You can have a look at https://github.com/Smile-SA/magento2-module-elasticsuite-targetrule which is an Open Source module that we don't really maintain anymore.
But it uses a percolation index/requests to determine which Target Rules conditions a product would match, so that could give you an idea of how to implement what I'm talking about.
PS: we might introduce in the future percolation of virtual categories rules inside Elasticsuite, but I don't think it's even on our roadmap yet, so don't hold your breath :)
I would like to check if a product is in Virtual Category during add to cart action.
The text was updated successfully, but these errors were encountered: