2

I would like to Override Magento\Catalog\Block\Product\View\Description, but I've got:

[2017-08-21 16:03:47] main.CRITICAL: Invalid template file: 'product/view/attribute.phtml' in module: 'Test_Catalog' block's name: 'product.info.sku' [] []

and detail.phtml is missing on frontend on product page.

I have done:

etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Catalog\Block\Product\View\Description" type="Test\Catalog\Block\Product\View\Description" />
</config>

in Test/Catalog/Block/Product/View/Description:

<?php
namespace Test\Catalog\Block\Product\View;

class Description extends \Magento\Catalog\Block\Product\View\Description
{

    /**
     * @return array|bool
     */
    public function getConfigProductChild()
    {
         //function returns child products in array
    }
}

I'm using TemplateMonster Theme so I would like to use getConfigProductChild function in :

project/app/design/frontend/TemplateMonster/framework/Magento_Catalog/templates/product/view/details.phtml

I read that I should type referenceBlock with template and Mine block but it doest works (or I did something wrong?). Tried something like that:

in view/frontend/layout/default.xml of mine module:

 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.info.details" class="Test\Catalog\Block\Product\View\Description" template="Magento_Catalog::product/view/details.phtml" after="product.info.media"/>
    </body>
</page>

Instead of Magento_Catalog I tried also use TemplateMonser etc.

Do You know what's the problem?

EDIT:

path for missing pthml:

project/app/design/frontend/TemplateMonster/framework/Magento_Catalog/templates/product/view/details.phtml

layout using details.phtml:
project/app/design/frontend/TemplateMonster/framework/Magento_Catalog/layout/catalog_product_view.xml

<body>
        <referenceContainer name="content">
            <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.details" template="product/view/details.phtml" after="product.info.media">
                <block class="Magento\Catalog\Block\Product\View\Description" name="product.info.description" template="product/view/attribute.phtml" group="detailed_info">
                    <arguments>
                        <argument name="at_call" xsi:type="string">getDescription</argument>
                        <argument name="at_code" xsi:type="string">description</argument>
                        <argument name="css_class" xsi:type="string">description</argument>
                        <argument name="at_label" xsi:type="string">none</argument>
                        <argument name="title" translate="true" xsi:type="string">Details</argument>
                    </arguments>
                </block>
                <block class="Magento\Catalog\Block\Product\View\Attributes" name="product.attributes" as="additional" template="product/view/attributes.phtml" group="detailed_info">
                    <arguments>
                        <argument translate="true" name="title" xsi:type="string">More Information</argument>
                    </arguments>
                </block>
            </block>
        </referenceBlock>
</body>

1 Answer 1

2

In your current theme, you need to make change in catalog_product_view.xml file as below.

If your new template still exist in Magento_Catalog module then update code like below:

<block class="Test\Catalog\Block\Product\View\Description" name="product.info.details" template="Magento_Catalog::product/view/details.phtml" after="product.info.media" remove ="true"/>

If your new template still exist in Test_Catalog module then update code like below:

<block class="Test\Catalog\Block\Product\View\Description" name="product.info.details" template="Test_Catalog::product/view/details.phtml" after="product.info.media" remove ="true"/>
5
  • Thanks for answer and your time! template exist in: /app/design/frontend/TemplateMonster/framework/Magento_Catalog/templates/product/view/details.phtml. In this case I should use Magento_Catalog, right? It doesnt works. Commented Aug 22, 2017 at 5:52
  • Magento_Catalog yes it is correct. Can you please share how you are using in layout and pls check log also Commented Aug 22, 2017 at 6:53
  • I just edit my post Commented Aug 22, 2017 at 7:07
  • framework is the only theme in TemplateMonster package ? Also in your updated layout code - you have not change path Magento_Catal‌​og:: this one is missing Commented Aug 22, 2017 at 7:11
  • 1
    Yes, I had to add Magento_Catal‌​og:: to TemplateMonster layout also. Thanks! Commented Aug 23, 2017 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.