-
Notifications
You must be signed in to change notification settings - Fork 248
The Concept of Default Source and Domain Driven Design
Installing Magento 2 with Multi-Source Inventory on board should introduce neither performance nor usability difficulties for Magento Merchants and Administrators.
That's why we still should support existing admin UI for product configuration where there is the only field Quantity, which does not expose a knowledge about physical Sources used under the hood. The main goal is to prevent from overwhelming Admin UI with different Source options for those merchants who have the only Source and not going to use Multi-Source possibilities.
But introducing the Default as a Role for Sources, which leads to adding isDefault attribute to SourceInterface, will violate Domain Driven Design (DDD) principles because there is no such Business Concept in Inventory Domain as Default Source.
The Default Source is a part of Catalog Bounded Context, but not Inventory One. It is Magento Catalog wants to add a "special case" for installations with single source/stock to simplify Admin UI for those merchants. Thus, Inventory bounded context (read Inventory module and APIs declared as a part of its Service Contracts) should be agnostic to the Default Role Concept.
Thus, what we end up with.
As Inventory can't add awareness about Default Role of the Source. This business invariant should be added to the Catalog bounded context (but not to the Catalog module as it's demanded to prevent a formation of God-modules). Thus, it's recommended to introduce a dedicated module - InventoryCatalog where this logic would be placed. Doing so - both Domain Logic and Modularity would be respected.
There are two possible ways of adding this Business Rule in Magento 2:
- Adding Extension Attribute (isDefault) for
SourceInterface
from InventoryCatalog module. - Introduce dedicated Services
getDefaultSource()
andsetDefaultSource(int $sourceId)
It's proposed to go with option 2 to make APIs more operation/command oriented.
GitHub Story Label for current Story is "Default Source Concept" Thus, you can find all the tickets related to the story following Story Label
Multi-Source Inventory developed by Magento 2 Community
- Technical Vision. Catalog Inventory
- Installation Guide
- List of Inventory APIs and their legacy analogs
- MSI Roadmap
- Known Issues in Order Lifecycle
- MSI User Guide
- 2.3 LIVE User Guide
- MSI Release Notes and Installation
- Overview
- Get Started with MSI
- MSI features and processes
- Global and Product Settings
- Configure Source Selection Algorithm
- Create Sources
- Create Stock
- Assign Inventory and Product Notifications
- Configure MSI backorders
- MSI Import and Export Product Data
- Mass Action Tool
- Shipment and Order Management
- CLI reference
- Reports and MSI
- MSI FAQs
- DevDocs Documentation
- Manage Inventory Management Modules (install/upgrade info)
- Inventory Management
- Reservations
- Inventory CLI reference
- Inventory API reference
- Inventory In-Store Pickup API reference
- Order Processing with Inventory Management
- Managing sources
- Managing stocks
- Link and unlink stocks and sources
- Manage source items
- Perform bulk actions
- Manage Low-Quantity Notifications
- Check salable quantities
- Manage source selection algorithms
- User Stories
- Support of Store Pickup for MSI
- Product list assignment per Source
- Source assignment per Product
- Stocks to Sales Channel Mapping
- Adapt Product Import/Export to support multi Sourcing
- Introduce SourceCode attribute for Source and SourceItem entities
- Assign Source Selector for Processing of Returns Credit Memo
- User Scenarios:
- Technical Designs:
- Module Structure in MSI
- When should an interface go into the Model directory and when should it go in the Api directory?
- Source and Stock Item configuration Design and DB structure
- Stock and Source Configuration design
- Open Technical Questions
- Inconsistent saving of Stock Data
- Source API
- Source WebAPI
- Sources to Sales Channels mapping
- Service Contracts MSI
- Salable Quantity Calculation and Mechanism of Reservations
- StockItem indexation
- Web API and How To cover them with Functional Testing
- Source Selection Algorithms
- Validation of Domain Entities
- PHP 7 Syntax usage for Magento contribution
- The first step towards pre generated IDs. And how this will improve your Integration tests
- The Concept of Default Source and Domain Driven Design
- Extension Point of Product Import/Export
- Source Selection Algorithm
- SourceItem Entity Extension
- Design Document for changing SerializerInterface
- Stock Management for Order Cancelation
- Admin UI
- MFTF Extension Tests
- Weekly MSI Demos
- Tutorials