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
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"/>
-
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 useMagento_Catalog, right? It doesnt works.Konrad Siamro– Konrad Siamro2017年08月22日 05:52:40 +00:00Commented Aug 22, 2017 at 5:52 -
Magento_Catalogyes it is correct. Can you please share how you are using in layout and pls check log alsoPankaj Pareek– Pankaj Pareek2017年08月22日 06:53:31 +00:00Commented Aug 22, 2017 at 6:53 -
I just edit my postKonrad Siamro– Konrad Siamro2017年08月22日 07:07:32 +00:00Commented Aug 22, 2017 at 7:07
-
frameworkis the only theme in TemplateMonster package ? Also in your updated layout code - you have not change pathMagento_Catalog::this one is missingPankaj Pareek– Pankaj Pareek2017年08月22日 07:11:57 +00:00Commented Aug 22, 2017 at 7:11 -
1Yes, I had to add
Magento_Catalog::to TemplateMonster layout also. Thanks!Konrad Siamro– Konrad Siamro2017年08月23日 06:41:25 +00:00Commented Aug 23, 2017 at 6:41