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 would I do an addAttribute to a CMS page? 
 
Shpigford
Sr. Member
 
Avatar
Total Posts:  171
Joined:  2007-09-03
Denver, CO
 

On my CMS home page I have the following (to list new products):

{{block type="catalog/product_new" name="home.catalog.product.new" alias="product_new" template="catalog/product/new.phtml"}}

I need to be able to access an attribute, though.

For my category pages I can add this to my product_list block:

<action method="addAttribute"><attribute>artist</attribute></action>

But I can’t figure out how to get this in to the block on the home page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
phillyj8
Jr. Member
 
Total Posts:  27
Joined:  2008-06-12
 

I’m trying to figure out how to do exactly the same thing.  I’ve added attributes to my product page and category page, but can’t work out how to add them to a CMS page.

After looking at many forum posts, it seems like I should be able modify the following code on New.php:

From:

->addAttributeToSelect(array('name''price''small_image'), 'inner')

To:

->addAttributeToSelect(array('name''price''small_image''manufacturer'), 'inner')

And then add something like this to new.phtml or whatever template you’re using:

<?php echo $_product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($_product?>

But I can’t seem to get it to work.  Just says “No”.  So I guess that manufacturer attribute is still not available to new.phtml.  Not sure what else to do to make it available.

 
Magento Community Magento Community
Magento Community
Magento Community
 
phillyj8
Jr. Member
 
Total Posts:  27
Joined:  2008-06-12
 

Wow I am upset with myself.  After a couple hours of banging my head against the wall on this, I just realized that I actually did have this working - I was just looking at the wrong CMS page on my site.

So that code should work for you - it is for me.  I will give the disclaimer that I have no idea what I’m doing, just sort of fishing around and copying other people in the forums and it seemed to work.

Now I’d like to figure out how to get the toolbar in one of these pages so I can have grid/list view - any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Shpigford
Sr. Member
 
Avatar
Total Posts:  171
Joined:  2007-09-03
Denver, CO
 

Hmmm. I’d rather not modify a core file (New.php).

Anyone else have an idea?

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