Post by oclcas » Thu Dec 22, 2016 3:32 am

I am working on a site where we have multiple suppliers, who each provide widgets with different subsets of options.

For instance, Vendor 1 had Colors A B and C available, while Vendor 2 has colors B E and F available.

In the backend we call the Options ("Vendor 1 Colors" and "Vendor 2 Colors") and assign them to products. This VQMOD allows you to set a Display Name separate from the Option Name, so that both of those options will be displayed on the product page as "Color".

As I'm only a beginner as far as VQMOD's go, I don't know what the proper method is for adding a column to Opencarts database. Therefore, you must MANUALLY add a column called 'display' to the 'option_description' table, set as a VARCHAR(128).

I would GREATLY appreciate any assistance in how to add this at the VQMOD level.

The code is on Github, and I published it under GPL 3.0. ... play-names

I would love to hear thoughts, feedback, or instruction on how to manipulate the database structure though VQMOD's.


New member


Wed Sep 14, 2016 11:22 pm

Post by OSWorX » Thu Dec 22, 2016 5:27 am

1. if that should be for OpenCart 2.x, make it as OCMod
2. adding/changing database (tables) can be done the same way as usual

For example, you are using the file
Add there now a new function (e.g. checkTable() ) wherein you add your code for database manupulation.

3. Use the xml very rare. For example you are adding some code for displaying new input fields
Instead af adding so many lines, simple move the creation of those line in the controller, where you can do like

Code: Select all

$data['my_new_field'] = $this->load->controller('ctaalog/myNewOption');
And 1 more line for the template where you do:

Code: Select all

<?php echo $my_new_field; ?>

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image

User avatar
Guru Member


Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by oclcas » Sat Dec 24, 2016 12:19 am

Thank you for your feedback. Have a couple questions/concerns.

1 - Seems that depending where I read, some people say VQMOD is the proper way to extend Opencart, and others say that OCMOD is the better method. Is there consensus in the community about which is the proper method, because it seems like VQMOD gets all the attention.

2 - Where is the checkTable function? I searched my Opencart installation for it and didn't find that string anywhere. I see the query function,

Is using raw SQL acceptable? I feel like:

"show columns from " . DB_PREFIX . "option_description like 'display'"

and if the result count is 0, follow that with:

"ALTER TABLE " . DB_PREFIX . "option_description
ADD `display` varchar(36) NOT NULL"

to add the column (if doesn't exist) would work, except then I worry that i'm only testing against MySQL rather than all the databases that Opencart supports.'

Looking at a couple of other Extensions, it appears that most developers simply assume that MySQL is the database that will be used (setting the engine to MyISAM during the process of creating a new table), which would probably break things if executed on a server running Postgres or MSSqL.

3. Last point is cosmetic only - this isn't touching the template. It's just supplying the display name in place of the option name to the template, if the user has set an alternate name for the option.

New member


Wed Sep 14, 2016 11:22 pm
Who is online

Users browsing this forum: No registered users and 3 guests