In my cart observer, I block 1 item in the cart and then display a notification to the user something like "you could select just one item" the problem that it appears to be the error log Magento first then when I return to the home page. I find my message displayed. I just want to display it in my page and not also in the error log page or display it in the cart page without adding a second item of course.
Observer.php :
class Amir_Prince_Model_ObserverCountItemCart{
public function limiter_panier(Varient_Event_Observer $observer) {
$session = Mage::getSingleton('checkout/session');
$quote = $session->getQuote();
if($quote->getItemsCount()>=1){
$message = 'You can select only one item.';
$session->addError($message);
// Mage::thrownewException($message); // the log error commented
throw new Exception($message);// the frontend notification
}
}
}
Best Answer
You'll need to remove
throw new Exception($message);
to stop getting log messages in the exception log. Its also better to use the methods:Depending on how you want the message to appear.