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
 
Wilson Sheldon
Member
 
Total Posts:  47
Joined:  2008-06-07
 

Could anyone shed any light on why I can’t get certain attributes values in the shopping cart?  For example,

I can get weight, like this:

$myprod->getWeight();

As described in the Wiki.  However I have a custom attribute ‘is_rental’.  I tried:

$myprod->getIsRental();

But it returns nothing, and no error either.

The value is clearly selected Boolean in the Admin.

Thanks for any advice!

Wilson

 
Magento Community Magento Community
Magento Community
Magento Community
 
SeL_
Magento Team
 
Avatar
Total Posts:  1140
Joined:  2007-10-10
Paris, France
 

Hi,

Please check the value of the parameter “Visible on Catalog Pages on Front-end” for your custom attribute.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wilson Sheldon
Member
 
Total Posts:  47
Joined:  2008-06-07
 

Thanks SeL.

I’ve double-checked I have that set now but I’m still not able to retrieve the value in the cart.  This is the syntax I’m using in the cart .phtml file to try and find the value.

<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php echo 'is rental? ' . $_item->getISRental(); ?>
<?php endforeach ?>

I also tried:

$_item->getProduct()->getISRental();

I’ve attached my Attribute setup.

Is there a chance the problem is with ‘scope’?

Thanks again for your help.

Wilson

Image Attachments
Picture 2.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
Wilson Sheldon
Member
 
Total Posts:  47
Joined:  2008-06-07
 

Whoops.  I fixed my typo now:

$_item->getIsRental();

(lowercase ‘s’)

Btw, this is a simple product.  Does that make a difference?  I can still retrieve many of the other attributes, just not this one.

Thanks again.
Wilson

 
Magento Community Magento Community
Magento Community
Magento Community
 
Discovery
Enthusiast
 
Total Posts:  767
Joined:  2007-12-29
 

It does not pull all attributes through into the collection for the cart, I have forgotten how to add to the xml what extra attributes you need - sorry about that, but there’s a clue. Also, a more generic function getattributetext or gettextbyname (I forget them), can you retrieve anything like that?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Wilson Sheldon
Member
 
Total Posts:  47
Joined:  2008-06-07
 

Hi everyone, Just wanted to post an update for the next person looking for this info.  I was never able to get any custom values outside of the default ones, to come through to the cart without hacking the core.  I did a global search for the ones I could get, say ‘weight’ but couldn’t see how that correlated to the cart or not.

Just occurred to me that perhaps it’s a flag you can set manually in the database?

I ended up adding a prefix to my SKU so I could move on, but if anyone knows the answer that certainly would be valuable.

Thanks,
Wilson

 
Magento Community Magento Community
Magento Community
Magento Community
 
till
Member
 
Total Posts:  58
Joined:  2007-12-17
 

Check this thread:
http://www.magentocommerce.com/boards/viewreply/94559/

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