Magento 1: How to Add Product Labels in 20 minutes

add-product-label-in-magento

Most of the templates that you’ve purchase off the shelves come with 2 default labels, namely New and Sale. As the needs for market grows, an eCommerce site may need more than 2 labels.

Therefore, in this guide we will show you how to create additional product labels using attributes.

Before you begin, please have the following ready:

  • Store backend access
  • Store FTP access
  • Labels in .png/.jpeg (new and sales or anything)

Log into your Magento admin panel and go to the menu Catalog -> Attributes -> Manage Attributes. 

1.Click on the Add New Attribute button and follow the 2 steps as shown on the image.

add-product-label-in-magento-1.pngProceed to Manage Label/Options and follow the 2 steps on shown on the image.

2. Do the same for Sale label:

add-product-label-in-magento-2.png
add-product-label-in-magento-3.png

3. Now, attaching the newly created attribute to the product. Go to Catalog -> Attributes -> Manage Attribute Sets. Choose your attribute set. Usually it is called Default.

add-product-label-in-magento-4.png

4. Choose your New and/or Sale attributes from the “Unassigned Attributes” section on the right and drag it to the Groups section on the left.

add-product-label-in-magento-5.png

5. Click on Save Attribute Set.

6. Go to Catalog -> Manage Products,  choose a desire product and set the newly added attributes (Sale or New) depending on which you’ve added earlier on.

add-product-label-in-magento-7.png

7. Save the product.

Now you’ve got the first part done. The next step is to add a few lines of code to the template file.

  • Login to the FTP.
  • Navigate to /public_html/app/design/frontend/theme/theme_name/template/catalog/product/list.phtml
    *remember to replace theme and theme_name to your own theme*
  • Locate this line: “foreach ($_productCollection as $_product): ?>” and add in the follow code within the <li></li> tag

For NEW
<?php if ($_product->getAttributeText('new') == "Yes"): ?>
<div class="custom-product-new">
<img src="<?php echo Mage::getBaseUrl(); ?>media/wysiwyg/label_blue_new.png">
</div >
<?php endif; ?>

For SALE

<?php if ($_product->getAttributeText('sale') == "Yes"): ?>
<div class="custom-product-special">
<img src="<?php echo Mage::getBaseUrl(); ?>media/wysiwyg/bb-label-special-d.png">
</div >
<?php endif; ?>

Comments