Magento – display SKU on product listing page

In list.phtml, I want to be able to see the SKU in the product listing. list.phtml is a simple if a tad large “if-else” construct, the first part of the if being list view, the else part being the grid view. So, if you want it in both places, you’ll have to hit 2 spots. list.phtml is found in app/design/frontend/pathToYourTheme/template/catalog/product.

On this particular project, SKU is very important. We mail out several catalogs to various verticals, and some people don’t know anything but the SKU when they’re ordering.

My theme is based on default. Your actual line numbers may vary, but here’s the context for list view, the “if” of our template:


55 <?php // Product description ?>
56 <div class="product-shop">
57 <h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h5>
58 <?php echo $this->htmlEscape($_product->getSku()); ?>
59 <?php if($_product->getRatingSummary()): ?>
60 <?php echo $this->getReviewsSummaryHtml($_product) ?>
61 <?php endif; ?>

Grid view is the “else” of this section, it’s down a little further in list.phtml:


102 <h5><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><? php echo $this->htmlEscape($_product->getName()) ?></a></h5>
103 <?php echo $this->htmlEscape($_product->getSku()); ?>
104 <?php if($_product->getRatingSummary()): ?>
105 <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
106 <?php endif; ?>

And that’s it! You’ll have a nice display of your SKU.

Facebook comments: