Looking for the best way to add the SKU field on the category list page in Magento 2 using the Luma theme ? (Please note the Luma theme is the default theme that ships with Magento2)


first, you should create your own theme (with the luma theme as parent in your case) to extend the template.

If you have not done this yet, a good starting point is to copy the luma theme, remove all Module folders and adjust the configurations. Here is a link to the official documentation: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-create.html

Then you have to override the product list theme (https://github.com/magento/magento2/blob/d3be4538b600e2c97e3fc36153da268bb2f98c39/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml)

This file has to be placed in <theme_root_dir>/Magento_Catalog/templates/product/list.phtml

The Sku should be available in the loaded product I think. If not, you would have to adjust the Attribute Config in the Backend so that it is available on the Category Page.

If it is, you should be able to get the sku by simply adding the following statement for example below here: https://github.com/magento/magento2/blob/d3be4538b600e2c97e3fc36153da268bb2f98c39/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml#L65

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.