Display The Custom Products Attributes On the Frontend Product Listing as Well as on the Product Description Page In Magento



Suppose you have create a custom product attributes through the Magento admin and assigned this attributes to the products if you are facing problem how to create the attribute and assigned it into the admin

Refer to the “Create and Assign Product Attributes Through Admin Panel In Magento“. Now if you want to display this attribute into the frontend follow the steps given below:

Step 1. Suppose I have created and assigned a attribute through the Magento admin here my attribute is Part Number and the attribute code is “partno”.

Step 2. For Displaying the attribute on the product listing page, navigate to the /app/design/frontend/default/your_custom_template/template/catalog/product/list.phtml or Navigate to the /app/design/frontend/base/default/template/catalog/product/list.phtml open the file in the editor of your choice and insert the code below where you want to display the custom attribute.

<?php echo $Partnumber = nl2br($_product->getResource()->getAttribute('attributeCode')->getFrontend()->getValue($_product)); ?>

<?php echo $Partnumber = nl2br($_product->getResource()->getAttribute('partno')->getFrontend()->getValue($_product)); ?>

Step 3. For Displaying the attribute on the product description page, navigate to the /app/design/frontend/default/your_custom_template/template/catalog/product/view.phtml or Navigate to the /app/design/frontend/base/default/template/catalog/product/view.phtml open the file in the editor of your choice and insert the code below where you want to display the custom attribute.

<?php echo $Partnumber = nl2br($_product->getResource()->getAttribute('attributeCode')->getFrontend()->getValue($_product)); ?>

<?php echo $Partnumber = nl2br($_product->getResource()->getAttribute('partno')->getFrontend()->getValue($_product)); ?>

Note : It is very important for displaying the attribute on the frontend which you want to display on the frontend it should be Visible on Product View Page on Front-end “YES” and Used in Product Listing = “YES” as like the below image.

Attributeonfrontend

Hope this will help someone.