1

Is it possible to add several the same product times to the cart with a different name? I did with different price, but I have not managed to do it with a different name.

I used an observer "sales_quote_item_set_product" but sets the same name when there are several products in cart.

The product is added by programming with "checkout_cart_product_add_after" event, using:

 $quote = Mage::getSingleton('checkout/session')->getQuote(); $quoteItem = $quoteItem = Mage::getModel('sales/quote_item'); $quoteItem->setProduct($product_model); $quoteItem->setQuote($quote); $quoteItem->setQty('1'); $quoteItem->setParentItem(NULL); $quoteItem->setStoreId(Mage::app()->getStore()->getId()); $quoteItem->setName('Custom Name')//I need this, but does not work $quoteItem->setOriginalCustomPrice(0); $quote->addItem($quoteItem)->save(); 

If I print the value of $quoteItem with var_dump() I see if the name was changed, but in the cart appears with the original name.

Another option was to use $product_model->setName() before $quoteItem->setProduct($product_model) but in the cart appears also with the original name.

1 Answer 1

2

Take a look at Magento change product name adding to cart

Use event sales_quote_item_set_product

class Mynamespace_Samples_Model_Observer { public function salesQuoteItemSetProduct(Varien_Event_Observer $observer) { /* @var $item Mage_Sales_Model_Quote_Item */ $item = $observer->getQuoteItem(); //only change the item you want by product id if($item->getProductId() == xyz){ $item->setName('Ians custom product name'); } return $this; } } 
2
  • It update name of all the products in the cart and not the last product we added. Commented Sep 14, 2016 at 14:16
  • 1
    @ParthThummar even im facing same issue? were you able to solve the issue? Commented Jul 4, 2017 at 9:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.