I have a store with products that have attributes for colour and size that users have to select. I want to display their selection in the shopping cart and, googling around, all the suggestions for how to do this suggest using a module (for example, see here http://www.magentocommerce.com/boards/viewthread/43580/).

However, I seem to have managed it without using a module. I've simply added the following code to app/design/frontend/myarea/default/template/checkout/cart/item/default.phtml. Note I have other products, such as gift cards, that don't have these attributes.

    $_colour = Mage::getModel('catalog/product')->load($this->getProduct()->getId())->getAttributeText('color');
    $_size = Mage::getModel('catalog/product')->load($this->getProduct()->getId())->getAttributeText('sizes');
    if ($_colour) {echo "<div>" . $this->__('Colour: ') . $_colour . "</div>";}
    if ($_size) {echo "<div>" . $this->__('Size: ') . $_size . "</div>";}

Is there something I'm missing in these other posts? I'm concerned my solution may have a flaw that will show up at some point.


Thanks guys but now I'm really baffled!

I've put the following in my config.xml file:

    <!-- add product attributes to cart layout -->
                    <color />
                    <sizes />

If I have the following in my default.phtml file, I only get the size. The colour isn't displayed. (If I remove the sizes from my config.xml, the size isn't displayed as I would expect.)

    $_colour = $_item->getProduct()->getAttributeText('color');
    $_size = $_item->getProduct()->getAttributeText('sizes');
    if ($_colour) {echo "<div><strong>" . $this->__('Colour: ') . "</strong>" . $_colour . "</div>";}
    if ($_size) {echo "<div><strong>" . $this->__('Size: ') . "</strong>" . $_size . "</div>";}

Now the bizarre thing is if I replace $_item by $this, it works! But it ignores whatever's in my config.xml file.

    $_colour = $this->getProduct()->getAttributeText('color');
    $_size = $this->getProduct()->getAttributeText('sizes');
    if ($_colour) {echo "<div><strong>" . $this->__('Colour: ') . "</strong>" . $_colour . "</div>";}
    if ($_size) {echo "<div><strong>" . $this->__('Size: ') . "</strong>" . $_size . "</div>";}

2 Answers 2


Please go to this link it may help you


  • Thanks. I had seen this but it emphasises my question. Again, this link does things through a module while my approach didn't bother with a module. Why should I use a module?
    – PedroKTFC
    May 10, 2014 at 12:38
  • You want a custom code , so you can find appropriate code from this module dude
    – Ami Kamboj
    May 10, 2014 at 14:00
  • It would be great if you can write down the most important parts of the link into your answer. If the links vanishes in the future, your answer is still valuable. May 30, 2014 at 10:39


What magento does is to load all the quote items on the cart pages and load all attributes, which are defined in app/code/core/Mage/Sales/etc/config.xml at the XPath: /config/global/sales/quote/item/product_attributes.

What you then do is:


What this does is to load the product again. This is a performance killer. What you want instead is, to add your attributes (color and size) to this XPath. And for THIS, you need an config.xml.


Do I need a module to display product attributes in the shopping cart?


You want more infos? To load attributes for quote_items you have to add some nodes into the config-XML. To do this you have either to edit an existing config.xml (NOOOOOOOOO!!!) or have your own one.

  • Thanks Fabian but I still haven't understood why. My little bit of code above does what I want without a module. Why then should I use a module, what extra does it give me?
    – PedroKTFC
    May 10, 2014 at 17:16
  • updated ... and a few more chars to have enough to ping you. May 10, 2014 at 22:03
  • Fabian, just a nudge. I posted a new answer explaining how far I've got and what I now don't understand. I'd much appreciate your thoughts if you can spare the time.
    – PedroKTFC
    May 15, 2014 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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