4

I have been reading the forum but I can't find any solution to solve my case.

I have a custom module where I'm getting the error:

1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'simulator.phtml' in module: '' block's name: 'product.view.simulator'

My module works with Magento 2.2 but after upgrade to 2.3 it does not work. I use Mac & docker(Image:alexcheng/magento2:latest), no windows. I think the problem is in the symlink which is not getting the right path.

File: catalog_product_view.xml (I have tried with template set to :simulator.phtml but it doesn't work) I hace tried changing the module location:

vendor//magento-2x/.. or app/code/...

but it now works

<?xml version="1.0"?>
<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.addtocart">
          <block class="<vendor>\<module_name>\Block\Product\Simulator"
           name="product.view.simulator"
           as="product_simulator"
           template="simulator.phtml"/>
       </referenceBlock>
    </body>
</page>

Some ideas?

Thanks in advance.

Solution: The problem was solved enabling symlinks to template(Advance->Developer in magento admin panel), but I have read that it's dangerous :S

  • Are you sure you created the simulator.phtml in the right directory? I think you should post your full module directory/file tree – Maikel Koek Mar 1 at 12:59
  • Path is right, it reachs at the right destination – pgarcess Mar 4 at 11:39
0

I think you need to update the template attribute to correct one with full module path like below

template="Magento_Catalog::product/view/simulator.phtml"

Hope this will help you.

Thanks

  • But simulator.phtml is my template file, it is not a Magento_Catalog file. Anyway it does not works – pgarcess Mar 1 at 13:08
  • Magento_Catalog is just a place holder you need to use your module name like DigitalOrigin_Pmt::simulator.phtml – VDC Mar 1 at 13:09
  • I tested this solution before but it continues failing – pgarcess Mar 1 at 13:12
  • wath is the path of your simulator.phtml file like its under template directory or under sub directory please add path here – VDC Mar 1 at 13:15
  • Template path: /view/frontend/templates/product/simulator.phtml – pgarcess Mar 1 at 13:23
0

Template Path Given Like This

<?xml version="1.0"?>
<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.addtocart">
          <block class="DigitalOrigin\Pmt\Block\Product\Simulator"
           name="product.view.simulator"
           as="product_simulator"
           template="Vendor_ModuleName::simulator.phtml"/>
       </referenceBlock>
    </body>
</page>
  • 1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Vendor_ModuleName::simulator.phtml' in module: 'DigitalOrigin_Pmt' block's name: 'product.view.simulator' – pgarcess Mar 1 at 13:13
  • template="DigitalOrigin_Pmt::simulator.phtml" just change it – Rk Rathod Mar 1 at 13:17
  • Using template="DigitalOrigin_Pmt::simulator.phtml" still fails. It's not the solution – pgarcess Mar 4 at 7:47
  • Your template file location ? – Rk Rathod Mar 4 at 7:49
  • Template path: /view/frontend/templates/product/simulator.phtml – pgarcess Mar 4 at 8:42
0

Magento can not locate your template because you have the wrong path in your layout xml file.

template="Vendor_ModuleName::simulator.phtml"/>

If the path to your actual template file is: DigitalOrigin/Pmt/view/frontend/templates/product/simulator.phtml

then it should be like this:

<?xml version="1.0"?>
<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.addtocart">
          <block class="DigitalOrigin\Pmt\Block\Product\Simulator"
           name="product.view.simulator"
           as="product_simulator"
           template="Vendor_ModuleName::product/simulator.phtml"/>
       </referenceBlock>
    </body>
</page>

And please do change {Vendor_ModuleName} to your actual package name. Its just a placeholder above in the code snippet

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.