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:

  • login to the admin panel
  • select Catalog => Attributes => Manage Attributes
  • select Add New 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 Product

Used in product listing: Yes

Now assign the new attribute to the proper attribute set(s):

  • select Catalog => Attributes => Manage Attribute Sets
  • drag your new Unassigned Attribute (grid_note) to Group
  • select Save Attribute Set

Now check the new “Grid Note” attribute and add a value:

  • select Catalog => Manage Products
  • select a Product
  • add text note to Grid Note attribute

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: