Having two or more ways to do something can be useful, but it isn't always the case. When it comes to OpenCart, there are four ways to modify its core functionality: vQmod, OCMOD, Override Engine and Event Handlers. Let’s take a quick look at vQmod and OCMOD and the differences between these two.
What is vQmod and How Does it Work?
vQmod (or Virtual Quick Mod) is the most widely used of the four override systems available today. If you're using MultiMerch, you probably know that we only use vQmod for OpenCart core modifications.
It's actually quite simple – search/replace code modifications are specified as separate xml files (see the syntax examples here). vQmod then parses the xml files during page load and applies the modifications to the target files. The result is saved as a temporary modified file, which is then loaded by OpenCart instead of the original one.
This means vQmod doesn’t make any direct changes to the actual OpenCart core files. Because of this, the modifications are non-destructive and the original files are left intact – you can always undo the changes by simply removing the xml file.
vQmod lets you apply multiple modifications to same files, making it possible to install multiple vQmod-powered extensions (usually) without conflicts. The system also has a variety of options for finding/replacing code, error handling, positions, indexing and more. If an error occurs, OpenCart will simply fall back to the original source file.
The drawback is that vQmod isn't part of OpenCart – it needs to be installed separately. If you're creating your own vQmod-powered extensions, you'll need to make sure your clients have vQmod installed on their servers. If it's not present, the extension will not work correctly. (The good thing is – the installation process is really simple: upload, run the installer, done)
Finally, even though vQmod was designed to use it with OpenCart, it can also be used separately – there is a standalone version of vQmod available for download that can be integrated into any custom project unrelated to OpenCart.
Is OCMOD a Better Alternative?
If vQmod is so awesome, why would you need something else? Well, the idea was to have something simpler built into OpenCart and available by default. Or, as Daniel Kerr, the main guy behind OpenCart, put it: "The problem also is vQmod, I just don't like how there are a lot of unnecessary features."
In fact, OCMOD is basically a stripped down version of vQmod system built into OpenCart. It works in a similar way – modifications are stored in xml files and uploaded to the store, then parsed and applied to OpenCart core code. Unlike vQmod, OpenCart has a built-in OCMOD modification uploader and manager. In addition to this, OCMOD allows you to specify extra SQL and PHP code to be executed during modification installation in separate install.php and install.sql files.
There are a few drawbacks compared to the original vQmod, though. This includes a few missing advanced search/replacement modifiers such as top, bottom, iafter and ibefore, as well as partial line matching and a few other things. In addition to this, OpenCart's modification cache needs to be refreshed every time there are changes to OCMOD files, which may slow down development, and OCMOD log files aren't as informative as vQmod's.
Because of these differences and the lack of a clear benefit, OCMOD hasn't received wider adoption (with some of the community calling it a “poor man’s vQmod”) and vQmod is still used by many OpenCart developers who are reluctant to spend time and effort converting their mods. (If you feel like converting, however, see a great vQmod to OCMOD conversion guide by an OpenCart developer rph here).
Both vQmod and OCMOD are meant to be used for the same purpose and both have their pros and cons (feel free to check this developer discussion thread on OpenCart forums). The choice is yours, though. We at MultiMerch still use vQmod – mostly because there are quite a bit of modifications in MultiMerch Marketplace. If you're starting something from scratch, you may as well try OCMOD first since it's part of OpenCart. You can always switch later!
+ mature, stable and robust system – original version released in 2010
+ clear documentation
+ simple modification syntax and deployment
- not part of OpenCart core – needs to be installed separately
+ part of OpenCart core – no additional installation needed
+ modification installer integrated into OpenCart
+ "execute during installation" scripts
- a few features missing compared to vQmod
- relatively new system with no clear development roadmap