OOG Second Part – Excessive Code Maintenance

Day 2: The end of the road is nowhere near, but i am still strong in mind and body :). Opencart is a complete shopping cart system but misses many features that the merchants leads thus leading to the use of many extensions, VqMOD scripts and custom modifications of the code. All three methods are used VqMOD to modify the code without editing the source file directly, extensions when you need back-end configurations as a part of the added features and direct modification if you find a bug or other similar cases.

Now these approaches will always lead with a lot of extra code, that in some cases may not be necessary in the feature but is there, slowing down your system (how you ask?) by adding extra queries for example. We will separate this in three paragraphs so it is clearer and easier to understand.


-> Extensions if disabled they are not used in the front-end but that does not mean the controller is not called, in addition the settings of the controller are continuously read from the database, making this clear if you are not using an extension do NOT just leave it disabled, you should UNINSTALL it, this is the only way to make sure that this extension has no effect whatsoever in the performance. (I am pointing this out, because i used to do it a lot myself till a month ago).


-> Custom modifications are the hardest to track down, you have to manually check the code to avoid calling to categories twice for example (that was my case), in this case you should also be aware of templates that change the default  controllers and models, because i that case is the same like doing a ton of custom modifications to the core of Opencart, making it a nightmare to debug. For example in my case


is a function called in header.php that was also called by my custom menu file that i created. Failing to notice this issue for a long time i have been  lead to getting double data for nothing, and the solution was really simple, simply pass the data generated in the controller of header.php to the custom menu. What this shows us, is that we need to be really careful when doing the custom modifications and avoid them when possible.


-> VqMOD scripts read the files specified in the script and when the conditions are met the specified changes are applied to these files, by creating duplicate cached copies of the originals with the edits in them, also by simply removing a script from the xml folder with completely eliminate it. This approach eliminates all disadvantages that we specified in the custom modifications section,, also some of the disadvantages of the extensions and has no relevance with the database only the process of file read and write. BUT if you overuse VqMOD scripts you will exponentially increase TTFB (i am unable to get some numbers on this case for the moment), the solution is pretty simple do not use VqMOD for everything, manage it carefully with carefully crafted scripts that are used only when needed to and are as concise as possible.


PS. if you always keep in mind the sections above you will make sure that no slowdowns come from excessive code, and no routine maintenance of the code is needed to avoid speed problems.

guide intro  : Opencart Optimization Guide

First day     : Remove Category Counts

Third day    : i think it will  take some time (whole database needs to be reviewed)