Magento – How to Display SKU on Category Page

categorysku

I would like to display the product SKU on the category pages.

I managed to plant it in the short description on every product page using:

<div class="std">
      <h5><?php echo $this->__('Product Code: ') . $this->htmlEscape($_product->getData('sku'));?></h5>
 </div>

this was on view.phtml

If i apply the same code inside list.phtml it displays on site "Product Code:" but no actual SKU number.

I am placing it just below:

<?php if ($gc['display_price'] == 1) echo '<div class="display-onhover">'; ?>
                    <?php echo $this->getPriceHtml($_product, true); ?>
                <?php if ($gc['display_price'] == 1) echo '</div>'; ?>

Best Answer

In Magento if we are working with the custom HTML integration then we want to display the products SKU on the product listing page as well as on the Product description page as by default it is not displayed in Magento frontend. It is very easy to display the product SKU on the frontend.

Diaplay SKU On The Product Listing Page.

Step 1. 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.

Step 2. Add the code below in the appropriate position where you want to display the SKU

<?php echo nl2br($_product->getSku()) ?>

<?php echo $this->htmlEscape($_product->getSku()) ?>

<?php echo $sku = Mage::getModel('catalog/product')->load($_product->getId())->getSku();?>

Now refresh the browser cache and you have done.

Related Topic