Developer notes
Technical reference for developers who customize Vendor Catalog Guardrails.
Add-on identity
Section titled “Add-on identity”| Item | Value |
|---|---|
| Add-on id | kv_vendor_catalog_guardrails |
| Function prefix | fn_kv_vendor_catalog_guardrails_ |
| Language variables | kv_vendor_catalog_guardrails.* |
| CSS scope | .kv-vcg |
| PHP namespace | Tygh\Addons\KvVendorCatalogGuardrails |
| Edition | Multi-Vendor (core edition MULTIVENDOR) |
Hooks used
Section titled “Hooks used”PHP hooks (arguments identical in 4.17.2 and 4.21.2):
update_product_pre($product_data, $product_id, $lang_code, $can_update): remembers the price before the save and sets$can_update = falsewhen a Block rule fails (vendors only);update_product_postat priority 5000, after the core Vendor data premoderation handler (4000): runs the rules, stores the check and decides;clone_product_postat priority 5000: a vendor’s copy of a product is checked like a new product;delete_product_post,delete_company: remove the stored checks.
Template hook: products:update_detailed_images.pre (result box on the product page). The add-on works through the public functions of the core premoderation add-on: fn_vendor_data_premoderation_approve_products(), _disapprove_products() and _request_approval_for_products(). When that add-on is switched off, Reject disables the product (status Disabled) and Hold / Approve only record the result.
Note: core refuses to move a product out of “Requires approval” while a vendor is the logged-in user, so the add-on marks only the products its rules approve in that call and a tools_update_status_before_query handler (priority 2500, after core) lets exactly those status changes through. The session and the user type are never changed.
Hooks provided
Section titled “Hooks provided”None.
Database tables
Section titled “Database tables”| Table | Content |
|---|---|
?:kv_vcg_rules |
rules: type, title, status, action (F / R / B), weight, plan (0 all, -1 no plan), reason template, JSON parameters, position |
?:kv_vcg_reasons |
reason templates |
?:kv_vcg_checks |
latest check per product: score, state (O open / D decided), resolution, JSON findings, queue time and SLA deadline |
?:kv_vcg_log |
events (90 days) |
?:kv_vcg_trusted |
trusted vendors |
All tables are kept on uninstall unless “Delete all data on uninstall” is on.
Rules engine
Section titled “Rules engine”Evaluator::evaluate($rules, $context, Probe $probe) is pure logic over a product context and a Probe (the database lookups), so it can be unit-tested without a store (tests/unit/cli.php). ContextBuilder builds the context from a saved product (post) or from the submitted form (pre, only rules that can be decided from the form). Moderator::decide() is the decision matrix.
REST API entity
Section titled “REST API entity”Tygh\Api\Entities\KvVcgChecks (/api/kv_vcg_checks), see Usage. Privileges: view_kv_vcg / manage_kv_vcg.
Template overrides
Section titled “Template overrides”Admin templates live in design/backend/templates/addons/kv_vendor_catalog_guardrails/. The add-on prints nothing on the storefront (full page cache safe).