سؤال

Is it recommended and necessary to use local.xml for layout updates instead the module layout.xml, does not create redundancy and overload in code ?

هل كانت مفيدة؟

المحلول 2

The benefits to use local.xml :

  1. Only one file to manage overrides and updates
  2. No need to have any other .xml file for your theme since it’s dependent on the xml files inside the base folder
  3. Every change to the local.xml file is evident so there is no need to search for changes inside xml files

The drawbacks:

None that I could think of, unless transparency and evident code changes aren’t your thing.

The use:

All you have to do is to create one inside your theme’s folder and write your xml. Since magento reads through the xml files it will first search for the changes inside your newly created local.xml and apply overrides and updates and then fall through the .xml files inside the base folder if that is the default xml folder set via the magento administration.

نصائح أخرى

I would advice against using local.xml.
Indeed the benefit of having all the changes in one place is attractive. But you will hate it when the project grows and you add more and more things in the same file.
Also it defeats the purpose of modularity. Imagine you have to put the newsletter form in various places in different pages. In one place for configurable products, somewhere else in the homepage and somewhere else in the order history page.
Then the next developer, 6 months later has to remove the core newsletter module and replace it with a third party system. If you use local.xml he will have to clean it up and then disable the core module. He might miss some things.
I know the scenario is not likely to happen but I think you get the idea.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top