I have created a custom promotion in magento2. To get that working I needed to do some customization in cart which I am trying to do with salesrule_validator_process event. I needed the rulename and discount values to be modified before applying in cart.

Now In Magento1 we used to update values as below:

$result = $observer['result'];



How we can achieve the same in Magento2?

Any thoughts/suggestions are welcome.


You can apply discount amount in magento2 by same event just write below code in your observer file:

$result = $observer->getEvent()->getResult();


  • It is not working. I already tried. – Pallavi Sinha Jul 19 '16 at 10:44
  • This event dispatch from vendor/magento/module-sales-rule/Model/RulesApplier.php eventFix() and it will call when anybody apply coupon code from cart page – Yogesh Karodiya Jul 19 '16 at 11:05
  • Yes I know that. How i can use this info for setting new dicsount? Can you please explain a little bit more? – Pallavi Sinha Jul 19 '16 at 11:16
  • from where you want get access your discount? you can get any model factory or collection factory by just pass it from construct function and put your logic before apply set amount. – Yogesh Karodiya Jul 19 '16 at 11:24
  • I tried this. $result = $observer->getEvent()->getResult(); $result->setAmount(10); $result->setBaseAmount(10); but this is not working. – Pallavi Sinha Jul 19 '16 at 11:42

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.