Repository navigation
feat(php-transformer): recognise priceless cards that link to a caller-declared catalog product - #8036
Merged
Conversation
…r-declared catalog product
…ind a doubled card title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_purchasegrid (one "Classic Grahams" card: image + heading linking to/products/classic-grahams-6-75oz) was imported as staticcore/group/core/image/core/heading. The catalog SSI declares asentity_collection:products(generic/products/v1) was merged only after the HTML had been converted (RuntimeDeclarationPromotion::mergeCatalogProducts()), so card recognition never saw it.What changed
ArtifactPageCompilerreads the caller'sgeneric/products/v1rows (slug +source_route/url) from the runtime declarations it already receives and passes them as acatalog_productstransform option.HtmlCompilationregisters 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→HtmlToBlocksonly.CatalogProductEvidence(new,HtmlToBlocks/Patterns): does a link name a declared product? Route equality (case-insensitive, ignoring a trailing/,/index.htmlor.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 (animg) whose name link names a declared product qualifies with or without a price. Its card data carriescatalog_product: trueand omitspricewhen 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 existinghtml_product_grid_fallback→generic/product-grids/v1path. The item template has slots only for what the card shows (hereimage+name, noprice).CommerceFallbackReporteritem template: a card that draws its title twice binds both copies asnameslots. 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. Onlynameis exempt, because it matches the exact product name. Other roles keep the ambiguity rule.RuntimeEntityCollectorkeeps a priceless catalog card's row (noregular_price). The catalog merge supplies the price, and the catalog owns the commerce fields as before.docs/contracts/products.mddocuments 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 throughArtifactCompiler. It uses a reduced partake card oncollections/all/index.htmland a product page with an add-to-cart form:product_gridsentity whose item isclassic-grahams-6-75oz, with exactly oneimageand onenameslot and noprice/add_to_cartslot. The merged product has the catalog price6.99and the card binding. A catalog product without a card stays bindingless. The plan passesWordPressSitePlan::assertValid./products/graham-cracker-pie) gives no grid.image×1 andname×2 slots and nofieldslot. Without the name exemption this fails:{"image":1}.On
trunk, case 1 fails withA one-card collection whose card links to a catalog product is a product grid: ["cart_links","products"]. Cases 2 and 3 pass ontrunkand 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 ontrunkin 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.shon/tmp/loop/partake-e2e-source/partakefoods.com, each time into a new disposable Studio site, and deleted every site afterwards. The baseline transformer isorigin/trunk6426cc5 (0.56.65). The candidate is this branch.SSI v1.47.9 (=
main). Since SSI #3648 (v1.47.4),collections/all/no_purchaseis a store-listing route: SSI 301s it to the seededno_purchaseproduct-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 onmain. This run checks for regressions:content_ownership.hardcoded_countbound_commerce_ui.bound_by_kindssi:cart_link7,mini-cart71ssi:cart_link7,mini-cart71bound_commerce_ui.static_by_kindunbound_product_region1 (header cart link)product_gridsdeclaredNo 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_purchasepage intotemplates/tag-no-purchase.html, served at/tag/no-purchase/). This run shows the card itself:product_gridscollections/all/no_purchase, itemclassic-grahams-6-75oz, slotsimage,name,name(no price, no add-to-cart)templates/tag-no-purchase.htmlcore/heading"Classic Grahams" ×2woocommerce/product-collection(hand-picked [88] =classic-grahams-6-75oz) ›product-template›product-image+ 2×core/post-titlecontent_ownership)templates/tag-no-purchase.html,core/heading)bound_by_kindproduct blocksproduct-collection1,product-template1,product-image1The rest of v1.47.3's
hardcoded_countis 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 bothcard__heading … wp-block-post-titleheadings 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
unresolvedlookalike 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. Onmainthe 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-productcommerce-catalog.jsonasgeneric/products/v1rows): trunk gives noproduct_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.