Developer notes
app/addons/kv_pc_builder/Tygh/Addons/KvPcBuilder/Engine.php: the compatibility engine (pure PHP, no database): rule evaluation, candidate checks, power estimate and the constraints used for SQL filtering.Facts.php: the feature index (?:kv_pcb_facts).Catalog.php: part lists through corefn_get_products()plus the add-on condition.Builds.php: selection parsing, the verified summary, share codes.Cart.php: adding a build to the cart, cart ids, labels, ordered counter.Templates.php,Messages.php,Audit.php,Presets.php,Config.php.
- Controllers:
controllers/frontend/kv_pc_builder.php(view, options, check, load, save, add, remove),controllers/backend/kv_pc_builder.php. - Storefront:
views/kv_pc_builder/view.tpl,components/line.tpl, hookscheckout:product_info,checkout:minicart_product_info,orders:product_info;js/addons/kv_pc_builder/func.js,css/addons/kv_pc_builder/styles.less. - Admin:
views/kv_pc_builder/{manage,update,builds,data}.tpl, hookorders:product_info.
Tables
Section titled “Tables”| Table | Content |
|---|---|
kv_pcb_templates (+ _descriptions) |
Template settings; name, description, page title, meta description per language |
kv_pcb_slots (+ _descriptions) |
Slots: position, icon, required, part and quantity limits, categories, feature filter, spec features |
kv_pcb_rules |
type (match, lte, power), slot_a, features_a (CSV), slot_b, feature_b, sum_qty |
kv_pcb_facts |
Feature index: product_id, feature_id, normalized value, number, display text. PRIMARY KEY (product_id, feature_id, val), keys (feature_id, val) and (feature_id, num) |
kv_pcb_builds |
Share codes: code, template, name, items (JSON slot => product => qty), hash, total, carted, ordered |
How part lists are filtered
Section titled “How part lists are filtered”Catalog::options() calls fn_get_products() with the slot categories, search, sorting and pagination, so visibility, usergroups, Ultimate sharing and Multi-Vendor vendor status stay core. The add-on condition is appended in the get_products hook from a static property that is set only around its own call (never from request parameters):
- slot feature filter and the stock rule;
- the compatibility constraints from
Engine::constraints()as correlatedEXISTSsubqueries on thekv_pcb_factsprimary key, for exampleEXISTS (SELECT 1 FROM kv_pcb_facts WHERE product_id = products.product_id AND feature_id = 12 AND val IN ('am5')).
The pagination therefore counts compatible parts only. A second count without the constraints gives the “N hidden” note. Compatibility of each listed part is then evaluated in PHP (Engine::candidate()) for the badge and the reasons.
Cart lines
Section titled “Cart lines”Each part is added with extra.kv_pcb = {uid, name, code, tpl, slot, sn}. The uid is added to the cart id (generate_cart_id). Stamps are signed during the request that adds the build; pre_add_to_cart drops any stamp posted from outside. get_order_info adds the build name to item names (setting).
Full page cache (4.21)
Section titled “Full page cache (4.21)”schemas/full_page_cache/varnish.post.phpaddskv_pc_builder.viewto the cacheable dispatches andkv_pcb_buildsto the ignored cache tags.- The page HTML holds no visitor data: slots, texts and URLs only. Prices, stock, compatibility and the build are loaded by AJAX GETs (
options,check,load) that never write.saveandaddare POSTs.
Hooks used
Section titled “Hooks used”get_products, generate_cart_id, pre_add_to_cart, get_order_info, place_order, update_product_features_value_post, clone_product_post, delete_product_post, update_product_feature_post, delete_feature_post, import_post.
Console
Section titled “Console”php admin.php --dispatch=kv_pc_builder.rebuild -pUpgrades
Section titled “Upgrades”The add-on ships Upgrade\Synchronizer (revision 3): after an in-place upgrade it adds missing tables, columns, settings and language variables on the next admin page.