I'm having trouble trying to fetch Product data such as price, SKU etc into a custom .phtml file referenced as a block within my catalog_product_view.xml file.

Here's what I'm struggling with... I'm able to fetch product data using:

$product = $block->getProduct();

within a custom product tab under: Magento_Catalog/templates/product/tabs/instructions.phtml referenced as:

<block class="Magento\Catalog\Block\Product\View" name="instructions.tab" template="product/tabs/instructions.phtml" group="detailed_info">
                        <argument translate="true" name="title" xsi:type="string">Instructions</argument>

within my catalog_product_view.xml file.

However, when I try to pull through product information in a template block: Magento_Catalog/templates/html/myblock.phtml it doesn't work.

The block is referenced as:

<block class="Magento\Framework\View\Element\Template" group="detailed_info" name="callout" template="Magento_Catalog::html/left-callout.phtml" />

Many thanks

Your Answer

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

Browse other questions tagged or ask your own question.