What is it that prevents supporting loading of admin models from catalog and vice versa?
Are there any technical reasons for this?
Here is a previous related discussion about this topic.
http://forum.opencart.com/viewtopic.php?f=20&t=47856
My understanding is that in order to support this we just need the following updates
- Define two new variables in config
-- DIR_ADMIN
-- DIR_CATALOG
Currently we only have 'DIR_APPLICATION' which refers to the current context be it catalog or admin.
update the model function in system/engine/loader.php and add an optional parameter
Code: Select all
public function model($model, $base='APPLICATION') {
switch(strtoupper($base))
{
case 'ADMIN':
$file = DIR_ADMIN . 'model/' . $model . '.php';
break;
case 'CATALOG':
$file = DIR_CATALOG . 'model/' . $model . '.php';
break;
default:
$file = DIR_APPLICATION . 'model/' . $model . '.php';
}
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
if (file_exists($file)) {
include_once($file);
$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));
} else {
trigger_error('Error: Could not load model ' . $file . '!');
exit();
}
}