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 – Gopal Patel Jan 28 '17 at 6:30
  • Or set as out of stock. – ProxiBlue Jan 28 '17 at 6:42

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. – Ricardo Martins Sep 26 '17 at 0:19

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.