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

Code to display custom price type attribute
 
likedonduan
Jr. Member
 
Avatar
Total Posts:  12
Joined:  2008-03-04
Jakarta
 

Hello, I have some custom attribute using “Price” catalog type. What I want to do is to display that attribute. Normally those kind of attribute show up automatically in additional information block in product view page, but I remove that code from my custom theme to give extra control to what I want to display.

For custom attribute using “Drop down” attribute, I manage to display that attribute using this kind of code:
$_product->getResource()->getAttribute(’custom_attribute’)->getFrontend()->getValue($_product)

The question is, what kind of code should I use to display that attribute? I’ve try above code with no luck.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jrutter
Jr. Member
 
Total Posts:  24
Joined:  2008-04-08
 

Im trying to do something similar, have you received any solutions yet?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 

+= 1

(I’ve the same question)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 

Ok, SOLVED!

this post show the solution:

Moshe - 22 November 2007 12:17 AM

@spider: if you want to add custom attributes to product listing, you will have to add them in the layout xml.

To save time we do not load all the available attributes for all product in the list, only necessary ones (name, image, url_key, etc.)

Edit main.xml, find handles <catalog_category_default> and <catalog_category_layered> and replace in both:

<block type="catalog/product_list" name="product_list"></block>
with:
<block type="catalog/product_list" name="product_list">
   <
action method="addAttribute"><code>custom_attribute</code></action>
</
block>

You will need to repeat <action> tag for each additional attribute you wish to see in product list.

The only thing left is put the attribute in the list. To do so, open template/catalog/product/view.phtml and add your attribute this way:

<?php echo $_product->getData('custom_attribute'); ?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 

Ok, now the problem is: in search result and tagged products pages the custom_attribute is not showing anymore, and if I add the attribute in the catalogsearch.xml and tag.xml layout files, this ugly error is the result:

Fatal errorCall to a member function getProductCollection() on a non-object in /opt/lampp/htdocs/catalogo/app/code/core/Mage/Catalog/Model/Layer.php on line 41

Somebody from the magento staff could explain this please?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Member
 
Avatar
Total Posts:  33
Joined:  2008-08-11
 

Working again:
http://www.magentocommerce.com/boards/viewthread/1610/P45/

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