Skip to content

feat(php-transformer): recognise priceless cards that link to a caller-declared catalog product - #8036

Merged
chubes4 merged 2 commits into
trunkfrom
feat/catalog-product-card-evidence
Dec 6, 2026
Merged

chubes4 merged 2 commits into
trunkfrom
feat/catalog-product-card-evidence

Conversation

@chubes4

@chubes4 chubes4 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8025 (option 1: catalog-corroborated cards).

Why

A product card that shows no price and no purchase control never qualified as a product, even when the caller's declared catalog names the product its title links to. On partakefoods.com, Shopify's collections/all/no_purchase grid (one "Classic Grahams" card: image + heading linking to /products/classic-grahams-6-75oz) was imported as static core/group/core/image/core/heading. The catalog SSI declares as entity_collection:products (generic/products/v1) was merged only after the HTML had been converted (RuntimeDeclarationPromotion::mergeCatalogProducts()), so card recognition never saw it.

What changed

  • New input into HTML conversion. ArtifactPageCompiler reads the caller's generic/products/v1 rows (slug + source_route/url) from the runtime declarations it already receives and passes them as a catalog_products transform option. HtmlCompilation registers them with the source document next to the existing schema evidence (CommerceStructureRecognizer::registerSourceDocument()), so every recognizer instance reading that document's cards sees the same evidence. No new layer edge: ArtifactCompiler → HtmlToBlocks only.
  • CatalogProductEvidence (new, HtmlToBlocks/Patterns): does a link name a declared product? Route equality (case-insensitive, ignoring a trailing /, /index.html or .html). A document-relative link, or a row without a route, falls back to the slug as the last route segment. Provider neutral: no /products/ vocabulary.
  • CommerceStructureRecognizer: a card with a product photo (an img) whose name link names a declared product qualifies with or without a price. Its card data carries catalog_product: true and omits price when none is shown. An inline SVG glyph is not a photo. Without this rule, Dawn's announcement bar (<a href="/products/girl-scouts-sparkables"><p><span>Announcing…</span><svg class="icon icon-arrow">) became a one-item grid on every page.
  • CommerceFallbackReporter: a catalog card counts as strong evidence (like schema.org or a cart control), so a one-card grid qualifies without listing controls. The grid then takes the existing html_product_grid_fallback → generic/product-grids/v1 path. The item template has slots only for what the card shows (here image + name, no price).
  • CommerceFallbackReporter item template: a card that draws its title twice binds both copies as name slots. Dawn does this, with a heading over the media and another in the caption. Before, a role matching more than one leaf named none of them, so a one-card grid kept "Classic Grahams" as hardcoded template text. Only name is exempt, because it matches the exact product name. Other roles keep the ambiguity rule.
  • RuntimeEntityCollector keeps a priceless catalog card's row (no regular_price). The catalog merge supplies the price, and the catalog owns the commerce fields as before.
  • docs/contracts/products.md documents the evidence.

Without a caller catalog, nothing changes: every card path and threshold, including MIN_IMAGE_ONLY_QUALIFIED_CARDS, is untouched, so showcase or recipe pages on non-commerce imports cannot become grids. A catalog does not vouch for a card that links to an undeclared route.

Tests

New tests/contract/catalog-product-cards.php, driven through ArtifactCompiler. It uses a reduced partake card on collections/all/index.html and a product page with an add-to-cart form:

  1. One priceless card linking to a catalog product gives one product_grids entity whose item is classic-grahams-6-75oz, with exactly one image and one name slot and no price/add_to_cart slot. The merged product has the catalog price 6.99 and the card binding. A catalog product without a card stays bindingless. The plan passes WordPressSitePlan::assertValid.
  2. The same card without a catalog gives no grid (unchanged).
  3. With a catalog, a card linking to an undeclared route (/products/graham-cracker-pie) gives no grid.
  4. With a catalog, an announcement link to a catalog product that carries only an SVG arrow gives no grid. Without the photo rule this fails: one grid.
  5. With a catalog, a card with a doubled title gives image ×1 and name ×2 slots and no field slot. Without the name exemption this fails: {"image":1}.

On trunk, case 1 fails with A one-card collection whose card links to a catalog product is a product grid: ["cart_links","products"]. Cases 2 and 3 pass on trunk and with the change.

Local runs (PHP 8.5):

  • composer lint: PHPCS + PHPStan, no errors.
  • composer test:parity: 376 fixtures pass.
  • php tests/run.php: 2142 scripts. 4 fail identically on trunk in this local environment (Chromium geometry: artwork-slideshow, positioned-carousel-stage, out-of-flow-slides-carousel-stage; PHP 8.5 deprecation output: header-button-box). No new failures.
  • caller-products-catalog.php, product-grid-item-templates.php, layer-direction.php: pass.

Real check: reimport of the frozen partakefoods.com capture

I ran static-site-importer/lab/import-loop/gates/reimport.sh on /tmp/loop/partake-e2e-source/partakefoods.com, each time into a new disposable Studio site, and deleted every site afterwards. The baseline transformer is origin/trunk 6426cc5 (0.56.65). The candidate is this branch.

SSI v1.47.9 (= main). Since SSI #3648 (v1.47.4), collections/all/no_purchase is a store-listing route: SSI 301s it to the seeded no_purchase product-tag archive (/product-tag/no_purchase/, Woo's native product collection). That page is no longer in the compiled artifact, so this capture no longer shows the static card on main. This run checks for regressions:

SSI v1.47.9 trunk this branch
content_ownership.hardcoded_count 0 0
bound_commerce_ui.bound_by_kind ssi:cart_link 7, mini-cart 71 ssi:cart_link 7, mini-cart 71
bound_commerce_ui.static_by_kind unbound_product_region 1 (header cart link) same
product_grids declared none none
scorecard statuses identical identical

No new grid appears on the home page, the blog posts or the recipe pages. Before the photo rule, Dawn's announcement bar became a grid on every page. The rule removed that false positive before this run.

SSI v1.47.3 (last release that still compiles the no_purchase page into templates/tag-no-purchase.html, served at /tag/no-purchase/). This run shows the card itself:

SSI v1.47.3 trunk this branch
product_grids none 1: collections/all/no_purchase, item classic-grahams-6-75oz, slots image, name, name (no price, no add-to-cart)
templates/tag-no-purchase.html static core/heading "Classic Grahams" ×2 woocommerce/product-collection (hand-picked [88] = classic-grahams-6-75oz) › product-template › product-image + 2× core/post-title
hardcoded "Classic Grahams" (content_ownership) 2 (templates/tag-no-purchase.html, core/heading) 0
bound_by_kind product blocks none product-collection 1, product-template 1, product-image 1

The rest of v1.47.3's hardcoded_count is the "Vanilla Wafers" mega-menu labels, which SSI #3656 later excluded. Rendered /tag/no-purchase/ (candidate): <li class="wc-block-product post-88 … product_tag-no_purchase blocks-engine-collection-item-transport"> with the Woo product image (classic-grahams-1024x1024.jpg) and both card__heading … wp-block-post-title headings rendering "Classic Grahams" from the product. That is the source card's markup, with no price.

One caveat on v1.47.3: its region report also lists the new grid's binding as an unresolved lookalike for that document. It already lists the same document's cart-link binding that way on trunk, even though the template contains the lowered product collection. That is the old SSI's template-document region accounting. On main the route is no longer compiled, so it does not apply.

Direct compile of the real captured page (collections/all/no_purchase/index.html + index.html + the capture's 15-product commerce-catalog.json as generic/products/v1 rows): trunk gives no product_grids. This branch gives exactly one grid, the Classic Grahams card.

Written by Claude (Opus) via Pi coding agent, orchestrated by Franklin; AI implemented the change and tests.

@chubes4
chubes4 merged commit 84b5477 into trunk Dec 6, 2026
27 checks passed
@chubes4
chubes4 deleted the feat/catalog-product-card-evidence branch December 6, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Priceless product cards (and small image-only grids) never bind even when the declared catalog names the product

1 participant