Developer notes
PDF engine
Section titled “PDF engine”Tygh\Addons\KvPdfCatalog\Pdf\Document is a small PDF 1.7 writer in pure PHP: embedded TrueType subsets (Noto Sans, Identity-H with a ToUnicode map, so text can be searched and copied), filled, stroked and rounded rectangles, lines, JPEG images (PNG, GIF and WebP converted with GD on a white background, large images downscaled), clipping and URI link annotations. Image data is kept in a temporary file and save() streams the document to disk, so memory stays low on large catalogs.
Renderer draws the cover and the layouts; Products reads the product rows; Builder builds, stores and schedules.
How products are read
Section titled “How products are read”Products::load() calls fn_get_products() with area = C and the catalog’s options, then fn_gather_additional_products_data() with images and discounts. During the build the session auth is switched to a virtual customer of the chosen price group (usergroup_ids = All + Registered + the group, or All + Guest), so user group prices, catalog promotions and storefront visibility apply; on Ultimate runtime.company_id is set to the catalog’s storefront. Both are restored afterwards.
“In stock only” adds products.amount > 0 OR products.tracking = 'D' in the get_products hook when $params['kv_pdf_catalog_in_stock'] is set.
Features come from fn_get_product_features_list($product, 'CP') (shown in product lists or on the product page), at most six per product.
Hooks used
Section titled “Hooks used”PHP: get_products, before_dispatch (admin-visit scheduler, runs after the response with register_shutdown_function). Same signatures in 4.17.2 and 4.21.2. No template hooks: the storefront uses an own page (kv_pdf_catalog.catalogs) and a Block Manager block.
?:kv_pdf_catalogs: catalog_id, company_id (Multi-Vendor 0 = marketplace, else vendor; Ultimate = storefront), status, name, usergroup_ids (CSV, 0 = all), show_in_block, rebuild_hours, options (JSON), file_name, built_at, build_info (JSON: pages, products, bytes, seconds, error), position, timestamps.
Files: var/kv_pdf_catalog/catalog-<id>-<16 hex>.pdf; a rebuild writes a new file and removes the old one.
Dispatches
Section titled “Dispatches”- Admin / vendor:
kv_pdf_catalog.manage|add|update|build|download|duplicate|delete. - Console:
php admin.php --dispatch=kv_pdf_catalog.cronprints a JSON summary. - Storefront:
kv_pdf_catalog.catalogs[&company_id=],kv_pdf_catalog.download&catalog_id=,kv_pdf_catalog.cron&key=(404 without the right key).
Full page cache
Section titled “Full page cache”The PDF catalog downloads block is session_dependent and not cached, so under the 4.21 full page cache it is rendered per visitor (the list depends on user groups). The catalog page and downloads are add-on dispatches, which are never cached.