0

I am trying to add custom attribute into product page, but for some reason its generating error even after running all imp commands.

<block class="Magento\Catalog\Block\Product\View\Description"
                   name="product.info.my.info" 
                   template="Magento_Catalog::product/view/attribute.phtml">
                    <arguments>
                        <argument name="at_call" xsi:type="string">GetMyInfo</argument>
                        <argument name="at_code" xsi:type="string">my_info</argument>
                        <argument name="at_label" xsi:type="string">none</argument>
                        <argument name="add_attribute" xsi:type="string">itemprop="my_info"</argument>
                    </arguments>
                </block>

Do i have to describe the GetMyInfo method some where ?

Here is error generating on product page

 1 exception(s):
 Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Magento\Catalog\Model\Product\Interceptor::GetMyInfo

 Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Magento\Catalog\Model\Product\Interceptor::GetMyInfo
 <pre>#1 include('/var/www/vhosts/...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
 #2 Magento\Framework\View\TemplateEngine\Php->render(&Magento\Catalog\Block\Product\View\Description#000000004c1cab8400000000466be1bb#, '/var/www/vhosts/...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
 #3 Magento\Framework\View\Element\Template->fetchView('/var/www/vhosts/...') called at [vendor/magento/framework/View/Element/Template.php:301]
 #4 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
 #5 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1103]
 #6 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:673]
 #7 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:564]
1

Try following code

<block class="Magento\Catalog\Block\Product\View\Description"
                   name="product.info.my.info" 
                   template="Magento_Catalog::product/view/attribute.phtml">
                    <arguments>
                        <argument name="at_call" xsi:type="string">getMyInfo</argument>
                        <argument name="at_code" xsi:type="string">my_info</argument>
                        <argument name="at_label" xsi:type="string">none</argument>
                        <argument name="add_attribute" xsi:type="string">itemprop="my_info"</argument>
                    </arguments>
                </block>

Test first in the developer mode.

7
  • what is difference ? – Mr.Devops Oct 1 '20 at 11:11
  • issue is even i have now removed the code still the exception error exists even after clear cache everything 1 exception(s): Exception #0 (Magento\Framework\Exception\LocalizedException): – Mr.Devops Oct 1 '20 at 11:14
  • 1
    Difference is getMyInfo I have changed GetMyInfo to getMyInfo. – Anshu Mishra Oct 1 '20 at 11:17
  • yes but this error not going now after fixing code Exception #0 (Magento\Framework\Exception\LocalizedException): Invalid method Magento\Catalog\Model\Product\Interceptor::GetMyInfo I did fixed with small get Still it showing error, i did runn compiled command too, does it saved GetMyInfo somewhere from where i have to remove it now ? – Mr.Devops Oct 1 '20 at 11:22

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.