elasticsuite
elasticsuite copied to clipboard
Simle use slow productRepository for render Swatches
Preconditions
Magento Version : 2.3 and 2.4 ElasticSuite Version : any Environment : Production
Third party modules : No
Steps to reproduce
- Smile use slow
productRepositoryto load all product varation for 36 Product this are 200 addtional mysql query for uncached catageorie site - https://github.com/Smile-SA/elasticsuite/blob/9830c3e4f647ef5dcf7b65e784abf0bd8e5b87f3/src/module-elasticsuite-swatches/Helper/Swatches.php#L34
Expected result
- Simle schoul preload via collection mutch less queries
Actual result
- [Screenshot, logs]
I'm not sure how we could optimize this.
We are supposed to go through this line : https://github.com/Smile-SA/elasticsuite/blob/9830c3e4f647ef5dcf7b65e784abf0bd8e5b87f3/src/module-elasticsuite-swatches/Helper/Swatches.php#L38
That should be already better than legacy Magento because we have the children_ids indexed in the document coming from ES.
That being said, our loadVariationsFromSearchIndex function is basically a copy-pasted of the legacy one : https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Swatches/Helper/Data.php#L241
Any insight about how we could do this better ?
@larsroettig any update here ?
Hi @david-fuehr, do have an idea to optimize this call ?
Hi together, I just investigated this class further and have created the following draft: https://github.com/Smile-SA/elasticsuite/compare/2.10.x...david-fuehr:2.10.x
These changes seem to break backwards compatibility as the returned $variation does not have all product attributes loaded as before, but only those who are currently used in the code (as far as I see in a first check). With the property $varationSelectAttributes, which can be modified via `di.xml, custom variation product attributes may be added.
@romainruaud what do you think? Would you please verify these changes? If you can approve them, maybe we should create a similar PR in the magento core for \Magento\Swatches\Helper\Data?
any update on this ,i guess swatches are too slow