Element 'body' : Character content other than whitespace is not allowed because the content is 'element-only' after Magento 2.3.4 upgrade

magento.stackexchange https://magento.stackexchange.com/questions/305714

Domanda

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 !!.

È stato utile?

Soluzione

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>

Altri suggerimenti

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> 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top