0

After Magento 2.3.4 upgrade, Error is "Element 'body' : Character content other than whitespace is not allowed because the content is 'element-only'" on Product details page.

Actually after removing below code from app/code/Vendor/Module/view/layout/catalog_product_view.xml file it's resolved.

<?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">
   <body>
      <!-- <referenceBlock name="product.info.addtocart">
           <action method="setTemplate">
               <argument name="template" xsi:type="string">Vendor_Module::catalog/product/view/addtocart.phtml</argument>
           </action>
       </referenceBlock>
       <referenceBlock name="product.info.addtocart.additional">
           <action method="setTemplate">
               <argument name="template" xsi:type="string">Vendor_Module::catalog/product/view/addtocart.phtml</argument>
           </action>
       </referenceBlock>   ---->
   </body>
</page>

Error screen: enter image description here

Now i am looking for rectification of this code because it was working fine in Magento 2.2.4 version but not in Magento 2.3.4

If anyone having an idea please guide me. Thanks in Advance !!.

1

Below code worked perfectly fine.

  <?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">
      <body>
          <referenceBlock name="product.info.addtocart" template="Vendor_Module::catalog/product/view/addtocart.phtml"/>
          <referenceBlock name="product.info.addtocart.additional" template="Vendor_Module::catalog/product/view/addtocart.phtml"/>
      </body>
  </page>
0

I think setTemplate is not used in Magento 2.3.4 you double check with that.

Try with below code

<referenceBlock name="product.info.addtocart">
    <arguments>
        <argument name="template" xsi:type="string">Vendor_Module::catalog/product/view/addtocart.phtml</argument>
    </arguments>
</referenceBlock>
<referenceBlock name="product.info.addtocart.additional">
    <arguments>
        <argument name="template" xsi:type="string">Vendor_Module::catalog/product/view/addtocart.phtml</argument>
    </arguments>
</referenceBlock> 
3
  • Hi @aravind, i tried this solutions before only actually error resolved but template was not loading. – Hitesh Balpande Feb 28 '20 at 15:11
  • As per Magento 2.3.4 std. action method is deprecated so that's why error was coming. – Hitesh Balpande Feb 28 '20 at 15:12
  • sorry action node – Hitesh Balpande Feb 28 '20 at 15:24

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.