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