Ka Extensions for OpenCart 4

This documentation applies to Ka Extensions for OpenCart 4.x only. It is not compatible with OpenCart 3.

What Is Ka Extensions

Ka Extensions is a shared library for OpenCart 4 used by the modules of Karapuz Team (ka-station.com). It is installed as a separate OpenCart extension with the code ka_extensions , so updates and fixes are applied to all modules at once.

Requirements: OpenCart 4.1.0.3 - 4.1.x, see How To Install Ka Extensions.

Kamod Engine

Kamod lets a module change OpenCart classes and templates by inheritance instead of patching the original files:

  • a module class extends the original controller, model or library class and overrides only the methods it needs (see Overriding Core Files);
  • several modules can extend the same class: kamod builds a chain where every class extends the previous one;
  • twig templates are extended in the same way (see Twig Templates);
  • a module can extend files of another module (see Overriding Other Modules).

Kamod generates the resulting classes and templates in the kamod cache (system/storage/cache.kamod/ ) and loads them instead of the original files.

KaPatch

KaPatch is a part of kamod that makes small text changes in files, like OCMOD: plain text or regular expression replacement (see KaPatch Mechanism).

Ka Extensions Page

Ka Extensions adds the Extensions > Ka Extensions page to the admin area. Modules based on the library ("ka_type": "ka_extensions" in install.json , see install.json Reference) are listed there, installed, uninstalled and registered with a license key.

Base Classes for Modules

Classes in the \Opencart\Extension\KaExtensions\System namespace (extension/ka_extensions/system/ ):

  • Controller , Model - base classes with the onLoad() hook and the kadb database helper;
  • TraitController - render helpers: disableRender() , enableRender() , getRenderData() , getRenderTemplate() , showPage() , top messages;
  • ControllerInstaller , ControllerSettings - module installer and settings page (see Module Settings Page);
  • ControllerForm , TraitControllerForm - forms built from a list of fields;
  • Db , QB , Tables - database helpers (see Database: Db, QB and Tables);
  • Mail - emails from twig templates (see Sending Emails);
  • KaGlobal , Language , Store , Arrays , Format , Curl , UrlParams , Pagination - helpers.

The API reference of these classes is a part of this documentation.

Twig Functions

t() , has_t() , linka() and other twig functions, and base page templates for the admin area (see Twig Templates).

Other Changes

The library also changes some standard behaviour through kamod:

  • the Ka Extensions menu item and the ambulance icon with the number of kamod errors in the admin header;
  • missing language files of extensions fall back to English (en-gb );
  • email attachments can have their own file names;
  • user permissions include routes of extension controllers.

Search results