How core customizations work?

The Opencart modification system is a way of adding corrections and modifications to the core without modifying the core of Opencart.

Where can it be applied?

It can be applied almost everywhere:

/system/startup.php (excerpt)

...
// Engine
require_once(modification(DIR_SYSTEM . 'engine/action.php'));
require_once(modification(DIR_SYSTEM . 'engine/controller.php'));
require_once(modification(DIR_SYSTEM . 'engine/event.php'));
require_once(modification(DIR_SYSTEM . 'engine/front.php'));
require_once(modification(DIR_SYSTEM . 'engine/loader.php'));
require_once(modification(DIR_SYSTEM . 'engine/model.php'));
require_once(modification(DIR_SYSTEM . 'engine/registry.php'));
require_once(modification(DIR_SYSTEM . 'engine/proxy.php'));

// Helper
require_once(DIR_SYSTEM . 'helper/general.php');
require_once(DIR_SYSTEM . 'helper/utf8.php');
require_once(DIR_SYSTEM . 'helper/json.php');
...

Remember it is used for making modifications on the core, not to control Opencart the way you like it.

How it is done

You can load modifications by creating an XML file that you name something like: 'something.ocmod.xml'. The name is not so important, for once it is uploaded and installed, it is managed by Opencart. The name is important once you want to publish the modification in the Opencart Marketplace.

Sample of a modification:

<?xml version="1.0" encoding="utf-8"?>
<modification>
    <code>AddComposerSupport</code>
    <name>Add Composer Support</name>
    <version>1.0</version>
    <author>J.J. van de Merwe</author>
    <link>http://www.enovision.nl</link>
    <file path="system/startup.php">
        <operation>
            <search position="after">
                <![CDATA[
spl_autoload_extensions('.php');
                ]]>
            </search>
            <add position="insert">
                <![CDATA[
require DIR_SYSTEM . '../vendor/autoload.php';
                ]]>
            </add>
        </operation>
    </file>  
</modification>

More information

Read this article: link

Last update: August 27th at 7:40am