2

We have a custom theme with some layout / template overrides

Now we have installed a 3rd party module, which is overriding one of layout files in our custom theme. So, only module's override is being loaded

I suppose, we can deal with this, by defining that concrete layout override in a custom module (instead of the custom theme approach), and then define the module dependencies to load both layout overrides

Or is there a way to do that without the need of declaring a new module?

UPDATE

About RishabhRkRai answer...

Let's say our custom theme is placed in folder app/design/frontend/Sinapsis/projectname

We had this layout override there:

app/design/frontend/Sinapsis/projectname/Magento_Multishipping/layout/multishipping_checkout_billing.xml

Now, we've installed a module which overrides that same layout file. The concrete module name is Df_Checkout, and problem is our layout override stopped working

I've tried, following the answer, moving our override to

app/design/frontend/Sinapsis/projectname/Df_Checkout/layout/multishipping_checkout_billing.xml

but only module's layout keeps loading

  • You can just create your module layout file inside theme and set your old layout changes to your new module layout file. – Rakesh Jesadiya Sep 1 '17 at 5:19
  • please note that if you changed your sequence you need to run bin/magento module:disable YOUR_MODULE, followed by bin/magento module:enable YOUR_MODULE to make sure Magento has updated the configuration load order (as seen in app/etc/config.php) – Kristof at Fooman Sep 5 '17 at 21:33
6
+50

In your custom theme, follow this to override the layout file

app/design/frontend/Theme_Vendor/Theme_Name/ThirdPrty_Vendor/Module_Name/layout/file_to_override.xml

After doing this, remove the static files and flush the cache

  1. rm -rf pub/static/*
  2. php bin/magento setup:static-content:deploy
  3. php bin/magento cache:flush

There is an alternate way, which may works for you. You just need to create an custom module and inside module.xml add the dependency like

    <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Modulename" setup_version="2.1.7">
        <sequence>
            <module name="ThirdParty_ModuleName"/>
        </sequence>
    </module>
</config>

Now you have to override the xml file as

app/code/Vendor/Module_Name/view/Scope/layout/file_to_override.xml

  • You should not remove pub/static or static-content to overriding xml files. You only need clean or flush cache for this task. For more details: magento.stackexchange.com/a/184927/35758 – Prince Patel Sep 2 '17 at 17:16
  • 1
    Mmm... so it is same concept as overriding Magento modules files, is it? I think this does not work for me. 3rd party module continues loading its layout – Raul Sanchez Sep 4 '17 at 13:58
  • @RaulSanchez I used this method to override 3rd party module and It's work for me. – Rishabh Rk Rai Sep 5 '17 at 6:10
  • I am going to update the question, so it is more clear – Raul Sanchez Sep 5 '17 at 6:59
  • Am I the only one who got this working with app/design/frontend/Theme_Vendor/Theme_Name/VendorName_ModuleName/layout/file_to_override.xml instead of app/design/frontend/Theme_Vendor/Theme_Name/VendorName/ModuleName/layout/file_to_override.xml. It should be VendorName_ModuleName instead of VendorName/ModuleName – Akash K. Jan 12 '18 at 13:36
0

Please note that magento has 2 ways to customize layout.

Extend layout http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-extend.html

Override layout http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/layout-override.html

Here are a few steps to make sure that your layout is extended correctly.

  1. move layout in your theme

app/design/frontend/Sinapsis/projectname/Df_Checkout/layout/multishipping_checkout_billing.xml

  1. Check the layout and make sure that block names match.

  2. Check the code in your Block. There are cases when the template was updated directly in the block code. In that way you need to extend the Block.

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.