Post by rph » Wed Oct 08, 2014 8:50 am

With OpenCart 2.0 finally here many developers will begin converting their vQmod scripts over to OCMod. The syntax of OCMods is extremely similar up to the point where you actually have to use it. At that point the differences can become a frustration.

Informational Tags

The tags holding mod information are <name>, <author>, <version>, and <link>. All tags are optional.

<name> - The name of the OCMod (<id> in vQmod).
<author> - OCMod developer.
<code> - A unique string OpenCart will use to identify the script internally. Required starting in 2.0.1.0.
<version> - OCMod version.
<link> - URL in the form of http://example.com. If http:// is omitted the link will be broken.

Key OCMod Differences

Position attributes (replace, before, after) have been moved from <search> to <add>.

Code: Select all

<add position="replace"><![CDATA[//]]></add>
The file name attribute is now path.

Code: Select all

<file path="catalog/controller/product/product.php">
Wildcard paths are specified using glob brace.

Code: Select all

<file path="system/{engine,library}/{action,loader,config,language}*.php">
NOTE: Wildcard paths were silently broken in OpenCart 2.0.2.0. The new method is coma separated full paths:

Code: Select all

<file path="system/engine/action.php,system/engine/loader.php,system/library/config.php,system/library/language.php">
NO whitespace is allowed in the path tag.

Regex will always perform a replace operation. Operations "before" and "after" are not available.

Indexing begins at 0 instead of 1.

Development Mode

Uploading ocMod scripts may be bypassed by placing them in the system directory (/system). The modification system will directly load and apply them when the cache is manually refreshed through Extensions -> Modifications in Admin.

Zip ocMod Distributable

ocMods may be distributed as zip files that are directly installable from OpenCart's Extension Installer.
  • The zip file name must end in .ocmod.zip.
  • The ocMod script must be located in the root of the zip file.
  • The ocMod script must be named install.xml.
  • The zip file must contain an /upload directory in the root, even if it's empty.
  • The zip file may contain additional files unrelated to the mod such as documentation.
Please note this is only a small element of what a zip extension distributable can do.

Unavailable Features As Of OpenCart 2.0
  • <file> error attributes (skip, log, abort).
  • <operation> error attributes (skip, log, abort).
  • Operation <ignoreif>.
  • Position (search/add) attributes top, bottom, ibefore, and iafter.
OCMod Bugs

OpenCart 2.0
  • Regex searches are not trimmed so leading/trailing whitespace in the CDATA tag can lead to failure. [FIXED OpenCart 2.0.3.0]
  • Multiple matches to a <search> will result in unintended side effects as OCMods string position index will be invalidated! [FIXED]
  • Despite information on the OpenCart wiki, the "index" attribute is not available. [FIXED]
  • The "offset" attribute is buggy and does not work as expected. [STATUS UNKNOWN]
Last edited by rph on Tue Jul 14, 2015 5:09 am, edited 16 times in total.

rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by rph » Wed Oct 08, 2014 8:55 am

Changes In OpenCart 2.0

Controller properties are out. Children and views are not directly loaded in the extended controller.

Code: Select all

$data['product_id'] = $product_id;

$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');

$this->response->setOutput($this->load->view('template/product/product.tpl', $data));
The ?> closing tag has been removed from pure PHP files so it can no longer be used to hook in code in places like language files.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by rph » Sun Oct 12, 2014 3:10 am

I've updated the first post with several OCMod bugs and documentation issues. I would recommend not converting vQmods until they're addressed.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by kombi » Sat Apr 11, 2015 11:16 am

where does all the xml live in opencart with this installer. Vqmod mod everything lived in xml folder. so with OCMOD where do you find the files if a conflict happens?

New member

Posts

Joined
Thu Sep 06, 2012 5:03 am

Post by RuslanBrest » Sat Apr 11, 2015 4:50 pm

OcMod XML stored in database `oc_modification` table. No feature exist to export them to files, ready to use out-of-the-box. To find conflicts you need to analyze ocmod.log and save XML to files manually (or write an extension for this).

If you are finding and resolving conflicts, now you should copy-paste all enabled Modifications to the XML files and put them to `./system/` folder with `extension-name-or-any-other-text.ocmod.xml` filenames template (ocmod.xml extension is a must have). Then disable exported extensions in "Extensions / Modifications". Edit XML files, press Refresh button in Modifications, look result and ocmod.log.

After debugging finished - move them back into Opencart (upload via Extension installer, remove `.ocmod.xml` from `system` folder, Refresh in Modifications).

http://www.labtodo.com/category/opencart


New member

Posts

Joined
Sat Nov 12, 2011 3:19 pm


Post by kombi » Sat Apr 11, 2015 5:22 pm

Thanks for all the info. So let say a conflict is found and you have no access to the admin gui. You go in and delete the entry in the database that causing the issue/conflict. How do you clear the cache so the pages get regenerated.

New member

Posts

Joined
Thu Sep 06, 2012 5:03 am

Post by OSWorX » Sat Apr 11, 2015 6:00 pm

Important update: with OC 2.0.2.0 the wildcard is removed!
Instead of having

Code: Select all

<file path="system/{engine,library}/{action,loader,config,language}*.php">
from now on the full path has to be written.

How boring!

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member
Online

Posts

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

Post by kombi » Sun Apr 12, 2015 2:14 am

good to know... That is a bummer as well

New member

Posts

Joined
Thu Sep 06, 2012 5:03 am

Post by rph » Sun Apr 12, 2015 2:17 am

Thanks for reminding me of this thread OSWorX. I've updated the info.

In all honesty I've started and stopped converting my own mods over to OpenCart 2.0 a dozen times over. It's become very difficult to justify spending time on. I don't see the business model in having a modification system that's laborious, poorly documented, and unstable.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by OSWorX » Sun Apr 12, 2015 4:29 am

rph wrote:Thanks for reminding me of this thread OSWorX. I've updated the info.

In all honesty I've started and stopped converting my own mods over to OpenCart 2.0 a dozen times over. It's become very difficult to justify spending time on. I don't see the business model in having a modification system that's laborious, poorly documented, and unstable.
No problem ;D
And this is one of 999 reasons I am not converting any of my extensions over to OCMod.
Either the customer use VQmod - or let it.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member
Online

Posts

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

Post by RuslanBrest » Sun Apr 12, 2015 5:01 pm

kombi wrote:So let say a conflict is found and you have no access to the admin gui. You go in and delete the entry in the database that causing the issue/conflict. How do you clear the cache so the pages get regenerated.
Don't even know why do you need to discuss this strange case, but if you have access to FTP, then you have full access. You can directly replace `system/modification/*` files.

But if you need to press "Refresh" button, you can install 2nd "admin" folder, configure it properly and duplicate admin user or temporary change password hash to the hash of known password.

http://www.labtodo.com/category/opencart


New member

Posts

Joined
Sat Nov 12, 2011 3:19 pm


Post by RuslanBrest » Sun Apr 12, 2015 5:12 pm

Yet another problem of ocmod:

* no sort order of ocmods => no ability to guarantee that conflicts resolved today will not occurs tomorrow. This can be quickly fixed by adding sorting by `date_added` field, but more preferable way is adding sort_order column;

* update ocmod modifications not available and can be done only via removing it. This changes both its place in database (can rearrange positions of conflicting modifications) and the date_added too.

http://www.labtodo.com/category/opencart


New member

Posts

Joined
Sat Nov 12, 2011 3:19 pm


Post by JNeuhoff » Mon Apr 13, 2015 12:08 am

You shouldn't rely on any given sort orders for your OCmods nor for your VQmods. 3rd party VQmods/OCmods are often not aware of each other. Each VQmod/OCmod should be robust enough so not to rely on other VQmods/OCmods in any particular order.

Having said that all:

I going to use the Override Engine (factory design pattern and extended classes) and/or Events (mediator design pattern) for my own websites, no need for cumbersome OCmods :)

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by kombi » Mon Apr 13, 2015 12:45 am

My 2 cents... why reinvent the wheel if it was working well and folks liked it, developed it, and supported it. Why not just work with Q to integrate VQMOD into OC and add a few features that may be needed. Seems silly to fight each other when at the end of the day we all want the same thing. Oh well back to the topic.
Last edited by kombi on Mon Apr 13, 2015 3:45 am, edited 1 time in total.

New member

Posts

Joined
Thu Sep 06, 2012 5:03 am

Post by RuslanBrest » Mon Apr 13, 2015 3:22 am

kombi wrote:why reinvent the wheel if it was working well
Good question. Why reinvent the wheel with vqmod/ocmod in 2011 when OOP/OOD[1] was invented and wide used starting approx. in ~1990-1995? Why not use HMVC[2] for modules and some sort of Composer/Packagist as extensions distribution model?

vQmod doesn't have any serious pros in architecture over OCmod - it mostly absolutely the same. Both of them have the same drawbacks and the same principles.

[1]: http://en.wikipedia.org/wiki/Object-ori ... rogramming
[2]: http://en.wikipedia.org/wiki/Hierarchic ... controller

http://www.labtodo.com/category/opencart


New member

Posts

Joined
Sat Nov 12, 2011 3:19 pm


Post by JNeuhoff » Mon Apr 13, 2015 3:55 am

@RuslanBrest:

Traditional OOP doesn't solve the following problem:

You have a number of 3rd party extensions which need to change the same method of a controller or model class, or which need to change the same viewer template. VQMod/OCMod, despite all their weaknesses, attempt to solve this issue.

A better approach (IMHO :) ) is the Override Engine which uses a class factory, OOP techniques, and (this is new) automatic chained class extensions.

Or OpenCart's new Event triggers can help to a degree, too (it uses the mediator design pattern for this), however, at the moment only a limited number of event triggers are allowed, important ones such as 'pre.action', 'post.action', 'pre.load.view' or 'post.load.view' are missing.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by kombi » Mon Apr 13, 2015 4:15 am

Touché -- Thanks for the info!

New member

Posts

Joined
Thu Sep 06, 2012 5:03 am

Post by RuslanBrest » Mon Apr 13, 2015 12:19 pm

@JNeuhoff: Of course, I agree. I had meant any design pattern (observer, mediator, etc) which will enable module files to be encapsulated, objects to be inherited, extended or overwritten. Events in OC2 is good move. I also hope OE will be more accepted by core developers and community authors.

http://www.labtodo.com/category/opencart


New member

Posts

Joined
Sat Nov 12, 2011 3:19 pm


Post by OSWorX » Mon Apr 13, 2015 2:52 pm

kombi wrote:My 2 cents... why reinvent the wheel if it was working well and folks liked it, developed it, and supported it. Why not just work with Q to integrate VQMOD into OC and add a few features that may be needed. Seems silly to fight each other when at the end of the day we all want the same thing. Oh well back to the topic.
1. VQMod is a third party development
2. OCMod is made by Daniel Kerr (the owner and master of OpenCart)

We have had many internal discussions about this and how OCMod could be.
Daniel declined the most, and made his own quirks.

Simple, but that how it is is and that is why OCMod is as it is today.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member
Online

Posts

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

Post by JNeuhoff » Wed Apr 15, 2015 8:34 pm

We have had a VQmod-XML support since the very beginnings of OpenCart 2.0.0.0, with the aim to have it seemlessly integrated with OpenCart and to co-exist with OCmod. It supports different ways to upload modifications to an OpenCart server:
  • Use the OpenCart admin backend at Extensions > Extension Installer to upload individual XML files to the OpenCart database. The XML file names must end with '.vqmod.xml' or '.ocmod.xml' depending on the type of XML used.
  • Use the OpenCart admin backend at Extensions > Extension Installer to upload zipped OpenCart extensions which include an XML file (the latter ends up in the OpenCart database). The name of the ZIP-file to be uploaded must end with '.vqmod.zip' or '.ocmod.zip'. The folders and files structure of the ZIP-file should look like this:
    • upload/*
    • install.xml (can contain VQmod or OCmod XML)
    • install.php (optional)
    • install.sql (optional)
  • Use FTP to upload XML files directly to OpenCart's system folder. The XML file names must end with '.vqmod.xml' or '.ocmod.xml' depending on the type of XML used.
  • Use FTP to upload VQmod XML files directly to OpenCart's vqmod/xml folder. The file names must end with '.xml'.
    • Note: This option is useful for the many OpenCart extensions that come as ZIP-files, and which include an upload folder with amongst other a vqmod/xml sub-folder. The content of the ZIP-archive is extracted on a local computer and then everything from the extracted upload folder, including an embedded vqmod/xml folder, is uploaded to OpenCart's main folder.
After the OpenCart modifications are uploaded, it is important to go into the OpenCart admin backend at
Extensions > Modifications and then click on the 'Refresh' button. This will re-create a cache for all modified OpenCart core files in the system/modification folder.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 31 guests