Skip to content

feat(core-flows,medusa,dashboard,js-sdk,types): add inventory item export - #16223

Merged
kodiakhq[bot] merged 10 commits into
developfrom
feat/inventory-items-export
Jul 28, 2026
Merged

feat(core-flows,medusa,dashboard,js-sdk,types): add inventory item export#16223
kodiakhq[bot] merged 10 commits into
developfrom
feat/inventory-items-export

Conversation

@srindom

@srindom srindom commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

What — What changes are introduced in this PR?

Adds an export feature for inventory items:

  • An Export button on the admin inventory list page (both the default table and the view_configurations table) that opens a drawer, shows the currently applied filters read-only, and kicks off the export.
  • POST /admin/inventory-items/export — accepts the same query filters as the list endpoint, starts the workflow, and responds 202 with a transaction_id.
  • exportInventoryItemsWorkflow in core-flows — runs the export step async in the background, streams the CSV to the File Module, and delivers the download link via a feed notification (failure notification via compensation).
  • The exported CSV contains one row per inventory item with the item's details and total quantities, plus stocked, reserved, and available quantities per stock location (e.g. Location [European Warehouse] Stocked Quantity) — not just the aggregate.
  • The export fans out to one row per variant-item connection: each row includes the linked variant's id, title, barcode, EAN, and UPC (Variant Barcode/Variant Ean/Variant Upc, resolved through the variant-inventory module link). Items shared by multiple variants get one row per variant; items without a linked variant get a single row with empty variant columns.
  • sdk.admin.inventoryItem.export() in the JS SDK and a useExportInventoryItems hook in the dashboard.

Why — Why are these changes relevant or necessary?

Products already support CSV export, but there was no way to export inventory. Merchants managing stock across multiple locations need the per-location breakdown, which the list view only shows as an aggregate.

How — How have these changes been implemented?

The implementation mirrors the existing product export end-to-end (route drawer → 202 + long-running workflow → file upload → feed notification). The export step pages through Query in batches of 50 and streams to the file module with backpressure handling. Stock locations are fetched upfront and sorted by name so the per-location columns are stable across all rows and batches; items without a level at a location get empty cells (distinguishing "no level" from 0). Level quantities are normalized through the BigNumber utility since Query can return raw big-number instances.

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

  • New HTTP integration tests in integration-tests/http/__tests__/inventory/admin/inventory-export.spec.ts covering: per-location columns for items stocked in multiple locations, export filtered by inventory item id, and export filtered by location.
  • Verified manually in a local project: triggered the export from the inventory list UI, received the feed notification, and downloaded the CSV.

Examples

// JS SDK
sdk.admin.inventoryItem.export({}, { location_levels: { location_id: "sloc_123" } })
  .then(({ transaction_id }) => console.log(transaction_id))

Resulting CSV columns:

Item Id, Item Sku, Item Title, ..., Variant Id, Variant Title, Variant Barcode, Variant Ean, Variant Upc, ..., Item Reserved Quantity, Item Stocked Quantity,
Location [European Warehouse] Stocked Quantity, Location [European Warehouse] Reserved Quantity, Location [European Warehouse] Available Quantity,
Location [US Warehouse] Stocked Quantity, ...

Checklist

  • I have added a changeset for this PR
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

The export intentionally omits incoming_quantity from the per-location columns.

🤖 Generated with Claude Code

…port

Adds an export feature for inventory items, mirroring the existing product
export. The exported CSV contains one row per inventory item with its total
quantities plus stocked, reserved, and available quantities per stock
location.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@srindom
srindom requested a review from a team as a code owner July 28, 2026 12:10
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 24c5e81

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

This PR includes changesets to release 79 packages
Name Type
@medusajs/core-flows Patch
@medusajs/dashboard Patch
@medusajs/js-sdk Patch
@medusajs/medusa Patch
@medusajs/types Patch
@medusajs/test-utils Patch
integration-tests-http Patch
@medusajs/draft-order Patch
@medusajs/loyalty-plugin Patch
@medusajs/admin-bundler Patch
@medusajs/medusa-oas-cli Patch
@medusajs/event-bus-redis Patch
@medusajs/framework Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer 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/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local 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/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin Patch
@medusajs/telemetry Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app 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

srindom and others added 4 commits July 28, 2026 14:36
… and drop incoming quantity

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Renames the barcode columns to Variant Barcode/Ean/Upc and creates one CSV
row per variant-item connection. Items without a linked variant keep a
single row with empty variant columns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-cloud af75e00 Commit Preview URL

Branch Preview URL
Jul 28 2026, 01:56 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-book af75e00 Commit Preview URL

Branch Preview URL
Jul 28 2026, 01:57 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 28, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-resources af75e00 Commit Preview URL

Branch Preview URL
Jul 28 2026, 01:59 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants