Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom attributes not available in cart
 
madla
Jr. Member
 
Total Posts:  25
Joined:  2009-03-29
 

I’m trying to access a custom attribute “size” in the cart for each item in checkout/cart/item/default.phtml.

I looked through most of the examples in the forums and it seems to be a common issue.

I can access all the standard attributes this way:

<?php $_product $this->getProduct();
$attribs $_product->getData('');
    
print_r($attribs);
?>

when I look at the output, none of my custom attributes are there.

Any help on this would be greatly appreciates...martin

 
Magento Community Magento Community
Magento Community
Magento Community
 
flmag
Member
 
Total Posts:  49
Joined:  2008-12-08
 

The getProduct() method doesn’t load all the data associated to a product you should use something like this:

Mage::getModel('catalog/product')->load($this->getProduct()->getId())->getData('size')
 
Magento Community Magento Community
Magento Community
Magento Community
 
madla
Jr. Member
 
Total Posts:  25
Joined:  2009-03-29
 

Thank you...works like a charm.

 
Magento Community Magento Community
Magento Community
Magento Community
 
repeaterstore
Member
 
Total Posts:  35
Joined:  2007-11-16
 

I’m using the following:
echo Mage::getModel(’catalog/product’)->load($this->getProduct()->getId())->getManufacturer();
in design/frontend/default/modern/template/checkout/cart/item/default.phtml
Which is giving me the number ID, not the actual name. So instead of ‘Apple’ I’m getting ‘2’. Any ideas? I’ve tried adding ->getfrontend() but it didn’t work.

Default attributes work OK. So the following:
echo Mage::getModel(’catalog/product’)->load($this->getProduct()->getId())->getSku();
echo Mage::getModel(’catalog/product’)->load($this->getProduct()->getId())->getName();
Give the proper SKU and name.

Any ideas?
Thanks,

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top