Quantcast
Channel: Manchester Web Design | Development | CMS | SEO | Really Web Design
Viewing all articles
Browse latest Browse all 8

Magento – Custom Attributes on category listing pages

$
0
0

A quick one here. A client wanted some custom attributes of theirs to show up on their category listing pages of a Magento build. This used to be a lot trickier than it now is, so I thought I’d outline what you need to do.

Let’s say you have an attribute set up with the attribute code “my_special_attribute”.

You can then access this with a getter function on the $_product object within theme/template/product/list.phtml.

Head to within the foreach statements (there’s typically two, as there are grid & list views), and type:

foreach ($_productCollection as $_product) :

    echo $_product->getMySpecialAttribute();

endforeach;

Note how the getter function uses the camelCase equivalent of your attribute code. So if you’re attribute code was “breadth in mm”, you would use $_product->getBreadthInMm.

If you’re still having difficulties getting your attribute to show, make sure you look in your attribute settings, and that “Used in Product Listing” is set to “yes”. Obvious, I know, but once I spent about half an hour trying to work out why it wasn’t working. Magento can make fools of us all.


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images