Skip to content

feat: store-scoped enrichment with locale-aware system prompts (#12)#62

Open
DavidLambauer wants to merge 9 commits intomage-os-lab:mainfrom
DavidLambauer:feature/phase2-multistore-locale-v2
Open

feat: store-scoped enrichment with locale-aware system prompts (#12)#62
DavidLambauer wants to merge 9 commits intomage-os-lab:mainfrom
DavidLambauer:feature/phase2-multistore-locale-v2

Conversation

@DavidLambauer
Copy link
Copy Markdown
Contributor

Summary

Fixes #12. Supersedes #53 (which was the Phase 2 bundle of locale + enrichment-flags; Ryan's #51 already covers the flags half, so this PR is just the locale half, cleanly rebased onto the post-merge main).

The enrichment pipeline now carries store context end-to-end, and the AI is automatically instructed to reply in the store's language.

Changes

Store context plumbing:

  • Request DTO gains a storeId field (defaults to 0 for backward compatibility with in-flight queue messages)
  • Publisher::execute accepts and passes storeId to queue messages
  • Consumer sets the correct store scope via StoreManager::setCurrentStore before loading the product
  • SaveAfter observer forwards the product's store ID to the publisher
  • MassEnrich controller forwards the current admin store scope

Locale-aware system prompt:

  • Config::getSystemPrompt() now queries with SCOPE_STORE, reads general/locale/code, and prepends "Respond in {Language}. " for non-English locales
  • Ships a LOCALE_LANGUAGE_MAP covering 46 ISO language codes
  • English locales get the prompt unchanged; unknown locales fall through silently

Module sequence: added Magento_Store so DI resolution is ordered correctly.

Test plan

  • Unit tests: 152 tests, 319 assertions, green on PHP 8.2/8.3/8.4 (via CI)
  • On a non-English store (e.g., fr_FR), enrich a product: AI output should be in French
  • On an English store, enrich a product: behavior identical to before
  • Mass enrich from admin grid: products inherit the current admin store scope in the queue message
  • Async mode: queue worker picks up the message, sets store scope before saving the product, output is correctly scoped

What changed vs the original #53

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] Translate open ai output based on locale of selected store scope

1 participant