Create Product Controller
products/providers/create_product_provider.dart
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
- setTitle / setDescription / setImageFiles / pickCategory mutate state.
- addOption / addOptionValue / removeOption rebuild the variants matrix.
- submit: uploadPublicFile per image → createPhysicalProduct → assignInventoryItemLocations + setInventoryItemQuantity per variant.
- 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.