diff --git a/app/code/Magento/InventoryCatalog/Api/DefaultSourceProviderInterface.php b/app/code/Magento/InventoryCatalog/Api/DefaultSourceProviderInterface.php new file mode 100644 index 000000000000..47d798dccaf5 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Api/DefaultSourceProviderInterface.php @@ -0,0 +1,22 @@ +sourceRepository = $sourceRepository; $this->sourceFactory = $sourceFactory; @@ -75,6 +91,8 @@ public function __construct( $this->stockFactory = $stockFactory; $this->assignSourcesToStock = $assignSourcesToStock; $this->dataObjectHelper = $dataObjectHelper; + $this->defaultSourceProvider = $defaultSourceProvider; + $this->defaultStockProvider = $defaultStockProvider; } /** @@ -96,7 +114,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface private function addDefaultSource() { $data = [ - SourceInterface::SOURCE_ID => 1, + SourceInterface::SOURCE_ID => $this->defaultSourceProvider->getId(), SourceInterface::NAME => 'Default Source', SourceInterface::ENABLED => 1, SourceInterface::DESCRIPTION => 'Default Source', @@ -119,7 +137,7 @@ private function addDefaultSource() private function addDefaultStock() { $data = [ - StockInterface::STOCK_ID => 1, + StockInterface::STOCK_ID => $this->defaultStockProvider->getId(), StockInterface::NAME => 'Default Stock' ]; $source = $this->stockFactory->create(); @@ -134,6 +152,9 @@ private function addDefaultStock() */ private function assignStockToSource() { - $this->assignSourcesToStock->execute([1], 1); + $this->assignSourcesToStock->execute( + [$this->defaultSourceProvider->getId()], + $this->defaultStockProvider->getId() + ); } } diff --git a/app/code/Magento/InventoryCatalog/etc/di.xml b/app/code/Magento/InventoryCatalog/etc/di.xml new file mode 100644 index 000000000000..fcead55d99ca --- /dev/null +++ b/app/code/Magento/InventoryCatalog/etc/di.xml @@ -0,0 +1,11 @@ + + + + + +