Skip to content

Comments

feat: emit workflow events for price lists, promotions, and campaigns…#14722

Open
p-stalega wants to merge 2 commits intomedusajs:developfrom
p-stalega:feat/price-list-promotion-campaign-workflow-events
Open

feat: emit workflow events for price lists, promotions, and campaigns…#14722
p-stalega wants to merge 2 commits intomedusajs:developfrom
p-stalega:feat/price-list-promotion-campaign-workflow-events

Conversation

@p-stalega
Copy link

@p-stalega p-stalega commented Feb 7, 2026

… (Omnibus)

Summary

What — What changes are introduced in this PR?

This PR adds workflow events for price lists, promotions, and campaigns so subscribers can react to these changes.

Concretely:

  • Price lists: price-list.created, price-list.updated, price-list.deleted, price-list-prices.batch-updated
  • Promotions: promotion.created, promotion.updated, promotion.deleted, promotion.status-updated, promotion-rules.batch-updated
  • Campaigns: campaign.created, campaign.updated, campaign.deleted, campaign.promotions-updated

New event constants are added in @medusajs/utils (PriceListWorkflowEvents, PromotionWorkflowEvents, CampaignWorkflowEvents), and the existing create/update/delete/batch workflows in @medusajs/core-flows call emitEventStep so these events are emitted. No new API surface or breaking changes.

Why — Why are these changes relevant or necessary?

The EU Omnibus Directive requires showing the lowest price applied in the 30 days before a current reduction when displaying a discount. To support that, storefronts and packages need to know when prices and promotions/campaigns change. Without workflow events for these operations, there is no supported, event-driven way to maintain price history and discount applicability. These events allow subscribers (e.g. Omnibus-oriented packages) to react to changes and stay in sync with Medusa’s pricing and promotion state.

How — How have these changes been implemented?

  • packages/core/utils/src/core-flows/events.ts

New constants with JSDoc and @eventPayload in the same style as existing workflow events (e.g. CartWorkflowEvents, SalesChannelWorkflowEvents).

  • packages/core/core-flows

In the relevant workflows we:

  • Use transform() to build the payload (e.g. [{ id: pl.id }] or { price_list_id, created, updated, deleted }).
  • Call emitEventStep({ eventName: ..., data: ... }) after the main step(s), following the same pattern as other workflows (e.g. sales channel, translation).

Workflows touched: create/update/delete price lists, batch price list prices; create/update/delete promotions, update promotion status, batch promotion rules; create/update/delete campaigns, add-or-remove campaign promotions.

Testing — How have these changes been tested, or how can the reviewer test the feature?

  • Existing unit and integration tests for the affected workflows were run; no regressions.
  • No new tests were added for event emission, to stay consistent with the rest of the repo (workflow events are not asserted in API-level integration tests; only the auth password-reset event is tested that way).
  • How to verify: Run the app, subscribe to one of the new events (e.g. price-list.created), perform the corresponding Admin API action (e.g. create a price list), and confirm the subscriber receives the event with the expected payload (e.g. { id: "<price_list_id>" }).

Examples

Subscribing to the new events in a Medusa subscriber:

// src/subscribers/omnibus.ts
import { PriceListWorkflowEvents, PromotionWorkflowEvents } from "@medusajs/framework/utils"

export default function omnibusSubscriber({ eventBusService }) {
  eventBusService.subscribe(PriceListWorkflowEvents.CREATED, async (event) => {
    const { id } = event.data
    // e.g. fetch price list and write to price history for "lowest in 30 days"
  })

  eventBusService.subscribe(PriceListWorkflowEvents.PRICES_BATCH_UPDATED, async (event) => {
    const { price_list_id, created, updated, deleted } = event.data
    // update price history for this price list
  })

  eventBusService.subscribe(PromotionWorkflowEvents.UPDATED, async (event) => {
    const { id } = event.data
    // refresh promotion/campaign applicability for Omnibus
  })
}

Payload shapes (as in JSDoc):

  • Lifecycle events: { id: string } per entity.
  • price-list-prices.batch-updated: { price_list_id, created, updated, deleted }.
  • promotion-rules.batch-updated: { promotion_id, rule_type, created, updated, deleted }.
  • campaign.promotions-updated: { campaign_id, add, remove }.

Checklist

Please ensure the following before requesting a review:

  • [ x] I have added a changeset for this PR
    • Every non-breaking change should be marked as a patch
    • To add a changeset, run yarn changeset and follow the prompts
  • The changes are covered by relevant tests
  • [x ] I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

I implemented the changes in this PR as a local patch and built a separate package on top of these workflow events (Omnibus compliance). I plan to release that package to the community once this PR is merged upstream.


Note

Medium Risk
Adds new event emissions across multiple pricing/promotion workflows; risk is mainly around unintended extra event traffic or payload/ordering assumptions for subscribers, but core business logic remains largely unchanged.

Overview
Adds new workflow event constants in packages/core/utils/src/core-flows/events.ts for price lists, promotions, and campaigns (including batch-update style events for price list prices and promotion rules, plus campaign promotion link updates).

Updates the corresponding @medusajs/core-flows create/update/delete (and related) workflows to call emitEventStep with transformed payloads (typically { id } arrays or a batch summary object), so external subscribers can react to pricing/promotion state changes.

Includes a changeset bumping @medusajs/utils and @medusajs/core-flows as patch releases.

Written by Cursor Bugbot for commit 617a00b. This will update automatically on new commits. Configure here.

@p-stalega p-stalega requested a review from a team as a code owner February 7, 2026 14:30
@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 617a00b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 76 packages
Name Type
@medusajs/utils Patch
@medusajs/core-flows Patch
@medusajs/event-bus-redis Patch
@medusajs/framework Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/workflows-sdk Patch
@medusajs/cli Patch
@medusajs/medusa-oas-cli Patch
integration-tests-http Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/event-bus-local Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/js-sdk Patch
@medusajs/types Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Feb 7, 2026

@p-stalega is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

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