Skip to content

feat(addons): Product Feed, the store catalogue as public JSON - #538

Open
vvezzola wants to merge 1 commit into
Panelica:mainfrom
vvezzola:feat/product-feed
Open

vvezzola wants to merge 1 commit into
Panelica:mainfrom
vvezzola:feat/product-feed

Conversation

@vvezzola

Copy link
Copy Markdown
Contributor

Summary

A bundled addon, Product Feed (modules/Addons/ProductFeed, inactive by default, its own service provider like BankPayments), that serves the store catalogue as public JSON at GET /feed/products.json. A marketing website can read the prices, options and addons the order form charges instead of copying them by hand.

Built to the shape agreed in #525:

  • Outside api/, so it never goes through ApiKeyAuth. No login, throttled to 60 requests a minute, cached for a configurable number of minutes (10 by default).
  • Starts from the visible scope: products come from Product::active() (neither hidden nor retired), with their visible configurable options and the product addons offered with them.
  • Fields are named, not filtered: every group, product, option, choice and addon is built from an explicit list of keys (name, slug, pay type, description raw and as descriptionHtml(), taxed, order_url, prices). Nothing is passed through from the model.
  • Default currency only. Prices are listed per cycle the product is sold on, with setup fees. An option value or addon that is not sold on a cycle (-1) has no entry for that cycle, never a -1.
  • CORS is off by default: the allowed origins list is empty until the operator fills it in (a list of origins, or *).
  • Parameters: group=<slug>, product=<slug>, lang=<code> (localised description, lang on the order link).
  • Settings: groups to publish (empty = every group the store lists; naming a hidden group publishes it, for a landing page outside the store menu), allowed origins, cache minutes.

Translations in en/tr/de/pl/zh/it and a guide in docs/guides/product-feed.md (added to mkdocs.yml).

Linked issue

Closes #525

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that changes existing behaviour)
  • Documentation only
  • Refactor / chore (no behaviour change)
  • Translation
  • Theme / styling
  • New module (gateway / registrar / server adapter)

Checklist

  • My branch is up to date with main (rebased on 3703966)
  • ./vendor/bin/pint --test passes on the new files
  • ./vendor/bin/phpstan analyse passes: 7 findings in Services/ProductFeed.php, all from existing model relations that have no return type (Product::pricing/terms/translations, ConfigOptionGroup::$options, ConfigOption::$subs), which Larastan cannot see. None points at a defect; I left the models alone to keep this PR to one subject.
  • php artisan test passes: not the full suite. tests/Feature/ProductFeedTest.php plus the Addon*, Translation*, ModuleDiscovery* and ApiAuditFixes tests: 226 passed.
  • I've added or updated tests for my change (visibility rules, group settings, filters, language, CORS, cache, -1 prices, admin page)
  • I've updated documentation (docs/, README.md, .env.example) where relevant
  • I've added or updated translation keys in lang/en/ (in the addon's own lang/en/addon.php)
  • I've considered the impact on existing installations (migration, config defaults): no migration, the addon is inactive until an operator turns it on, and CORS is closed until origins are listed.

Additional context

Out of scope for this first version, as discussed in #525: currencies other than the default, product bundles, promotions, domain pricing (client/domain-pricing already exists) and limits only a server module knows.

🤖 Generated with Claude Code

A website can print the prices, options and addons the order form
charges by reading /feed/products.json, instead of copying them by
hand. Only what the store already shows goes in: products neither
hidden nor retired, their visible option values and addons, in the
default currency. Settings: the groups to publish, the websites that
may read it from a browser (CORS) and the cache minutes.

This branch has not been deployed

No deployments
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.

[Feature] Product Feed addon: the store catalogue as public JSON for websites

1 participant