Tuesday, January 10, 2012

Magento display the custom attribute value in Frontend

Add an attribute from magento admin and that attribute should belong to corect attribute set
Then edit the template file either view.phtml or list.phtml
For example we are using in list.phtml
app/design/frontend/default/your-theme/template/catalog/product/list.phtml
and use one of these methods to pull your attribute on the product listing page (list or grid view):

<?php foreach ($_productCollection as $_product): ?>

    <!-- these are regular text attributes -->
      <?php echo $_product->getMyAttribute() ?>
      <?php echo $_product->getAnotherCustomAttribute() ?>
   
    <!-- this is dropdown attribute -->
      <?php echo $_product->getAttributeText('your_attribute') ?>
   
    <!-- this is a boolean attribute -->
      <?php echo $_product->getMyAttributeName() ? "Yes" : "No" ?>

<?php endforeach?>

1 comment:

Thankyou for your Comments

LinkWithin

Blog has moved, searching new blog...