EDIT: SOLVED
I had to override this method from Mage_Checkout_Block_Cart_Item_Renderer to use $this->getItem()->getName()
instead of $this->getProduct()->getName()
.
public function getProductName()
{
if ($this->hasProductName()) {
return $this->getData('product_name');
}
return $this->getProduct()->getName();
}
How can I change name of the product that I am creating here in Observer.php checkout_cart_product_add_after
event so that I see it in cart view.
I tried setName() and setData to change the name, but it didn't work.
I want to change name of $exampleItem, changing price works, but changing name doesn't.
class Test_Example_Model_Observer
{
public function cartProductAddAfter($observer)
{
$product = $observer->getEvent()->getQuoteItem(); // get product that gets added to cart
$exampleQty = $product->getQtyToAdd(); // get quantity of added product
$exampleProduct = Mage::getModel('catalog/product')->loadByAttribute('sku', 'EXAMPLE'); // get the example product
$exampleToAdd = $exampleProduct->load($exampleProduct->getId()); // load the example product
$quote = Mage::getSingleton('checkout/session')->getQuote(); // get quote
$exampleItem = $quote->addProduct($exampleToAdd, $exampleQty); // add example product to quote matching quantity of the normal product
$exampleItem->setCustomPrice(444);
$exampleItem->setOriginalCustomPrice(444);
$quote->save(); // save quote
}
}
var_dump()
on that item then it showed that name was changed, but in cart view nothing was changed.