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

  • 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. – Dominic Xigen May 23 at 12:42
  • @DominicXigen yes, was having something like this in mind, but wondering if there is an automatism for that already – Alex May 23 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. – Dominic Xigen May 23 at 14:08
  • It does. The question is about having this ensured on the fly – Alex May 23 at 16:38
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

  • 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 – Alex May 23 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. – Dominic Xigen May 23 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.