Skip to content

Developer notes

← Overview

The add-on registers two core exim patterns (app/addons/kv_category_import_export/schemas/exim/), so they appear in Administration → Export data / Import data and use the core engine (fn_export(), fn_exim_get_csv(), fn_import()), layouts and file handling.

  • Export runs through fn_export(). Values that are not plain columns (path, SEO name, image, available views, store) come from process_get functions backed by in-memory caches (one query per table, not per row). Trash categories are left out; rows are ordered by id_path, so parents come first.
  • Import uses import_process_data to take over each row group (all languages of one category) and sets skip_record, so the core writes nothing itself (the same approach as the core features pattern). CategoryImporter resolves the category (ID or path), creates parents, compares every value and writes only the changes through fn_update_category() per language, so the SEO add-on and other add-ons’ category hooks run as usual. Images go through fn_exim_import_images().
  • Product links: LinkImporter collects the rows and applies them per product in post_processing through fn_update_product_categories() (Ultimate product sharing and Multi-Vendor vendor counts follow), then sets positions.
  • Dry run: the same resolution with virtual (negative) IDs in the in-memory tree; nothing is written.
  • Report: post_processing replaces the core summary notification and writes kv_categories_report_<date>.csv / kv_category_products_report_<date>.csv to the export directory.

Note for 4.21: fn_update_category() empties selected_views when the key is missing (4.17 kept it). The importer always passes the current value.

Path Purpose
app/addons/kv_category_import_export/addon.xml Settings, default layouts (install/uninstall queries)
app/addons/kv_category_import_export/func.php Licence check, settings info, exim process functions
app/addons/kv_category_import_export/schemas/exim/kv_categories.php Categories pattern
app/addons/kv_category_import_export/schemas/exim/kv_category_products.php Product categories pattern
app/addons/kv_category_import_export/schemas/permissions/admin.post.php Console controller privileges
app/addons/kv_category_import_export/schemas/permissions/vendor_multivendor.post.php Hides the section from vendors
app/addons/kv_category_import_export/controllers/backend/kv_category_import_export.php Console export/import
app/addons/kv_category_import_export/Tygh/Addons/KvCategoryImportExport/Tree.php In-memory category index (paths, names, moves)
.../CategoryImporter.php, LinkImporter.php Import logic
.../Exporter.php, Images.php, Values.php Export values, images, normalisation
.../Report.php, Summary.php Row messages, notification and report file
.../SmartCollections.php Coexistence with Smart Collections
.../License/, .../Upgrade/Synchronizer.php License client, self-healing upgrades
design/backend/css/addons/kv_category_import_export/styles.less Report list and settings styles
var/langs/en/addons/kv_category_import_export.po Texts

No core PHP hooks are needed: the add-on works through exim schema callbacks (export_pre_moderation, pre_export_process, pre_processing, import_get_primary_object_id, import_process_data, post_processing). It calls fn_update_category(), fn_update_product_categories() and fn_update_product_count(), so their hooks fire for other add-ons.

Other add-ons can add columns with schemas/exim/kv_categories.post.php. A field with db_field of a categories or category_descriptions column is exported by the core; on import, the add-on’s importer only writes the columns it knows, so add a post_processing handler for your own columns.

fn_kv_category_import_export_is_licensed() wraps License\Client::isActive(). Without a valid license the pattern permissions contain an edition no store has (the core hides the patterns), export_pre_moderation stops direct exports, the import pre_processing empties the data and the console controller refuses. No data is changed.