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.

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;
    }
}
  • It update name of all the products in the cart and not the last product we added. – Parth Thummar Sep 14 '16 at 14:16
  • @ParthThummar even im facing same issue? were you able to solve the issue? – Guruprasad Jul 4 '17 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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