Almost every store is going to require custom attributes for its products. Naturally, you are going to want to advertise some of these features on the category and product listing pages. So I’d thought I’d take the time to write a short note on how to get this done.
Initially, for each product attribute which you want to use on the product page or category page, you will have tell Magento whether or not they should be made available.
To do this, find the attribute under Magento Admin -> Catalog -> Attributes -> Manage Attribute Sets. Then under frontend properties, near the bottom, you will find options for: “Visible on Product View Page on Front-end” and “Used in Product Listing”. These will allow you to display the attribute on the product page and category page respectively.
Then, when it comes to your theme design, there are a couple of ways that you can retrieve the attribute. For most you will be able to use:
<?php echo $_product->getAttributeName(); ?>
For example, suppose you were selling computer monitors and you had a field called screen_size. You would get the product field by:
<?php echo $_product->getScreenSize(); ?>
However, if the attribute is a dropdown box, this will only return an ID, so you will need to use another method. Luckily, it’s just as simple to remember! The getAttributeText function takes the field name as a parameter.
<?php echo $_product->getAttributeText('screen_size'); ?>
That’s it! If you cannot get it to work, double check that you have set the right scope for the attribute in admin.
Related posts:
Totally need to stress the fact that you need to set the frontend properties. That has done me a couple of times in the past.
My configurable products show up but when you click on add to cart, the product goes to the cart, and it asks you to choose options, but there is no drop down box for you to choose the size. All I want to do is set up t-shirts and let them pick their size. aarrrrggghhh…..can you help?
Hi Lisa. I’ve had a look at this product: http://www.phitlifeonline.com/shop/index.php/burnout-tee-grey-phit-life-bring-it-37.html, it doesn’t currently have any options displayed front end as you say, but also doesn’t seem to have an add to cart button at the moment?
I guess a couple of questions first would be have you made any template modifications on the product page? Have you added simple products to your configurable product for the different shirt sizes?
Thanks for the quick response! I can see the add to cart button on the front page but when I click it and it opens up the product – that’s when I don’t see the drop down box with options. I have added simple products to the configuarable product for the different shirt sizes. I am not aware of any template modifications on the product pages.
Hmm, the most likely thing is that the product hasn’t been configured properly but it’s difficult to work out what exactly is wrong without actually having a look in the admin area. I’ll send you an email to see if I can help further.
pls tell me how to add a product to cart with multiple attribute
This is really interesting, You’re an overly skilled blogger. I’ve joined your feed and stay up for seeking extra of your wonderful post. Also, I have shared your website in my social networks