Magento – display SKU on product page

Magento’s default theme doesn’t display the SKU on the product page (at least as of v1.1.6). As per this discussion thread, it’s fairly easy to add by editing the template:

In whichever theme you’re using, in the file template/catalog/product/view.phtml, add the line:

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

Here’s a few lines of my view.phtml to give you some context:

40
41
42
43
44
45
46
47
48
49
50
51
<div class="product-essential">
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form">
 
     <div class="product-img-box">
         <?php echo $this->getChildHtml('media') ?>
     </div>
 
     <div class="product-shop">
         <h3 class="product-name"><?php echo $this->htmlEscape($_product->getName()) ?></h3>
         <?php echo $this->htmlEscape($_product->getSku()) ?>
 
         <?php if ($this->canEmailToFriend()): ?>

We are also reminded in the Magento thread that we should not use the default theme in place, as it’s subject to changes from release to release. Instead, you should create a copy of the default theme (if that’s what you want to start with), and work with that. See also: http://www.magentocommerce.com/design_guide/articles/working-with-magento-themes#head-how-to-create-a-theme

Facebook comments: