Magento® – Show Same Product in Different Lines in Cart

In Magento sometimes you may want to show same product as different line items in cart, checkout and admin. You may want to do this when you are adding same product but with different options in cart. If you want to do this, here is the simple way do do it.

// Load the product
$product = Mage::getModel('catalog/product')->load($product_id);
$cart = Mage::helper('checkout/cart')->getCart();

// Add product to cart
$cart->addProduct($product, 1);

// Get the recently added quote item
$quote = Mage::getSingleton('checkout/session')->getQuote();
$quote_item = $quote->getItemByProduct($product);

if ($quote_item) {
    // Add custom option to quote item
    // a random number will differentiate it from other similar products
          "code" => "random",
          "value" => serialize(array(time()))

Now when you will see the cart, all products will appear in different rows.

Written by Arvind Bhardwaj

Arvind is a certified Magento 2 expert with more than 10 years of industry-wide experience.


5 thoughts on “Magento® – Show Same Product in Different Lines in Cart

  1. Where will i add this code ? Would you please guide me that how can i do this ?

    Thanks !

      1. Can u show u this ? (i have tried it with CartController in app/code/core.. but it isnt right) Sorry because im beginer with Magento, im going to change/edit Core code or make a new file in app/local. Only know i do that @@

        Thanks in advance !

Comments are closed.