I have created an observer "checkout_cart_save_before" and plugin Addproduct.

It is working perfectly for the website but not triggering for API while hitting on the postman.

Any suggestions about how to make this work.

Any help would be appreciated.


1 Answer 1


The event checkout_cart_save_before is only fire maegnto frontent.

You can use sales_quote_product_add_after event which is for all area Frontend,Admin,Rest Api,Rest Soap.

$this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]);

See the class \Magento\Quote\Model\Quote::addProduct

  • Thanks Amit, working on it
    – Amy
    Commented Jun 23, 2020 at 15:08
  • Hi Amit, I am not able to get the current customer quote item while hitting from rest API. Could you please help me with this.
    – Amy
    Commented Jun 29, 2020 at 4:55
  • You donot get customer in response of API and which API you are using?
    – Amit Bera
    Commented Jun 29, 2020 at 5:33
  • Hi Amit, I am using addproduct API (POST <host>/rest/default/V1/products). Here want I am trying to achieve is while adding product I am clearing the existing customer cart item, for this I am using class \Magento\Quote\Model\Quote::addProduct (around plugin)
    – Amy
    Commented Jun 30, 2020 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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