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

How to add Attributes to display in CMS products listing? 
 
Ross
Guru
 
Avatar
Total Posts:  336
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 

I have customised the catalog/product/list.phtml to show some additional Attributes for each product
(according to this wiki: http://www.magentocommerce.com/wiki/how-to/add-attributes-to-product-grid )

As well as the Category pages, the website front page (CMS) displays a category listing:

{{block type="catalog/product_list" category_id="9" template="catalog/product/list.phtml"}}
...but the added attributes do not show on this page because it is a CMS and not a Catalog page.

This code is used in the catalog.xml layout:

<reference name="content">
    <
block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
        <
block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
            <
action method="addAttribute"><attribute>author</attribute></action>
            <
action method="addAttribute"><attribute>ages_multi</attribute></action>
        </
block>
    </
block>
</
reference>
but does not work in the Layout Update XML, or in the cms.xml (from my attempts anyway).

some other people seemed interested in this question as well:
http://www.magentocommerce.com/boards/viewthread/5730/

any help would be apreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Guru
 
Avatar
Total Posts:  336
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 

I noticed that the search page doesn’t show extra attributes as well.  I am going to see if I can get around the problem by creating new template files for the front page and search page.  Wish me luck smile

(I guess the reason the attributes aren’t selected from the database by default is for performance reasons, but it would be great if they could be automagically selected when requested)

 
Magento Community Magento Community
Magento Community
Magento Community
 
seudo
Guru
 
Avatar
Total Posts:  344
Joined:  2008-04-21
 
Ross - 10 June 2008 12:34 AM

I am going to see if I can get around the problem by creating new template files for the front page and search page.  Wish me luck smile

Any developments on this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Guru
 
Avatar
Total Posts:  336
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 
seudo? - 16 July 2008 09:40 AM

Any developments on this?

Sorry, I couldn’t afford to spend a lot of time on this so I just did what was quickest and easiest - hack the core files.

For example, to include a custom attribute ’author‘ - so that it displays on the search pages:
add in file: app/code/core/Mage/CatalogSearch/Block/Result.php (about line 100)

->addAttributeToSelect('author')
(for regular categories the XML does work, which is a preferable method - as it won’t get overwritten with an upgrade)

For CMS pages with category listings, add a similar line to:
app/code/core/Mage/Catalog/Model/Layer.php (about line 74)

 
Magento Community Magento Community
Magento Community
Magento Community
 
seudo
Guru
 
Avatar
Total Posts:  344
Joined:  2008-04-21
 

Ross,
Thanks a bunch for the quick reply. I will continue to see what I can do.  Hopefully there will be some of these issues fixed for v1.1 but from what I have been reading on other issues I am having, the beta appears to be adding new features while leaving important problems unresolved.

thanks again!

 
Magento Community Magento Community
Magento Community
Magento Community
 
OurWorldTalks
Member
 
Total Posts:  60
Joined:  2008-07-08
 

Hi there.... did u managed to get the extra attributes to show on the page? I see for the page http://www.outoftheark.co.uk/born-in-a-barn.html, there is a text attribute of Ages. And at just below the title of the product, there is age again. Are you pulling the age from the attributes to the top, it also shows at the front page when viewing a list of products.

Could you kindly guide us on how to do that?
Appreciate it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ross
Guru
 
Avatar
Total Posts:  336
Joined:  2007-08-31
Scarborough, North Yorkshire, UK
 
OurWorldTalks - 17 July 2008 05:24 AM

Hi there.... did u managed to get the extra attributes to show on the page? I see for the page http://www.outoftheark.co.uk/born-in-a-barn.html, there is a text attribute of Ages. And at just below the title of the product, there is age again. Are you pulling the age from the attributes to the top, it also shows at the front page when viewing a list of products.

Could you kindly guide us on how to do that?
Appreciate it.

Edit the template for the product page:
frontend/default/mytheme/template/catalog/product/view.phtm
by adding code like this:

<class="author">by <?php echo $_product->getAuthor()?></p>
<
class="ages">Ages<?php echo $_product->getAges()?> years</p>
(in this case the attribute names are ‘author’ and ‘ages’)

I think that should just work (can’t remember doing anything else).  It was on the product listing pages (CMS, category, search) and the cart page where there is the need to tell Magento to addAttributeToSelect()

 
Magento Community Magento Community
Magento Community
Magento Community
 
OurWorldTalks
Member
 
Total Posts:  60
Joined:  2008-07-08
 

Hi Ross, it worked perfectly. Thanks for sharing!

 
Magento Community Magento Community
Magento Community
Magento Community
 
team_in_medias
Sr. Member
 
Avatar
Total Posts:  113
Joined:  2008-05-06
Aachen, Germany
 

Any idea how I get custom attributes to show in sales\order\recent.phtml?

I am using the following code:

$_orders $this->getOrders(); 
foreach (
$_orders as $_order{
    $_items 
$_order->getItemsCollection();
    foreach (
$_items as $_item{
[
...]

Thanks in Advance,
Andreas

 
Magento Community Magento Community
Magento Community
Magento Community
 
brad_frost
Jr. Member
 
Total Posts:  20
Joined:  2008-06-27
 

I am having problems following Ross’s advice. My current situation is laid out here (http://www.magentocommerce.com/boards/viewthread/15553/#)

Basically my code is currently returning “No” where the attribute ‘designer’ should show. Adding the attribute to catalogsearch.xml causes the page not to load.  I tried Ross’s method of adding the attributes to the core code, however, the search results is still returning a blank page.

Any advice on how to remedy this issue?

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