0

I already have 1 observer on checkout_cart_product_add_after .

Before end of $this I woule like to call another observer which is located in different module

magento\app\code\Custom\Module\Observer\AnotherObserver.php

Both are executing on same event. But both files do different functionality that's why want to make it in separate files.

Don't want to merge code of 2 files in 1 file

  • 1
    If they are both observing checkout_cart_product_add_after then you wouldn't need to call 1 observer from the other as Magento will execute both. Without actually seeing the code this might not be easily answerable. – Kristof at Fooman Feb 22 '17 at 3:44
  • How to set priority which observer should call first? – Jackson Feb 22 '17 at 3:45
  • @AnkitShah should use <sequence> node in module.xml – Khoa TruongDinh Feb 22 '17 at 3:48
  • @KhoaTruongDinh it's not working vice versa. I tried in both modules – Jackson Feb 22 '17 at 4:11
  • 1
    @KhoaTruongDinh i just indexed. Seems working fine :) Can post answer & will proceed with necessary – Jackson Feb 22 '17 at 6:18
2

In your case, should use <sequence> in the module.xml.

Read more here: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/build/module-load-order.html

| improve this answer | |

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.