Add Custom Note or Attribute to Magento Grid View

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:

1
2
3
4
5
6
7
8
9
<?php
if ( $_product->getGridNote() ) {
?>
<p class="gridnote"><?php
     echo $_product-&gt;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:

Post written by Ed Reckers

Founder and lead web development consultant at Red Bridge Internet : San Francisco WordPress Developers and Consultants.

14 Responses to “Add Custom Note or Attribute to Magento Grid View”

  1. kim

    this actually didn’t work for me. do you have any other step by step instruction?

  2. ed

    I don’t have any other instructions. Is there a part of the instructions that you can point to that you’re having problems with?

  3. mischa

    Where did you put the GridNote action in catalog.xml?

  4. ed

    mischa, 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”>

  5. Andy

    You Rock, Ed.. Thank you very much.

  6. Kimball

    Thanks!
    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.

  7. francois

    thanks a lot !

  8. emi

    Hi,
    Great post, really helpful to me. I’m a real beginner to all this php stuffs. But i tried to do exactly what you did. So i really need your help.

    My problem is the custom attribute doesn’t show up on my grid view. I already edited both catalog.xml and list.phtml.

    i added under & this…
    GridNote

    then i added in list.phtml under

    getGridNote() ) {
    ?>
    getGridNote();
    ?>

    I did all these steps above, but nothing appears on the products grid. Hope you could help me because my knowledge in all these is so limited.

    Thank you so much in advance.

    emi

  9. emi

    Hi,
    Great post, really helpful to me. I’m a real beginner to all this php stuffs. But i tried to do exactly what you did. So i really need your help.

    My problem is the custom attribute doesn’t show up on my grid view. I already edited both catalog.xml and list.phtml.

    i added under “” & “” this…
    “GridNote”

    then i added in list.phtml under “”

    “getGridNote() ) {
    ?>
    getGridNote();
    ?>

    I did all these steps above, but nothing appears on the products grid. Hope you could help me because my knowledge in all these is so limited.

    Thank you so much in advance.

    emi

    *correction on above errors

  10. R. de Rijk

    Different problem, but maybe you can help:
    in Magento 1.5.0.1 productstatus is shown as “not in stock”, while they’re in stock. I guess there’s an error in list.phtml?
    How does Magento determens if a product is saleable? I guess the list.phtml always returns “false”.

    thanks in advance for any help

  11. J Sinex

    Thank you – this helped guide us in the right direction to be able to add a special price/deal text note on the Grouped Product table. But be aware that for newer Magento versions you should NOT edit the catalog.xml file – just skip that part. For our case with the Grouped product, we changed the php code to include by $_item instead of by the product.

  12. ereckers

    J Sinex — I’m glad this helped. Also, thank you for update for the newer version of Magento.

  13. Milan

    hard to get it but finally got it… thanx for this awesome post 🙂

  14. peter

    it’s a great way to solve the issue. We used it when started manage our store. for now we use extensions.http://amasty.com/extended-product-grid.html this is the one we use to extend our product grid

Leave a Reply