I have a big problem with attributes class engine. I add new attribute called “promotion” and put this attribute into “Default” set. I was added new product with this attribute and here start my problem. I want to display value of this attribute in the list of products. How can I do this ?
I edit this file: app/core/Mage/Catalog/Product.php
this method I call in file witch show me the list of products: app/design/frontend/default/default/template/catalog/product/list.phtml
I added this piece of code:
<?=$_product->Promotion()?>
but I don’t see my value of this attribute but this line of text: “[535,10,,promotion,eav/entity_attribute,eav/entity_attribute_backend_default,text,,,text,promotion,,,0,1,0,1,,1,0,1,1,0,0,0]”
What I have to do for show value of this attribute ?
Help and thanks.
I have this problem too. I var_dump $_data - Varien_Object field and there is no my attribute. Magento doesn`t select it from db when it create Mage_Catalog_Model_Product object.
We talking about page witch list products in category
this class is responsible(I supose) for engine of this view: app/code/core/Mage/Catalog/Model/Product.php
and template file is: app/design/frontend/default/default/template/catalog/product/list.phtml
You will need to repeat <action> tag for each additional attribute you wish to see in product list.
Moshe, can I do the same when using {{block}} tag in my content pages? I’m displaying products attached to root catalog category on homepage (as they are not visible anywhere else, and therefore can be easily used for selected products) using:
I have created additional template list_home.phtml to accomplish my design. What I need is to access thumbnail image in the template. For other category listings I have added:
But it doesn’t work. Magento shows exception ‘Mage_Core_Exception’ with message ‘Can’t retrieve current category object’ in D:\Praca\www\magento\app\Mage.php:371
Which is theoretically obvious, because none is set - but show_root_category="true" avoids the message in {{Block}} but doesn’t in layout update.
What can I do to access thumbnail image within my template on homepage (CMS page)? I have managed to do it with hacking a core, by adding
/* ADD - REMOVE WHEN MOSHE REPLIES */ $this->_getProductCollection()->addAttributeToSelect('thumbnail'); /* ADD - REMOVE WHEN MOSHE REPLIES */
to _beforeToHtml() in core/Mage/Catalog/Block/Product/List.php - but I don’t find the idea clean. I would love to replace it with something not intruding the core.
The above solutions didn’t work for me either, /I’m unable to get the manufacturer for the product. I’m trying to list products with “Manufacturer Productname”.
In the following bit of code you easily make the mistake of putting the addAttribute action after the autoclosing <block> with the list.phtml template that preceeds it.
In the original code remove the “/” before the “>” and close the block manually after adding the attribute.
This is what it looks like:
Im confused about the Product.php. Witch is the right one to do the modification?
Model/Product.php or Block/Product.php?
This is what happens:
Fatal error: Call to a member function getSource() on a non-object in /kunden/205762_85051/webseiten/site/app/code/core/Mage/Catalog/Model/Product.php on line 703
I made the same changes as Ben’s post described and it doesn’t work. I’m using Magento v1.0.
What are the files that I need to modify and what are the exact modifications needed? Can someone provide precise instructions?
Here’s what I did:
1) app / design / frontend / default / default / layout / catalog.xml
In both <catalog_category_default> and <catalog_catagory_layered>
Replace the code within <reference name="content"> and </reference>
With: