our product has SKU and P/N number. All product's SKU has the same, but the P/N will depend on the country, so I've created an attribute "P/N" and want to show P/N on the product page instead of SKU.

It is possible to replace SKU on the frontend with P/N?

can anyone help me with this?

  • Hi @eric, Have you tried my solution? If it helped, please upvote and accept my answer so that others can also get benefitted from it. Commented Jun 14, 2019 at 5:46

1 Answer 1


Note: I have not tried it yet but it should work.

To show the SKU value in the product view page, /vendor/magento/module-catalog/view/frontend/templates/product/view/attribute.phtml file is called.

In this file you will find code like below:

$_call = $block->getAtCall();
$_code = $block->getAtCode();

which basically gets the values from the default catalog_product_view.xml file, there is a code block like below:

    <argument name="at_call" xsi:type="string">getSku</argument>
    <argument name="at_code" xsi:type="string">sku</argument>
    <argument name="css_class" xsi:type="string">sku</argument>
    <argument name="at_label" xsi:type="string">default</argument>
    <argument name="add_attribute" xsi:type="string">itemprop="sku"</argument>

You can override catalog_product_view.xml in your theme and change the values of at_call, at_code, css_class, at_label, and add_attribute as per your requirement.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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