I’m not sure about Nikkstocks last post...I thought the “myattribute” part of “getmyattribute” depends on what your attribute is called. So if the attribute I want to display is “catalogdescription”, I should use “getcatalogdescription”?
I’m having some problems getting this work - can you share what you did to get it running?
Looking through the wiki file’s revision history, it looks like they’ve updated that document since you posted, and fixed the problem you were talking about.
I still don’t seem to be able to get this to work though. Can anyone confirm that using getCatalogDescription should work fine, given that my attribute is called CatalogDescription?
As the wiki page is slightly confusing I’d like to clear things up a bit. There are actually two things you have to do:
1. Update your xml
2. Update your template
Lets look at an example for an attribute called “Manufacturer”.
basically what you do here is make your Attribute known in the product list.
In template/catalog/product/list.phtml you can then display the attribute value like this (be sure to add the output to the correct list layout, ie. ‘list’ or ‘grid’):
As asn extension to this, how would I display a custom attribute in a different format?
i.e
I have a custom attribute called publish_date which is a date field.
I want to show this in the category list, so I edited…
/app/design/frontend/default/default/template/catalog/product/list.phtml
and added. <?php echo $_product->getpublish_date()?>
This displays the attribute but shows it as for example 2008-1-12 00:00:00
In the product page itself under Additional Information, this is re-written to display as Jan 12, 2008 when in the product view page. Any suggestions how I can achieve this much nicer format?
As the wiki page is slightly confusing I’d like to clear things up a bit. There are actually two things you have to do:
1. Update your xml
2. Update your template
Lets look at an example for an attribute called “Manufacturer”.
basically what you do here is make your Attribute known in the product list.
In template/catalog/product/list.phtml you can then display the attribute value like this (be sure to add the output to the correct list layout, ie. ‘list’ or ‘grid’):
I have also updated “Visible on Catalog Pages on Front-end” in the admin panel.
But it is not working somehow, none of the 4 echo is printing anything. What have I possibility done wrong? Any help is much appreciated.
I was just trying to see if we could display a custom attribute in the product detail view: not just the value, but th label and type as well. For instance, I we have a dropdown select attribute, can we display that dropdown for the customer to select in place of a custom product option?
If so, what about a text field and text area? Thanks for the replies at your earliest convenience! Normally with attributes their value (defined in the product) is what gets displayed. But we would like to use this in place of a custom product option. Possible?
It all looks right, so I’ll try this out soon.
Thanks foe the dialogue!
maarlin - 11 February 2009 11:02 AM
Firstly I added new method to class Mage_Catalog_Block_Product_View_Attributes:
function setProduct($productId) { if (!Mage::registry('product') && $productId) { $this->_product = Mage::getModel('catalog/product')->load($productId); } }
Then I’ve added to /app/design/frontend/*/*/template/catalog/product/list.phtml this: