I created custom product attribute - Manufactures SKU.

Want to display in product page after SKU. enter image description here

  • are you using a custom module or theme to display that custom attribute?
    – Korbin
    Jul 22 at 11:55

Please add below code in your custom extension.

Step 1: Please create file under path PackageName/Module/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <move element="product.info.newattribute" destination="product.info.stock.sku" after="-"/>
        <referenceContainer name="content">
            <block class="Magento\Catalog\Block\Product\View" name="product.info.newattribute" template="PackageName_Module::newattribute.phtml" />

Step 2:- Please create file newattribute.phtml under path PackageName/Module/view/frontend/templates/

<?php $product = $block->getProduct(); ?>
<div class="product attribute sku">
    <strong class="type">Manufactures SKU</strong>
    <div class="value" itemprop="maufacture-sku"><?php echo $product->getSku(); ?></div>

Please write your attribute code instead of getSku(); in above code.

Output :- https://prnt.sc/1g43bfi


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.