I want to put an additional sku in the product page.
I have this code:
<?php
$product = $block->getCurrentProduct();
$sku = $product->getData('sku');
if (trim($sku) !== "") : ?>
<div class="product-info-sku">
<?php echo $sku; ?>
</div>
<?php endif; ?>
but I got this error
Fatal error: Uncaught Error: Call to a member function getData() on null in /var/www/magento/app/design/frontend/Mytheme/custom/Magento_Catalog/templates/product/view/attribute/additional_sku.phtml:3 S
product xml
<referenceContainer name="content">
<referenceContainer name="product.info.main">
<block class="MagentoCatalogBlockProductView" name="product.info.additional.sku" template="Magento_Catalog::product/view/attribute/additional_sku.phtml" before="product.info.price"/>
</referenceContainer>
</referenceContainer>
What did I do wrong? I’m new to Magento