arch-atlas

Create Product Controller

products/providers/create_product_provider.dart

domain

Overview

Holds the form state and runs the multi-call submit: upload images via VendorService.uploadPublicFile, build the create payload, POST /vendor/products, then attach the inventory rows via setInventoryItemQuantity + assignInventoryItemLocations + addProductLocation.

User Flow

  1. setTitle / setDescription / setImageFiles / pickCategory mutate state.
  2. addOption / addOptionValue / removeOption rebuild the variants matrix.
  3. submit: uploadPublicFile per image → createPhysicalProduct → assignInventoryItemLocations + setInventoryItemQuantity per variant.
  4. Errors short-circuit and surface in state.submitError.

Cases & Edge Cases

  • Image upload is sequential — parallelizing would speed up but the backend rate-limits /vendor/files.
  • Variant inventory is set as an after-creation step; if it fails, the product exists but with 0 stock.
  • Currency is per-product (not per-variant) — Medusa supports per-variant but the UI simplifies.

Code References

  • lib/src/features/seller/products/providers/create_product_provider.dart
  • lib/src/core/services/vendor_service.dart:230 // createPhysicalProduct
  • lib/src/core/services/vendor_service.dart:403 // assignInventoryItemLocations
  • lib/src/core/services/vendor_service.dart:423 // setInventoryItemQuantity

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

Same multi-call pattern as the provision wizard — if you change one, evaluate the other for consistency.