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.

Bookmark and Share

About the Author

MXWest

3 Responses to “ Magento – display SKU on product listing page ”

  1. Hey man, you’re my hero!!!
    Thanks dude!!
    PD:your son looks just like you.

  2. Genius !! Greetings from France – a life saver, now if you can tell me how to apply tiered pricing to multiple products I will buy you a huge glass of Chablis next time you’re near Bordeaux
    cheers
    K

  3. gratitude

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>