Naveenbos Naveenbos - 5 months ago 20x
PHP Question

Event observer not getting product details

I have created a observer event like below inside my config.xml file


In my Model i have created Observer.php

require_once 'Mage/Checkout/controllers/CartController.php';

class CustomModule_Observer
public function _construct()

public function getNewPrice()

$newprice = "5";

return $newprice;

public function updatePrice($observer)
$event = $observer->getEvent();
$product = $event->getProduct();// not getting any values how can i get this.
$quote_item = $event->getQuoteItem();
$new_price = $this->getNewPrice();

Reference Changing the price in quote while adding product to cart: magento


I have tried this, and its working, it gives us the product id.

$quote = Mage::getSingleton('checkout/session')->getQuote();
$cartItems = $quote->getAllVisibleItems();
foreach ($cartItems as $item){
   $productId = $item->getProductId();
   $product = Mage::getModel('catalog/product')->load($productId);
   // Do something