Skip to content

fix: correct the product feed contents and the discovery document - #16

Merged
KristofersOzolinsMagebit merged 2 commits into
developfrom
feat/spec-library-adoption
Sep 10, 2026
Merged

KristofersOzolinsMagebit merged 2 commits into
developfrom
feat/spec-library-adoption

Conversation

@KristofersOzolinsMagebit

Copy link
Copy Markdown
Member

Seven defects in the product feed and the discovery document, all found by running an export
against a real catalogue and by validating every response against the vendored ACP JSON Schema.

The export crashed, and the file it wrote was unusable

magebit:agentic-commerce:export died with
Config::getSellerName(): Return value must be of type string, null returned. The specification
makes the seller name optional, so the return type is now nullable. Two
@phpstan-ignore return.type comments had been hiding this.

Fixing the crash let the export finish, and the file it produced was wrong: the header had 22
columns while 1847 of 1891 rows had 27, so almost every row was written shifted — a variant's price
landed under an option label. Three causes:

  • The writer took its header from whichever product came first and wrote each row by value
    order. Products do not all carry the same columns, because a variant adds a pair per option.
    Rows are now buffered while the full column set is learned, then written against one header.
  • The variant columns were merged in on every pass of the mapping loop, so they landed
    mid-row and the work was repeated once per column.
  • formatValue threw away the value it was given and read it again without the parent
    product.
    Every column sourced from the parent came out empty, so all 1847 variants had no
    item_group_id and an agent could not group them.

A fifth defect showed up while checking the output: the bundle product was advertised at
0.00 USD with checkout enabled, when it really costs 61 to 77. Bundle and grouped products hold
no price of their own, and the price attribute is the string '0.000000' — truthy, so the
formatter's guard never fired. A new Source\Price falls back to the indexed minimum.

After the fixes: 27 columns, 1891 rows, every row 27 fields wide, all 1847 variants carrying
item_group_id, no blank ids, no blank or zero prices, no blank seller names.

The discovery document did not match the schema

ACP publishes no conformance suite, so nothing had ever checked our reading of the specification
from outside. A new harness drives every operation the vendored specification defines over HTTP and
validates each response against the specification's own JSON Schema. It found three divergences:

  • api_base_url named the checkout sessions rather than what they hang off, so an agent following
    the schema's own instruction requested /checkout_sessions/checkout_sessions.
  • Currencies went out as USD; the schema asks for lowercase.
  • Locales went out as Magento's en_US rather than the BCP 47 en-US.

Two existing unit tests had been asserting the wrong values, which is how all three survived. The
document also now advertises the services the store actually serves.

Tests

20 new tests, 189 passing in the module. Each was checked by putting the defect back and confirming
the test fails. phpcs, phpstan and the unit suite are green; six now-stale entries were removed
from the PHPStan baseline, which had been locking several of these bugs in.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ore serves

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@magebit-automation

magebit-automation Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✅ Magebit Code Review — Review complete

No issues met the confidence threshold to publish.

Changed files (18)

Api/

  • Api/ConfigInterface.php +4 −2
  • Api/Data/FeedProductInterface.php +7 −1
  • Api/ProductFeedWriterInterface.php +8 −0

Model/

  • Model/Config.php +18 −14
  • Model/Discovery/DiscoveryDocumentBuilder.php +33 −5
  • Model/Export/ProductFeed.php +2 −0
  • Model/Export/Writer/CsvWriter.php +136 −7
  • Model/Mapping/AbstractMapper.php +4 −4
  • Model/Mapping/ConfigurableProductMapper.php +10 −3
  • Model/Mapping/Source/Price.php +53 −0

Test/

  • Test/Unit/Model/ConfigTest.php +99 −0
  • Test/Unit/Model/Discovery/DiscoveryDocumentBuilderTest.php +44 −9
  • Test/Unit/Model/Export/Writer/CsvWriterTest.php +257 −0
  • Test/Unit/Model/Mapping/ConfigurableProductMapperTest.php +125 −0
  • Test/Unit/Model/Mapping/SimpleProductMapperTest.php +142 −0
  • Test/Unit/Model/Mapping/Source/PriceTest.php +72 −0

etc/

  • etc/ac_product_feed_mapping.xml +1 −1

(root)

  • phpstan-baseline.neon +0 −30

Reviewed by ~x-ai/grok-latest

@KristofersOzolinsMagebit
KristofersOzolinsMagebit merged commit c1f701a into develop Sep 10, 2026
3 checks passed
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.

1 participant