Magento Forum

   
Getting item attributes from a cart at checkout
 
dniesen
Member
 
Total Posts:  74
Joined:  2008-04-05
 

I’m trying to modify a shipping module to change the shipping options based on an attribute but I’m having a hard time wrapping my head around all of the classes and methods. 

How do I get the value of an attribute for the items in a cart at checkout?

So far I’ve pulled in the product using this:

$product Mage::getModel('catalog/product')->loadByAttribute('sku'$item->getSku(), array('perishable'));

I just can’t figure out how to pull the value.

 
Magento Community Magento Community
Magento Community
Magento Community
 
dniesen
Member
 
Total Posts:  74
Joined:  2008-04-05
 

Bah, I figured this out myself.  I made it much harder than it ever needed to be.  If anybody needs/wants details, let me know.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jacky2008
Member
 
Total Posts:  43
Joined:  2008-04-15
 

I just get the SKU shown at checkout page.

But I need show SKU, weight or any attribute. Anyone can help?

UP!

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

you can define additional attributes for quote in your own module config.xml file within <global> node:

<global>
    <
sales>
            <
quote>               
                <
item>
                    <
product_attributes>                        
                        <
is_preorder/> <!-- OWN NEW ATTRIBUTE -->
                    </
product_attributes>
                </
item>
            </
quote>
</
sales>

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jacky2008
Member
 
Total Posts:  43
Joined:  2008-04-15
 

@zentrale,

Thanks, it works for me. cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

you are welcome wink

Bye

 
Magento Community Magento Community
Magento Community
Magento Community
 
vibhor
Jr. Member
 
Total Posts:  15
Joined:  2008-08-29
 

@dniesen,

I have a similar requirement. I want to show the product’s long description as well in the cart. Can you please tell me how can i do so?

Thanks,
Vibhor

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

f.e. edit file /app/etc/local.xml. Within <global> node add following code:

<sales>
            <
quote>               
                <
item>
                    <
product_attributes>                        
                        <
description/> <!--Description -->
                        <
short_description/> <!--Short Description -->
                    </
product_attributes>
                </
item>
            </
quote>
</
sales>

Within checkout or cart phtml for displaying cart or checkout items you can print those attributes with

<?$_item->getDescription() ?>
<?
$_item->getShortDescription() ?>

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
vibhor
Jr. Member
 
Total Posts:  15
Joined:  2008-08-29
 

zentrale:

thanks for your reply. I tried as you suggested but with no luck.
Can you explain me why i need to edit the local.xml file? (newbie here)
I am trying to put ‘

<?=$_item->getDescription()?>
in /checkput/cart/item/default.phtml.

any suggestions would be really helpful.

Thanks,
Vibhor

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

in app/etc/local.xml you can add the individualization. Heres n example from my local.xml:

<config>
    <global>
        <
install>
            <
date><![CDATA[Wed30 Jul 2008 08:58:18 +0000]]></date>
        </
install>
        <
crypt>
            <
key><![CDATA[xxxxxxxxxxxxxxxxxx]]></key>
        </
crypt>
        <
disable_local_modules>false</disable_local_modules>
        <
resources>
            <
db>
                <
table_prefix><![CDATA[]]></table_prefix>
            </
db>
            <
default_setup>
                <
connection>
                    <
host><![CDATA[xxxxxxxxxxx]]></host>
                    <
username><![CDATA[xxxxxxxxxx]]></username>
                    <
password><![CDATA[xxxxxxxxxxxxxxxxx]]></password>
                    <
dbname><![CDATA[xxxxxxxxxxxxxxxxxxxxxx]]></dbname>
                    <
active>1</active>
                </
connection>
            </
default_setup>
         </
resources>
         <
session_save><![CDATA[files]]></session_save>
         <
sales>
            <
quote>               
                <
item>
                    <
product_attributes>                        
                        <
description/> <!--Description -->
                        <
short_description/> <!--Short Description -->
                    </
product_attributes>
                </
item>
            </
quote>
        </
sales
     </global>
     <
admin>
        <
routers>
            <
adminhtml>
                <
args>
                    <
frontName><![CDATA[admin]]></frontName>
                </
args>
            </
adminhtml>
        </
routers>
     </
admin>
</
config>

cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
QuattroPorte
Jr. Member
 
Avatar
Total Posts:  19
Joined:  2008-03-08
 

zentrale

As vibhor, I have followed your suggestion and added necessary code to app/etc/local.xml and the attributes are not getting pulled in :(

app/etc/local.xml:

....
<!-- 
Custom templates -->
        <
cms>
            <
layouts>
                <
redirect>
                    <
label>2C RB NoNav</label>
                    <
template>page/2columns-right-nonav.phtml</template>
                </
redirect>
            </
layouts>
        </
cms>
<!-- 
Additional attributes -->
        <
sales>
            <
quote>               
                <
item>
                    <
product_attributes>                        
                        <
artwork_image_size /> <!-- Artwork Image Size -->
                        <
short_description /> <!--Short Description -->
                    </
product_attributes>
                </
item>
            </
quote>
       </
sales>    
<!-- 
End Additions -->
     </global>

template/checkout/cart/item/default.phtml:

<?php $_item $this->getItem()?>
...
<?php echo $_item->getArtworkImageSize() ?>
...

Nichts, rein nichts :(

This is on a 1.1.7 install.
Any suggestions?

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