2

I made a pull request enter link description here for an the ElasticSuite module to make a discount of configurables flag dependent on simples.

Now of course the configurable has to be reindexed if on of the simples are changed.

Is there any Magento technique do have such cascading index triggers or does everything has to be done manually?

Edit: maybe mview.xml can help

4
  • 1
    Have you considered going down the event observer route? So catch a simple product save and look for parent product and trigger a save. Or better yet catch save and trigger an index of the parent product. Sorry I haven't done anything like this in Magento 2 just yet. So just a suggestion. I can't show you anything at code level. Commented May 23, 2019 at 12:42
  • @DominicXigen yes, was having something like this in mind, but wondering if there is an automatism for that already Commented May 23, 2019 at 13:26
  • In theory should sort itself out on next full price index. You could run on schedule? php bin/magento index:reindex catalog_product_price. Not 100% on that though. So not put as answer. Commented May 23, 2019 at 14:08
  • It does. The question is about having this ensured on the fly Commented May 23, 2019 at 16:38

1 Answer 1

1

Check out the following class

https://github.com/magento/magento2/blob/2.3/app/code/Magento/Catalog/Model/Indexer/Product/Price.php#L81

So I think

  • observe on simple product save

  • Work out parent id

  • Pass class above parent id

Not done this myself but in theory should work

2
  • Simple product save will probably not work reliably as a trigger because also catalog rules could change the price... But I am not sure if those even changes the price index Commented May 23, 2019 at 19:09
  • 1
    That's a fair point. You could catch catalog rule save. But then you've got to work out affected product ids. Then work out parents. Then pass to above. That would be quite an achievement if you get something working. Commented May 23, 2019 at 19:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.