Ka Extensions

Ka Extensions: Kapatch Mechanism

Overview

Ka Extensions provides the ability to apply patches to code in a way similar to OCMOD/VQMOD. This mechanism is called kapatch .

It was primarily implemented to eliminate dependency on OCMOD across different OpenCart versions.

Kapatch is applied after all modifications and is stored in the cache.kamod directory, alongside the class cache generated by the Kamod engine.

File Structure

Unlike traditional approaches where all patches are stored in a single file, kapatch uses a separate file per target file .

Kapatch files follow the same structure as child classes and templates.

To patch a file, you must recreate its path within your module and use an .xml extension.

Example

Original file:

/admin/controller/catalog/product.php

Kapatch file:

/admin/controller/extension/<vendor-name>/<module-name>/controller/catalog/product.php.xml

Kapatch Format

The structure of a kapatch file is as follows:

<kapatch version="1.0">
    <changes>
        <operation type="replace">
            <search regexp="true"><![CDATA[SEARCH-STRING]]></search>
            <text><![CDATA[REPLACEMENT-STRING]]></text>
        </operation>
    </changes>
</kapatch>

Details:

  • Multiple operation nodes can be defined within the changes section.
  • The regexp attribute is optional.
  • Currently, only one operation type is supported:

    • replace

Error Handling

Any errors encountered during kapatch application:

  • Are written to the error log file
  • Appear in the admin panel as a counter on the ambulance icon

Best Practices

Avoid inserting large chunks of code using kapatch. It is recommended to use kapatch primarily for lightweight modifications, such as inserting file inclusions.

Search results