Extension doesn't get enabled

2k Views Asked by At

I'm migrating extension for Opencart 2.3 to Opencart 3. Everything seems to work fine, except that I can't enable the extension. When I go to extension->shipping the status doesn't change it stays disabled, however if I go to settings, the drop down shows that enabled is selected. There aren't any errors on the front-end, or in the log files. I tried debugging but everything seems fine. Any ideas what may be wrong? Also the setting in the database(extensionName_status) is 1
Note: the extension is large, and it will be too much if I post it here. If you need specific fragment of code, I will provide it.

2

There are 2 best solutions below

0
On BEST ANSWER

The tricky thing about the 2.3->3.0 migration was that some variable names changed in a subtle way (as noted in my comment above). The status variable could be your problem. Here's Better Together 3.0 (left) vs 2.3 (right) in the controller file:

<       $data['total_better_together_status'] = $this->config->get('total_better_together_status');
---
>       $data['better_together_status'] = $this->config->get('better_together_status');
0
On

If your OpenCart 3.x module is labeled in the Modules category, then:

    if (isset($this->request->post['module_mymodule_status'])) {
        $data['module_mymodule_status'] = $this->request->post['module_mymodule_status'];
    } else {
        $data['module_mymodule_status'] = $this->config->get('module_mymodule_status');
    }

Or if it's labeled in the Analytics category, then you just change the module to analytics as shown below:

if (isset($this->request->post['analytics_mymodule_status'])) {
    $data['analytics_mymodule_status'] = $this->request->post['analytics_mymodule_status'];
} else {
    $data['analytics_mymodule_status'] = $this->config->get('analytics_mymodule_status');
}