1

I'm trying to add modules to the latest OpenCart version and so far no one worked. First I'm trying to add side cart, I found couple modules, but all of them are for earler versions and doesn't work with 2.0, also I tried to add facebook like box extension and there are the same errors.

So after module download I change couple things like in this thread Thread

1. I changed all $this->data to $data.
2.$this->response->setOutput($this->render());
I changed to $this->response->setOutput($this->load->view('module/minicart.tpl', $data)); 3 I changed $this->children to

$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');

So no errors when I'm trying to manage this module, but error when i'm trying to save it
Fatal error: Call to undefined method ControllerModuleMinicart::redirect() in C:\wamp\www\opencart\admin\controller\module\minicart.php on line 23

And the 23 line looks like:

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
            $this->model_setting_setting->editSetting('minicart', $this->request->post);        

            $this->session->data['success'] = $this->language->get('text_success');

            $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
        }

What I need to change? How I can finally start using modules ( it seems all modules are still for early versions and we have to remake them all..)

Community
  • 1
  • 1
Mode 856
  • 57
  • 1
  • 12

1 Answers1

3

Change

$this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));

to

$this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));

Sankar V
  • 4,110
  • 5
  • 28
  • 52
  • Thanks, no error now. But another issue, why my modules doesn't appear inside columns and inside Layouts -> Module where I can choose position my added modules doesn't appear in that dropbox where are default modules :/ – Mode 856 Feb 11 '15 at 09:05
  • Did you check the mysql query to fetch layout modules? – Sankar V Feb 11 '15 at 09:26
  • Where I can do that? I'm learning OC right now and I have no idea how to check that query :/ – Mode 856 Feb 11 '15 at 11:43
  • Check the function: `getLayoutModules` in `admin/model/design/layout.php`. – Sankar V Feb 11 '15 at 12:08
  • So line looks like `public function getLayoutModules($layout_id) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "'"); return $query->rows; }` I checked my msql database and I can't see my modules inside layout_module table, just default ones, if I install default module like "Information", everything works fine. So query doesn't fetch information to database I think, but why? – Mode 856 Feb 11 '15 at 12:29
  • Sorry.. I pointed the wrong file and function earlier. Check the function: `getInstalled` in `admin/model/extension/extension.php`. Try to debug by updating/uninstalling the current working modules. Also check how the data is inserted into that table in working modules and in your new module. – Sankar V Feb 11 '15 at 12:41
  • Ok, so all my modules are inside extension table. Inside layout_module table modules add's when I choose in admin panel `Layout -> Dropbox -> Models` but those 3rd party modules doesn't even appear in that dropbox that I can choose them for my layout. check this [screenshot](http://snag.gy/JXHie.jpg), I think something wrong with my module files, because even options window looks weird. – Mode 856 Feb 11 '15 at 13:01
  • Did you check the mysql queries related to your new extension ? – Sankar V Feb 12 '15 at 05:00
  • I can't understand, I downloaded facebook module which had to support 2.x version, but that also had bugs and I fixed them by replacing some code from default modules, then that module appeared in the layout screen, but in website has bugs as well.. So from now I have to replace almost 50% code of all 3rd party modules because of 2.x version..? Some kind of crazyness, why they changed everything so drastically that all older modules are useless unless you change a lot of code. Anyway I didn't reach my result, still trying to fix somehow – Mode 856 Feb 12 '15 at 08:09