Nov 11, 2014

Developer notes for migrating extensions to OpenCart 2

My condolences to anyone reading this.

Please note that this is not a full list of changes, as I've only been working with payment gateway extensions at the moment.

Opencart released version 2 in October 2014 with major layout and structure changes. When looking at the new version at first glance the codebase seems the same and you'd think extensions should work by default. They won't.

The first thing to notice is that they completely changed templates files - HTML structure, forms. TPL files should be completely rewritten. But at least the new admin layout looks nice.
  • Admin template files use forms, columns.
  • Catalog template files use a new default page layout
  • Any custom error template files need to adhere to the new layout.

Methods visibilty in classes is changed to public. Using private or protected will not work.
class ControllerPaymentPPStandard extends Controller {
public function index() { ...

Catalog model has a new property (terms & conditions URL) that is returned in the method data array.:
'terms'      => '',

There is no render function in controllers in version 2. Using the call
$this->render(); has been changed to
return $this->load->view($template_file, $data);
Important thing to note here is that $data must be a local variable, not a class attribute.

Redirection is changed from

$this->model_checkout_order->confirm() and
$this->model_checkout_order->update() have been changed to