Skip to content

feat: bulk generation for product descriptions (P0 #2)#9

Merged
roboshyim merged 1 commit into
mainfrom
feat/bulk-generation
Jul 21, 2026
Merged

feat: bulk generation for product descriptions (P0 #2)#9
roboshyim merged 1 commit into
mainfrom
feat/bulk-generation

Conversation

@roboshyim

Copy link
Copy Markdown
Collaborator

What

Adds queue-based bulk generation of product descriptions — P0 roadmap item #2, the final P0 item. Generates descriptions for many products at once via Shopware's message bus, reusing ProductDescriptionGenerator. This is the feature merchants ask for most (single-product modals don't scale to catalogs).

How it works

  1. POST /api/_action/frosh-ai/product/bulk-generate with {productIds, tone?, language?, maxWords?} → gates master + FeatureId::BulkGeneration + provider availability → creates a frosh_ai_bulk_job row (status queued) → dispatches BulkGenerateMessage onto the message bus → returns {jobId, total}.
  2. BulkGenerateHandler (async) processes each product: loads it, calls ProductDescriptionGenerator, writes the description back via product.repository update, and persists progress (processed/succeeded/failed/errors) after every item. Per-item try/catch means one bad product never kills the batch.
  3. GET /api/_action/frosh-ai/bulk-job/{jobId} returns live status + counts + errors.

Changes

  • frosh_ai_bulk_job DAL entity (src/Entity/BulkJob/): Definition + Entity + Collection, all ApiAware, mirrors UsageLog pattern. Fields: type, status, total/processed/succeeded/failed, entityIds/errors/context (JSON).
  • Migration Migration1783887000CreateBulkJob — creates the table (BINARY id PK, JSON cols, indexes on status + created_at).
  • BulkGenerateMessage (implements Shopware AsyncMessageInterface) + BulkGenerateHandler (#[AsMessageHandler], autoconfigured like CleanupUsageLogsHandler).
  • BulkGenerateController (enqueue + status endpoints).
  • FeatureId::BulkGeneration + featureBulkGeneration config checkbox (en + de-DE).

Tests

BulkGenerateHandlerTest (3 tests): full success (writes descriptions, marks completed), partial failure (error recorded, job still completes), missing job skipped. Updated FeatureFlagsTest (8→9 flags).

116 tests / 461 assertions, green — locally and in the frosh-ai-dev container (Shopware 6.7 / PHP 8.3).

Notes

Admin UI (a "bulk generate" action on the product grid + a progress modal polling the status endpoint) is a deliberate follow-up — this lands the engine + API + flag + tests. Requires a running message-queue worker (bin/console messenger:consume async) as with any Shopware async task.

- BulkJob DAL entity (frosh_ai_bulk_job) + migration
- BulkGenerateMessage (AsyncMessageInterface) + BulkGenerateHandler
- POST /api/_action/frosh-ai/product/bulk-generate + GET /api/_action/frosh-ai/bulk-job/{jobId}
- FeatureId::BulkGeneration + featureBulkGeneration config flag (en/de)
- Unit tests for handler (success, partial failure, missing job)
@roboshyim
roboshyim merged commit 1357a77 into main Jul 21, 2026
2 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