Skip to content

Developer notes

Technical reference for developers who customize Base.com Connector.

Item Value
Add-on id kv_basecom
Function prefix fn_kv_basecom_
Language variables kv_basecom.*
CSS scope .kv-basecom
PHP namespace Tygh\Addons\KvBasecom

All calls are POST https://api.baselinker.com/connector.php with the header X-BLToken and the form fields method and parameters (JSON), as in the official documentation (https://api.baselinker.com/). Answers carry status SUCCESS or ERROR with error_message and error_code. The limit is 100 requests per minute.

Method Used for
getInventories Connection test, the catalog choice
getInventoryWarehouses The warehouse choice (<type>_<id>, stock_edition only)
getInventoryPriceGroups The price group choice and its currency
getInventoryCategories, addInventoryCategory Category path of a product (parents first, unique name below a parent)
getInventoryProductsList Look a product or variant up by SKU before creating it
addInventoryProduct Create (no product_id) or update a product; parent_id makes a variant
updateInventoryProductsStock Stock, up to 1000 products per request, {id: {"bl_206": qty}}
updateInventoryProductsPrices Gross prices, up to 1000 products per request, {id: {price group: price}}
getOrders New orders (date_confirmed_from, 100 per answer, continue from the last date_confirmed + 1 s), one order by order_id for status follow
getOrderSources Readable source names
getOrderStatusList Status maps
setOrderStatus Status after import, CS-Cart status pushed back
createPackageManual, getOrderPackages Tracking number; the lookup reconciles a report whose answer was lost

What the documentation does not say, and how the add-on treats it:

  • Error codes and the answer to an exceeded limit are not documented. Client\Api::isLimit() treats HTTP 429, or a message or code that says “request limit”, “rate limit”, “too many requests” or “token blocked”, as a limit: the job is retried after at least a minute. Other errors are permanent for the item (shown in the product list and the log) unless the transport failed (network, 5xx).
  • Partial updates. addInventoryProduct with a product_id is documented as an update; the add-on sends only the fields it wants to change (it never resends prices, stock or images on an update unless asked).
  • Variants in orders. An order line carries product_id and variant_id; the add-on tries both against the variants it created, then the SKU.
  • SKU filter and variants (unverified). The docs do not say that filter_sku also matches variant SKUs; the add-on assumes it and saves the variant map right after each call.
  • Empty SKU of a variant group parent. The Base.com parent of a CS-Cart variation group is created without a SKU (its own variation carries the product code); a SKU lookup of the parent’s code therefore finds the variant and the add-on links its parent_id.
Class Role
Client\BaseClient HTTP (cURL, TLS verification, timeouts), error mapping, masked logging
Client\Api The Base.com calls above; test mode (dry run) skips every write method
Client\RateMeter Per account, per minute request counter; refuses calls above 80 per minute
Drivers\BaseCom\Mapper Pure translation: getOrders row to the normalized order, addInventoryProduct parameters
Drivers\BaseCom\Driver Implements Hub\DriverInterface on Api and Mapper
Hub\ProductSync, Hub\Listings, Hub\Categories, Hub\ProductMap, Hub\Rules Product sync (create / link / update, variants, stock and price batches), price and stock rules, the map
Hub\Orders Order import (cursor, source filter, idempotent order map, status follow)
Hub\Shipments, Hub\StatusMap, Hub\Options Status and tracking push, status maps, per-account options
Accounts, Secret, Config, Access Token (sealed with AES-256-GCM), settings, vendor access
Queue, Jobs, JobException, Log Job queue with back-off, handlers and scheduler, log
Table Purpose
?:kv_basecom_accounts Token per company (sealed), mode, last connection check
?:kv_basecom_options Per account options, status maps, order cursor, vendor access
?:kv_basecom_product_map, ?:kv_basecom_variant_map, ?:kv_basecom_category_map CS-Cart product to Base.com product, variation product to variant, category to category
?:kv_basecom_order_map Imported orders (Base.com order id, status, pushed status, tracking state, error)
?:kv_basecom_jobs, ?:kv_basecom_log, ?:kv_basecom_rate, ?:kv_basecom_cache Queue, log, request meter, reference data

PHP hooks (init.php): update_product_post (the product is sent again), update_product_amount_post (stock is sent), delete_product_post (map rows are removed), change_order_status_post (an imported order reports its new status). All admin pages are controller modes of kv_basecom; there are no storefront hooks, so the add-on does not change what a customer sees and is safe with the full page cache.

The base URL can be overridden for tests in config.local.php (development only):

$config['kv_basecom_base_url'] = 'http://127.0.0.1:11830';

node tests/mock-server/server.js 11830 starts a local stand-in of the API built from the documentation (every response shape is copied from the docs page of its method); node tests/e2e/e2e.mjs --store <url> --db <db> --root <store dir> runs the HTTP end-to-end test against it and refuses to run unless the store points at the mock; php tests/unit.php runs the unit tests.

Admin templates live in design/backend/templates/addons/kv_basecom/. Do not edit them in a store; they are replaced on update.