Magento Forum

Adding product attribute to shopping cart page
 
sheba2
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2011-01-05
United States
 

Please see attached.  How do I add the product attribute selected when product was created to the shopping cart page?  Thanks for your attention.

Image Attachments
prodattribute_show_on_shoppingcart.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
sumantechno
Guru
 
Avatar
Total Posts:  478
Joined:  2010-03-09
Bangalore
 

In cart.phtml of your current theme create new column and place “Product Type”.
In my case page was located:
app/design/frontend/default/suman/template/checkout/cart.phtml

Add new column on default.phtml of your current them.
My case it was located in
app/design/frontend/base/default/template/checkout/cart/item/default.phtml

Use the following code to print the attribute value

<?php 
        $productId 
$_item->getId();
        
$productInfo Mage::getModel("catalog/product")->load($productId); 
        echo 
$productInfo->getAttributeText('product_type'); 
?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
sheba2
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2011-01-05
United States
 

Hi Suman,

I am new to magento.  Can you please give me a step by step as to how I “create the new column” and make it functional.  I went into my cart.phtml and duplicated one of the lines please see attached.

Where in the default.phtml do I add the code you provided?  I tried different placements and ALL disabled the shopping cart page.

Image Attachments
shopcart_columnchange.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
sumantechno
Guru
 
Avatar
Total Posts:  478
Joined:  2010-03-09
Bangalore
 

I placed the following code in the default.phtml at line number 69

<td>
    
<?php 
        $productId 
$_item->getId();
        
$productInfo Mage::getModel("catalog/product")->load($productId); 
        echo 
$productInfo->getAttributeText('product_type');  //Attribute Code
    
?>
    
</td>

Remember by attribute code was “product_type”. Change this accordingly to your store.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sheba2
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2011-01-05
United States
 

How do I add the “Product Type” column to the page?

What do I add to cart.phml?  and what line do I add it?

What you have given me is NOT working.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sumantechno
Guru
 
Avatar
Total Posts:  478
Joined:  2010-03-09
Bangalore
 

I am attaching default.php located in “app/design/frontend/base/default/template/checkout/cart/item/”

File Attachments
default.phtml  (File Size: 19KB - Downloads: 123)
 
Magento Community Magento Community
Magento Community
Magento Community
 
sheba2
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2011-01-05
United States
 

Thanks, can you send me the cart.phtml too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sumantechno
Guru
 
Avatar
Total Posts:  478
Joined:  2010-03-09
Bangalore
 

Cart.phtml attached

File Attachments
cart.phtml  (File Size: 8KB - Downloads: 79)
 
Magento Community Magento Community
Magento Community
Magento Community
 
sheba2
Sr. Member
 
Avatar
Total Posts:  111
Joined:  2011-01-05
United States
 

Not working.  I first I made the changes in your file in mine.  Then I just copied your file over mine.  Both did not work.  I even tried 8 different attribute codes just to be sure the attribute code is not the issue.

Image Attachments
shopcart_columnchange_2.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
kelvinkyaw
Jr. Member
 
Total Posts:  3
Joined:  2013-01-29
Myanmar [Burma], Yangon
 

in your cart.phtml page

<th rowspan="<?php echo $mergedCells; ?>"><span class="nobr"><?php echo $this->__('Your New Column'?></span></th>


in your default.phtml

<td>
    
<?php 
        $productId 
$_item->getId();
        
$productInfo Mage::getModel("catalog/product")->load($productId); 
        echo 
$productInfo->getResource()->getAttribute('attribute_code')->getFrontend()->getValue($productInfo);
    
?>
</td>

Hopefully-->this will help!!!!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
PowercutUK
Member
 
Avatar
Total Posts:  65
Joined:  2011-04-04
Carmarthen, Wales, UK
 

Excellent advice and code Magento4u. Thanks

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