How to create vQmod file


What is vQmod and why you need it you can read here.

For create vQmod file you need any simple text editor (better with the code highlighter). Create a file with “xml” extension, for example a2bizz_vqmod.xml. Here is a listing of this file:

<?xml version="1.0" encoding="UTF-8"?>
  <!-- Modification id -->
  <id>My first fix</id>
  <!-- Modification version -->
  <!-- vQmod version for this modification -->
  <!-- The author of the modification -->
  <author><a href=""></a></author>
    Leave some comment here
  <!-- File to change. Such files can be several in one xml file -->
  <file name="admin/model/catalog/product.php">
    <!-- Operation for one change. Such operations can be several for this file -->
      <!-- Exact place where you need to add your change. You can set position position for it (in our case "after") and the code between <![CDATA[...]]> It means that "after" this code you will add some your code. If you want to add your code before you need to set "before" position. You can also "replace" some code with your code. Important! The code to change must to be exactly like in the file. One space or tab more or less between words and vQmod will find nothing. -->
      <search position="after"><![CDATA[$product_id = $this->db->getLastId();]]></search>
      <!-- Here we write our code what we want to add after, before, or instead of the existing code -->

As you can see above xml, it starts with the standard <?xml> tag declaration followed by a <modification>tag. Other tags include <version>,<id> , and <author>. You should not change <vqmver> as it indicates the vQmod version.

Work starts with the <file> tag. The name attribute indicates the file name that will be patched. It could be that you need multiple modifications to the same file. So that’s where the <operation> tag comes into play. Each modification will be wrapped by the <operation> tag. The info attribute allows you to add some useful message.

In this particular example, the <search> tag is used for the replace operation. You can use the position attribute to tell vQmod which operation will be performed. The content which is enclosed inside the <search> tag will be replaced with the content which is enclosed within the <add> tag.

As you may have noticed, the content for search and replace is enclosed within a CDATA tag, which means that the content won’t be interpreted as a markup but as character data.

Other options available for the position attribute:

  • before is used to insert the content before the search string.
  • after is used to insert the content after the search string.
  • top is used to insert the data at the top of the file. In this case, there’s no need for the <search> tag. Even if you’ve used it, it’ll be ignored.
  • bottom is used to insert the data at the bottom of the file. In this case, there’s no need for the <search> tag. Even if you’ve used it, it’ll be ignored.
  • In the case of ibefore, the data will be appended before the search data in the same line.
  • In the case of iafter, the data will be appended after the search data in the same line.

There are also a couple of optional attributes available for the <search> tag. Let’s have a quick look at these.

  • offset is an attribute designed to work in conjunction with the position attribute. So, for example, if position is set to before and offset is set to 3, it means that the content will be inserted before the three lines of the searched data.
  • index: Sometimes you want to replace only couple of instances of a particular string, not all the instances of that string in the search data. Say, for example, there are five instances of the $abc variable in your search data, but you only want to replace the first two instances of $abc with $def. In this case you need to specify index to 1,2.
  • The regex attribute is useful if you want to perform a regular expression based search for your operations. In that case, you’ll need to set regex to TRUE.


  • Download and extract the OpenCart-specific vQmod library.
  • Upload the vqmod directory to the root of your OpenCart installation.
  • Please make sure the vqcache directory that is under the vqmod directory is writable by the web server.
  • Visit and you should be presented with a success message. If that’s not the case, it’s likely a permissions issue.