1

I am overriding product page for customization, but my template is not setting.

[Namespace]/[Modulename]/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <action method="setTemplate">
                <argument name="template" translate="true" xsi:type="string">[Namespace]_[Modulename]::product/list.phtml</argument>
            </action>
        </referenceContainer>
    </body>
</page>

[Namespace]/[Modulename]/view/frontend/templates/product/list.phtml

<h1>Product view Page</h1>

...
//core module code
...

and I run the flush, clean command also.

Any help?

  • Add block instead of arguments – Ronak Chauhan Jan 9 '17 at 6:04
  • @RonakChauhan, I want to add just one line of code, remaining code will sampe. – Manoj Kumar Jan 9 '17 at 6:10
  • @ Manoj Kumar Do you want to add extra info or change existing elements. – Krishna ijjada Jan 9 '17 at 6:18
  • @RonakChauhan, I can add extra info successfully in the page last, but I want ot add extra info beside the SKU. – Manoj Kumar Jan 9 '17 at 6:19
  • You can override the phtml file not a single line – Ronak Chauhan Jan 9 '17 at 6:51
1

If you want to add extra information beside SKU, overriding (setTemplate) entire template may not be a good idea, you can add something like as i added some example.

<?xml version="1.0"?>
<!--
/**
 * Solwin Infotech
 * Solwin Product Print Page
 * 
 * @category   Solwin
 * @package    Solwin_Printpage
 * @copyright  Copyright © 2006-2016 Solwin (https://www.solwininfotech.com)
 * @license    https://www.solwininfotech.com/magento-extension-license/
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="product.info.main">
            <block class="[Namespace]\[Modulename]\Block\Product\Extrainfo" name="custom.extrainfo"  after="product.info.sku"  template="[Namespace]_[Modulename]::test.phtml"/>
        </referenceContainer>
    </body>
</page>

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.