Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

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

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:  23
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
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2008-08-11
 

+= 1

(I’ve the same question)

 
Magento Community Magento Community
Magento Community
Magento Community
 
Hugoto
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2008-08-11
 

Ok, SOLVED!

this post show the solution:

Moshe - 22 November 2007 01: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
Jr. Member
 
Avatar
Total Posts:  21
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
Jr. Member
 
Avatar
Total Posts:  21
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
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
50110 users|466 users currently online|102250 forum posts