I have applied this event in my config.xml but I dont know how to get data from this observer. I googled but no article found.



Observer file-

public function updateQuote($observer)
    $quoteItem = $observer->getEvent()->getItems();
    $quote = $quoteItem->getQuote();
    $id = $quote->getId();
    Mage::log($id."hello testing");

Getting only "testing" in log file and not getting "hello testing". How can I get info about product added into quote and info of the quote.

  • the Mage::log syntax is incorrect probably Feb 27, 2016 at 13:02
  • That I did consiously to see whether I get data in var $id or not and it show only sdfds in log file. Feb 27, 2016 at 13:04
  • I want to iterate loop only one time and only for that product that has been added not for all product that have been added before. Feb 27, 2016 at 14:59

2 Answers 2


This event is written as follow:

Mage::dispatchEvent(‘sales_quote_product_add_after’, array(‘items’ => $items));

Means, we can grab items as follow: $observer->getEvent()->getItems(). And this will be an array of items.

public function updateQuote($observer)
    Mage::log("testing", null, 'quote-log.log');
    $items = $observer->getEvent()->getItems();

    foreach($items as $item){
      Mage::log($item->getId()."hello testing", null, 'quote-log.log');


Now check file called quote-log.log in your var/log folder.

I haven't tested, but should work.

  • hello Adarsh, I did not get print $item->getId(), only prints hello testing Feb 27, 2016 at 14:42
  • check my update answer Feb 27, 2016 at 14:47
  • No it did not worked as I need. It prints 2 times for a single product and item id is also null. Feb 27, 2016 at 14:57
  • do u want to get product id? Feb 27, 2016 at 14:59
  • No, I need item Id from table quote_item Feb 27, 2016 at 15:00

Try $quoteItem = $observer->getEvent()->getItems() instead of $quoteItem = $observer->getEvent()->getQuoteItem();

  • @nimesh..it Did not worked Feb 27, 2016 at 13:22
  • check function is call by writing echo exit in function Feb 27, 2016 at 13:25
  • If function not call then provide config.xml all code Feb 27, 2016 at 13:27
  • This event trigger from "<root>\app\code\core\Mage\Sales\Model\Quote.php" function is "addProductAdvanced" line no 1025 Feb 27, 2016 at 13:29
  • check my updated question. Feb 27, 2016 at 14:11

Your Answer

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

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