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: '<module_name>' 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:Alex Cheung/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 the template set to <module_name>: 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 the template(Advance->Developer in Magento admin panel), but I have read that it's dangerous :S

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

3 Answers 3

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

9
  • But simulator.phtml is my template file, it is not a Magento_Catalog file. Anyway it does not works
    – pgarcess
    Commented Mar 1, 2019 at 13:08
  • Magento_Catalog is just a place holder you need to use your module name like DigitalOrigin_Pmt::simulator.phtml
    – VDC
    Commented Mar 1, 2019 at 13:09
  • I tested this solution before but it continues failing
    – pgarcess
    Commented Mar 1, 2019 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
    Commented Mar 1, 2019 at 13:15
  • Template path: /view/frontend/templates/product/simulator.phtml
    – pgarcess
    Commented Mar 1, 2019 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>
8
  • 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
    Commented Mar 1, 2019 at 13:13
  • template="DigitalOrigin_Pmt::simulator.phtml" just change it Commented Mar 1, 2019 at 13:17
  • Using template="DigitalOrigin_Pmt::simulator.phtml" still fails. It's not the solution
    – pgarcess
    Commented Mar 4, 2019 at 7:47
  • Your template file location ? Commented Mar 4, 2019 at 7:49
  • Template path: /view/frontend/templates/product/simulator.phtml
    – pgarcess
    Commented Mar 4, 2019 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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.