cancel
Showing results for 
Search instead for 
Did you mean: 

Display product SKU on category page

Display product SKU on category page

I am wanting to display the product SKU on the category page (page that shows list of all products in the category).

I would like to display the SKU right under the name of the product but I'm not sure how to go about doing this.

 

I have a custom theme that I have made using blank and the parent template.

2 REPLIES 2

Re: Display product SKU on category page

I got it working.

I had to add this php code:

<?php /* @escapeNotVerified */ echo $_product->getSku() ?>

 

I copied this file:

/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml

 

The copy of list.phtml was put inside my theme directory here:

/public_html/app/design/frontend/[your vendor name]/[your theme name]/Magento_Catalog/templates/product/list.phtml

 

Then inside that file, you add that bit of php code wherever you want the product SKU to be displayed and clear cache.

Re: Display product SKU on category page

Yes, you can also replace this code in class= product-item-link”

 

<a class="product-item-link"
                           	href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>">
                            	<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                            	(<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getSku(), 'sku'); ?>)
                        	</a>
OpenSource Expert | OpenSource Technologies | www.opensourcetechnologies.com
Magento plugins released: http://www.opensourcetechnologies.com/product/product-category/magento-extensions