Как адаптировать модули под opencart 2

С появлением новой версии Opencart появилась необходимость адаптировать под нее модули от старых версий. Это не так уж и сложно, нужно только знать некоторые нюансы.

Я приведу вам основные из них.

Для адаптации модулей Opencart 1.5.x под Opencart 2.x нужно учитывать следующие изменения:

1. Вместо 

$this->data

теперь нужно писать 

$data

2. Вместо

$this->template = 'module/module.tpl';

будет 

$this->response->setOutput($this->load->view('module/module', $data));

3. Вместо

$this->render()

будет

$this->load->view('catalog/category_list.tpl', $data);

4. Вместо

 $this->children = array(
  'common/header',
  'common/footer'
);

будет

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

5. Вместо

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

будет

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

6. Все поля в админке нужно верстать под bootstrap.

Смотрите также Модули Opencart 2

Комментарии 0