Skip to content

Instantly share code, notes, and snippets.

@matrunchyk
Created October 15, 2015 09:50
Show Gist options
  • Save matrunchyk/8951e361dbad191e8eaf to your computer and use it in GitHub Desktop.
Save matrunchyk/8951e361dbad191e8eaf to your computer and use it in GitHub Desktop.
Adds a support for custom OpenCart models
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Custom Model Support</name>
<code>custom_model_support</code>
<version>1.0</version>
<author>Sergii Matrunchyk</author>
<link>mailto: [email protected]</link>
<file path="system/engine/loader.php">
<operation>
<search trim="true"><![CDATA[
$model = str_replace('../', '', (string)$model);
]]></search>
<add position="after"><![CDATA[
/* <custom_model_support> */
$mod_file = DIR_MODIFICATION . ((defined('HTTP_CATALOG')) ? 'admin' : 'catalog') . '/model/' . $model . '.php';
/* </custom_model_support> */]]></add>
</operation>
<operation>
<search trim="true"><![CDATA[
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
]]></search>
<add position="after"><![CDATA[
/* <custom_model_support> */
} elseif (file_exists($mod_file)) {
include_once($mod_file);
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
/* </custom_model_support> */]]></add>
</operation>
</file>
</modification>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment