I copied catalog_product_view.xml and pasted it into app\design\frontend\Mytheme\DreamShop\Magento_Catalog\layout folder and code is added before the default.phtml

<block class="Magento\Catalog\Block\Product\View" name="product.info.options.productname" as="productname" template="Magento_Catalog::product/view/options/productname.phtml"/>

enter image description here

  • You are saying that you want name of the product but code says you are showing category name. What do you want please explain more? Jul 9, 2018 at 7:30
  • I want product name Jul 9, 2018 at 7:58
  • How did you add the file.phtml in your catalog page? Can you post the xml code in your question? Jul 9, 2018 at 8:30
  • <block class="Magento\Catalog\Block\Product\View\Options\Type\DefaultType" name="product.info.options.productname" as="productname" template="Magento_Catalog::product/view/options/productname.phtml"/> Jul 9, 2018 at 9:01
  • Are you calling it in product details page? Jul 9, 2018 at 9:05

3 Answers 3


Change the xml to below code:

<block class="Magento\Catalog\Block\Product\View" name="product.info.options.productname" as="productname" template="Magento_Catalog::product/view/options/productname.phtml"/>

In your template file productname.phtml add the below code:

<? php echo $this->getProduct()->getName(); ?>

Note: This should work if you are using this product in your product details page.

  1. app/design/frontend/{Theme}/{name}/Magento_Catalog/layout/catalog_product_view.xml

    <?xml version="1.0"?>
    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="product.info.main">
            <block class="Magento\Catalog\Block\Product\View" name="product.name" template="Magento_Catalog::productData.phtml" before="-" />
  2. app/design/frontend/{Theme}/{name}/Magento_Catalog/templates/productData.phtml

    <?php echo __('Product name : ').$this->getProduct()->getName(); ?>

Put below code in your catalog_product_view.xml it may helps you.

<move element="page.main.title" destination="product.info.main" before="-"/>

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.