Domanda

I'm trying to override the vendor/magento/module-customer/view/frontend/templates/address/edit.phtml with a custom one but I can't get it to work.

The stock address/edit.pthml gets loaded in vendor/magento/module-customer/view/frontend/layout/customer_address_form.xml.

My custom customer_address_form.xml located at /home/roy/www/dremelonline/web/vendor/activeants/magento2-checkoutchanges/src/view/frontend/layout/customer_address_form.xml looks like this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceBlock name="customer_address_edit">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Roy_CheckoutChanges::edit.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

My custom edit.phtml file is located in vendor/roy/magento2-checkoutchanges/src/view/frontend/templates/edit.phtml

My module.xml looks as following:

<module name="Roy_CheckoutChanges" setup_version="1.0.0">
    <sequence>
        <module name="Magento_Checkout"/>
        <module name="Magento_Customer"/>
        <module name="Roy_Base"/>
    </sequence>
</module>

I've flushed my cache and I have ran the upgrade command.

According to reading other posts about related problems, this code should work, but as you already know, it doesn't :p

Thanks!

È stato utile?

Soluzione

Add this code into your custom module etc/module.xml

<sequence>
       <module name="Magento_Checkout"/>
</sequence>

customer_address_form.xml :

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
    <referenceContainer name="content">
          <block name="customer_address_edit">
               <action method="setTemplate">
                    <argument name="template" xsi:type="string">Roy_CheckoutChanges::edit.phtml</argument>
               </action>
           </block>
       </referenceContainer>
   </body>

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top