For certain reason, i have to prevent the users to add the product into the cart.

here is the event in config.xml



public function searchStock($observer) {

    //how to prevent a product be added to a cart?
    Mage::getSingleton('core/session')->addNotice('This product can't be added to shopping cart.');


Or i need to use checkout_cart_product_add_after event, to remove the quote item after added into a cart?


  • just remove cart button simple Jan 28, 2017 at 6:30
  • Or set as out of stock.
    – ProxiBlue
    Jan 28, 2017 at 6:42

1 Answer 1


this is so funny method to solve the problem.

change to use checkout_cart_product_add_after and use in observer method

public function removeMessage ($observer) {

this will prevent the product to be added into the cart and avoid the success message

  • Sometimes I don't have the method _getSession in the observer. Sep 26, 2017 at 0:19

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.