Michael L Watson
Michael L Watson

Reputation: 980

Opencart where are extension status and position set?

Quick question about open cart, where are extension status and position set? I can see in the code

$postion = $this->config->get($extension . '_position');

and also

'status'      => $this->config->get($extension . '_status') 

However I can't see where these are defined?

Upvotes: 0

Views: 4788

Answers (2)

Dreamvention
Dreamvention

Reputation: 1

In Opencart Positions are used by Modules. They are set in admin unders extensions/modules. When you click save - it saves them to the database table oc_settings under the modulename_module

When Opencart is launched - in INDEX.php there is this code

// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0' OR store_id = '" . (int)$config->get('config_store_id') . "' ORDER BY store_id ASC");

foreach ($query->rows as $setting) {
    if (!$setting['serialized']) {
        $config->set($setting['key'], $setting['value']);
    } else {
        $config->set($setting['key'], unserialize($setting['value']));
    }
}

it creates the config - a massive array of all the settings for the current store id.

Afterwards the position controllers (column_left.php, column_right.php, content_top.php and content_bottom.php) go through the extensions in the table oc_extension and finds all the modules that will need to be shown.

then it goes through this massive array CONFIG and collects the settings for these modules - this all is stored in a array $module_data

then the controller uses these settings to basicly launch every controller of the module that should be shown. It passes the controller route and $settings for every module in a foreach loop and in result gets a render of the modules.

You can access the config anywhere in the php file - it can be another controller, a model or even tpl file.

$this->config->get(...)

If you want - you can go directly to the databes oc_settings and get the data from there with these functions

$this->load->model('setting/setting'); // remeber to always load the model.
$this->model_setting_setting->editSetting( 'free_checkout', $this->request->post);

Hope this helps.

Also you can use this module to expend the number of positions for your opencart SUPER easy Extra positions Unlimited

Upvotes: 0

hadvig
hadvig

Reputation: 1106

At first, look into your extension file ( for example 'payment/free_checkout.php') and search for something like that

$this->model_setting_setting->editSetting( 'free_checkout', $this->request->post);

This is where settings stored into database ( you can go deeper into setting model, if you want )

After that, open admin/index.php and look at lines 38 - 48. You can see, system gets data from database and store data into config object.

Upvotes: 1

Related Questions