I recently needed to allow for a custom note to be shown in Magento’s Grid and List views. My client asked that they be able to add to any product a customized note (text snippet) to announce such things as “Expected back in stock soon”, “20% Off Today”, “Color Red Coming this Week” and so on.
Luckily this is easily accomplished by using Magento’s attribute system and then editing a few templates. In this example I will be adding an attribute titled “Grid Note” with a system value of “grid_note”. Below are the steps I used for printing a product attribute on both the Grid and List views of a Magento store.
The first step is to create a plain text magento attribute:
Below are the actual values I submitted. Whatever not explicitly stated use default (you use whatever works for you):
Attribute Code: grid_note
Scope: Global
Catalog Input Type…: Text Field
Apply To: Selected Product Types :: Simple ProductUsed in product listing: Yes
Now assign the new attribute to the proper attribute set(s):
Now check the new “Grid Note” attribute and add a value:
The next step is to echo/print the new Magento attribute value to the grid and list view(s). There is good writeup on the Magento Wiki on How to add attributes to product grid in category which should first be reviewed. There are three files that I ended up editing to get to this point. For the sake of following through on my example and for my own documentation, I’ll list below the steps:
Edit: design/frontend/[your_template]/default/layout/catalog.xml
Follow the instructions under Update layout XML for How to add attributes to product grid in category.
I used the following lines:
<action method=”addAttribute”><attribute>GridNote</attribute></action>
Edit: design/frontend/[your_template]/default/template/catalog/product/list.phtml
Follow the instructions under Update templates for How to add attributes to product grid in category.
I used the following lines:
<?php
if ( $_product->getGridNote() ) {
?>
<p class=”gridnote”><?php
echo $_product->getGridNote();
?></p>
<?php
}
?>
Your next step is to add styling to your stylesheet. That should be pretty self explanatory and I won’t go into it here.
That’s about it for adding a custom note to your Magento store’s Grid and List views. By using Magento’s product attribute system you can add, edit, delete, and manage a custom message per product on your store’s Grid and List Views.
The following links were helpful in this post:
6 Responses
kim
July 1st, 2009 at 4:14 am
1this actually didn’t work for me. do you have any other step by step instruction?
ed
July 1st, 2009 at 9:28 am
2I don’t have any other instructions. Is there a part of the instructions that you can point to that you’re having problems with?
mischa
August 3rd, 2009 at 5:39 am
3Where did you put the GridNote action in catalog.xml?
ed
August 3rd, 2009 at 8:24 pm
4mischa, for the proper placement of the GridNote action in catalog.xml follow the instructions under the heading “Update layout XML” in the following Magento Wiki article:
http://www.magentocommerce.com/wiki/how-to/add-attributes-to-product-grid
Basically, you add it twice. Directly below/after the line(s):
< block type=”catalog/product_list” name=”product_list” template=”catalog/product/list.phtml”>
Andy
September 2nd, 2009 at 1:52 pm
5You Rock, Ed.. Thank you very much.
Kimball
December 17th, 2009 at 8:00 am
6Thanks!
Some how I missed “Used in product listing: Yes” when setting up a custom attributes. Without it the helper “$_product->getGridNote()” will not work in /cat…/prod…/list.phtml.
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Clients and Projects
Recently Written
Calendar
Recent Entries
Recent Comments
Most Commented
Kliky.Net - Web Development Blog is proudly powered by WordPress - BloggingPro theme by: Design Disease