elasticsuite icon indicating copy to clipboard operation
elasticsuite copied to clipboard

Simle use slow productRepository for render Swatches

Open larsroettig opened this issue 5 years ago • 5 comments

Preconditions

Magento Version : 2.3 and 2.4 ElasticSuite Version : any Environment : Production

Third party modules : No

Steps to reproduce

  1. Smile use slow productRepository to load all product varation for 36 Product this are 200 addtional mysql query for uncached catageorie site
  2. https://github.com/Smile-SA/elasticsuite/blob/9830c3e4f647ef5dcf7b65e784abf0bd8e5b87f3/src/module-elasticsuite-swatches/Helper/Swatches.php#L34

Expected result

  1. Simle schoul preload via collection mutch less queries

Actual result

  1. [Screenshot, logs]

larsroettig avatar Nov 19 '20 14:11 larsroettig

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 ?

romainruaud avatar Dec 11 '20 14:12 romainruaud

@larsroettig any update here ?

romainruaud avatar Jan 19 '21 15:01 romainruaud

Hi @david-fuehr, do have an idea to optimize this call ?

larsroettig avatar Jan 19 '21 15:01 larsroettig

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?

david-fuehr avatar Jan 24 '21 21:01 david-fuehr

any update on this ,i guess swatches are too slow

ia-gaurav avatar Apr 10 '21 04:04 ia-gaurav