From eba40e40f7487dd06dfecc1fbc77dbec908b1180 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 16 Jan 2018 11:10:10 +0200 Subject: [PATCH 01/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- ...dStockStatusToProductsMultistockPlugin.php | 93 +++++++++ ...ckStatusToProductsMultistockPluginTest.php | 178 ++++++++++++++++++ .../InventoryCatalog/etc/frontend/di.xml | 13 ++ .../InventorySalesApi/Test/_files/stores.php | 32 ++++ .../Test/_files/stores_rollback.php | 28 +++ 5 files changed, 344 insertions(+) create mode 100644 app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php create mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php create mode 100644 app/code/Magento/InventoryCatalog/etc/frontend/di.xml create mode 100644 app/code/Magento/InventorySalesApi/Test/_files/stores.php create mode 100644 app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php new file mode 100644 index 000000000000..ad330ea4a084 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php @@ -0,0 +1,93 @@ +stockResolver = $stockResolver; + $this->storeManager = $storeManager; + $this->isProductInStockInterface = $isProductInStockInterface; + } + + /** + * Around plugin for Magento\CatalogInventory\Helper::addStockStatusToProducts. + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @param Helper $subject + * @param callable $proceed + * @param AbstractCollection $productCollection + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function aroundAddStockStatusToProducts( + Helper $subject, + callable $proceed, + AbstractCollection $productCollection + ) { + // We need it to not prevent the execution of all the plugins next in the chain. + $proceed($productCollection); + $this->addStockStatusToProducts($productCollection); + } + + /** + * Assign stock status information to products for MSI. + * + * @param AbstractCollection $productCollection + * + * @throws \Magento\Framework\Exception\LocalizedException + */ + private function addStockStatusToProducts(AbstractCollection $productCollection) + { + /** @var WebsiteInterface $website */ + $website = $this->storeManager->getWebsite(); + /** @var StockInterface $stock */ + $stock = $this->stockResolver->get(SalesChannelInterface::TYPE_WEBSITE, $website->getCode()); + /** @var Product $product */ + foreach ($productCollection as $product) { + $status = (int)$this->isProductInStockInterface->execute($product->getSku(), (int)$stock->getStockId()); + $product->setIsSalable($status); + } + } +} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php new file mode 100644 index 000000000000..6d0893a1936b --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php @@ -0,0 +1,178 @@ +addStockStatusToProducts($productsData); + } + + /** + * Tests AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts for multiple stocks. + * + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stores.php + * @dataProvider addStockStatusToProductsMultiSourceDataProvider + * @param string $storeCode + * @param array $productsData + */ + public function testAddStockStatusToProductsMultiSource(string $storeCode, array $productsData) + { + $this->storeManager->setCurrentStore($storeCode); + $this->addStockStatusToProducts($productsData); + } + + /** + * Base test for AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts. + * + * @param array $productsData + */ + private function addStockStatusToProducts(array $productsData) + { + $this->indexer->reindexAll(); + $this->productCollection->clear(); + foreach ($productsData as $productData) { + $product = $this->productRepository->get($productData['sku']); + $this->productCollection->addItem($product); + } + $this->helper->addStockStatusToProducts($this->productCollection); + foreach ($productsData as $productData) { + /** @var ProductInterface $product */ + $product = $this->productRepository->get($productData['sku']); + $actual = $product->isSalable(); + self::assertEquals( + $productData['expected'], + $actual + ); + } + } + + /** + * Data provider for testAddStockStatusToProductsSingleSource. + * + * @return array + */ + public function addStockStatusToProductsSingleSourceDataProvider() + { + return [ + [ + [ + ['sku' => 'SKU-1', 'expected' => 1], + ['sku' => 'SKU-2', 'expected' => 1], + ['sku' => 'SKU-3', 'expected' => 0], + ], + ], + ]; + } + + /** + * Data provider for testAddStockStatusToProductsMultiSource. + * + * @return array + */ + public function addStockStatusToProductsMultiSourceDataProvider() + { + return [ + [ + 'eu_store', + [ + ['sku' => 'SKU-1', 'expected' => 1], + ['sku' => 'SKU-2', 'expected' => 0], + ['sku' => 'SKU-3', 'expected' => 0], + ], + ], + [ + 'us_store', + [ + ['sku' => 'SKU-1', 'expected' => 0], + ['sku' => 'SKU-2', 'expected' => 1], + ['sku' => 'SKU-3', 'expected' => 0], + ], + ], + [ + 'global_store', + [ + ['sku' => 'SKU-1', 'expected' => 0], + ['sku' => 'SKU-2', 'expected' => 0], + ['sku' => 'SKU-3', 'expected' => 0], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->helper = Bootstrap::getObjectManager()->get(Helper::class); + $this->indexer = Bootstrap::getObjectManager()->create(IndexerInterface::class); + $this->indexer->load(StockIndexer::INDEXER_ID); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productCollection = Bootstrap::getObjectManager()->create(ProductCollection::class); + } +} diff --git a/app/code/Magento/InventoryCatalog/etc/frontend/di.xml b/app/code/Magento/InventoryCatalog/etc/frontend/di.xml new file mode 100644 index 000000000000..7a56f32b50bc --- /dev/null +++ b/app/code/Magento/InventoryCatalog/etc/frontend/di.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stores.php b/app/code/Magento/InventorySalesApi/Test/_files/stores.php new file mode 100644 index 000000000000..003e32cc90e0 --- /dev/null +++ b/app/code/Magento/InventorySalesApi/Test/_files/stores.php @@ -0,0 +1,32 @@ +create(Store::class); + $website = Bootstrap::getObjectManager()->create(Website::class); + $website->load($websiteCode); + $store->setData( + [ + 'code' => $storeCode, + 'website_id' => $website->getId(), + 'group_id' => '1', + 'name' => $storeCode, + 'sort_order' => '0', + 'is_active' => '1', + ] + ); + $store->save(); +} +Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->reinitStores(); diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php b/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php new file mode 100644 index 000000000000..995beafb9b05 --- /dev/null +++ b/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php @@ -0,0 +1,28 @@ +get(Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$storeCodes = ['eu_store', 'us_store', 'global_store']; + +foreach ($storeCodes as $storeCode) { + /** @var store $store */ + $store = Bootstrap::getObjectManager()->create(Store::class); + $store->load($storeCode); + $store->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From a66c80ddc67b5e6520862f553ed43878b2d109d6 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 16 Jan 2018 13:13:08 +0200 Subject: [PATCH 02/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- app/code/Magento/InventoryCatalog/composer.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/InventoryCatalog/composer.json b/app/code/Magento/InventoryCatalog/composer.json index 48270bf1b128..d563d1094629 100644 --- a/app/code/Magento/InventoryCatalog/composer.json +++ b/app/code/Magento/InventoryCatalog/composer.json @@ -8,6 +8,8 @@ "magento/module-catalog-inventory": "100.3.*", "magento/module-inventory": "100.0.*", "magento/module-inventory-api": "100.0.*", + "magento/module-inventory-sales-api": "100.0.*", + "magento/module-store": "100.3.*", "magento/module-ui": "100.0.*" }, "type": "magento2-module", From 564799d88eae0d34391879f928928ea6d270ddea Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 16 Jan 2018 15:38:52 +0200 Subject: [PATCH 03/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- .../AddStockStatusToProductsMultistockPlugin.php | 5 +++-- .../AddStockStatusToProductsMultistockPluginTest.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php index ad330ea4a084..0547256918e7 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php @@ -66,8 +66,9 @@ public function aroundAddStockStatusToProducts( callable $proceed, AbstractCollection $productCollection ) { - // We need it to not prevent the execution of all the plugins next in the chain. - $proceed($productCollection); + // We need to prevent the collection modification by plugins next in the chain. + $temporaryCollection = clone $productCollection; + $proceed($temporaryCollection); $this->addStockStatusToProducts($productCollection); } diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php index 6d0893a1936b..80cdeafaa82d 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php @@ -94,6 +94,8 @@ private function addStockStatusToProducts(array $productsData) { $this->indexer->reindexAll(); $this->productCollection->clear(); + $this->productCollection->addFieldToFilter('sku', ['in' => null]); + $this->productCollection->load(); foreach ($productsData as $productData) { $product = $this->productRepository->get($productData['sku']); $this->productCollection->addItem($product); From f41f682af970f9bf96c601a891b063625bf5e2a2 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 16 Jan 2018 16:27:35 +0200 Subject: [PATCH 04/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- .../AddStockStatusToProductsMultistockPluginTest.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/code/Magento/InventoryCatalog/Test/Integration/{ => Plugin/CatalogInventory}/AddStockStatusToProductsMultistockPluginTest.php (100%) diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php similarity index 100% rename from app/code/Magento/InventoryCatalog/Test/Integration/AddStockStatusToProductsMultistockPluginTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php From 845e1d9ceaad6e98127f0807c7216b47d5efcdca Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Wed, 17 Jan 2018 11:23:45 +0200 Subject: [PATCH 05/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- .../AddStockStatusToProductsMultistockPluginTest.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php index 80cdeafaa82d..96c73eaccf3a 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php @@ -12,7 +12,6 @@ use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; use Magento\CatalogInventory\Helper\Stock as Helper; use Magento\Framework\Indexer\IndexerInterface; -use Magento\Inventory\Indexer\Stock\StockIndexer; use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; @@ -36,11 +35,6 @@ class AddStockStatusToProductsMultistockPluginTest extends TestCase */ private $productRepository; - /** - * @var IndexerInterface - */ - private $indexer; - /** * @var StoreManagerInterface */ @@ -70,8 +64,8 @@ public function testAddStockStatusToProductsSingleSource(array $productsData) * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stores.php @@ -92,7 +86,6 @@ public function testAddStockStatusToProductsMultiSource(string $storeCode, array */ private function addStockStatusToProducts(array $productsData) { - $this->indexer->reindexAll(); $this->productCollection->clear(); $this->productCollection->addFieldToFilter('sku', ['in' => null]); $this->productCollection->load(); @@ -171,8 +164,6 @@ public function addStockStatusToProductsMultiSourceDataProvider() protected function setUp() { $this->helper = Bootstrap::getObjectManager()->get(Helper::class); - $this->indexer = Bootstrap::getObjectManager()->create(IndexerInterface::class); - $this->indexer->load(StockIndexer::INDEXER_ID); $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); $this->productCollection = Bootstrap::getObjectManager()->create(ProductCollection::class); From 42e337152857b37750b6da865ee8618b8804fe99 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Wed, 17 Jan 2018 11:55:06 +0200 Subject: [PATCH 06/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- .../AddStockStatusToProductsMultistockPlugin.php | 2 +- .../AddStockStatusToProductsMultistockPluginTest.php | 2 +- app/code/Magento/InventoryCatalog/etc/frontend/di.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/{ => StockHelper}/AddStockStatusToProductsMultistockPlugin.php (97%) rename app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/{ => StockHelper}/AddStockStatusToProductsMultistockPluginTest.php (99%) diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php similarity index 97% rename from app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php rename to app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php index 0547256918e7..6b12da2677f8 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPlugin.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Plugin\CatalogInventory; +namespace Magento\InventoryCatalog\Plugin\CatalogInventory\StockHelper; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection; diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php similarity index 99% rename from app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php index 96c73eaccf3a..91ffc25224d8 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/AddStockStatusToProductsMultistockPluginTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Plugin\CatalogInventory; +namespace Magento\InventoryCatalog\Test\Integration\Plugin\CatalogInventory\StockHelper; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; diff --git a/app/code/Magento/InventoryCatalog/etc/frontend/di.xml b/app/code/Magento/InventoryCatalog/etc/frontend/di.xml index 7a56f32b50bc..c8cb83e7af5f 100644 --- a/app/code/Magento/InventoryCatalog/etc/frontend/di.xml +++ b/app/code/Magento/InventoryCatalog/etc/frontend/di.xml @@ -8,6 +8,6 @@ + type="Magento\InventoryCatalog\Plugin\CatalogInventory\StockHelper\AddStockStatusToProductsMultistockPlugin"/> From 8694b3d2e6f50a7a3ca1bf36d15695a0e98cb178 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Fri, 19 Jan 2018 10:38:50 +0200 Subject: [PATCH 07/15] 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- .../StockHelper/AddStockStatusToProductsMultistockPlugin.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php index 6b12da2677f8..95c3c56958a8 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php @@ -66,9 +66,7 @@ public function aroundAddStockStatusToProducts( callable $proceed, AbstractCollection $productCollection ) { - // We need to prevent the collection modification by plugins next in the chain. - $temporaryCollection = clone $productCollection; - $proceed($temporaryCollection); + $proceed($productCollection); $this->addStockStatusToProducts($productCollection); } From 5359a86755ec7198980f5b05582cfe7e28bd78d5 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 23 Jan 2018 16:52:42 +0200 Subject: [PATCH 08/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts`. --- ...ckStatusToProductsMultistockPluginTest.php | 44 +++++++++++++------ .../InventorySalesApi/Test/_files/stores.php | 32 -------------- .../Test/_files/stores_rollback.php | 28 ------------ 3 files changed, 31 insertions(+), 73 deletions(-) delete mode 100644 app/code/Magento/InventorySalesApi/Test/_files/stores.php delete mode 100644 app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php index 91ffc25224d8..cb23f44faaff 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php @@ -11,7 +11,6 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; use Magento\CatalogInventory\Helper\Stock as Helper; -use Magento\Framework\Indexer\IndexerInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; @@ -45,6 +44,25 @@ class AddStockStatusToProductsMultistockPluginTest extends TestCase */ private $productCollection; + /** + * @var string + */ + private $storeCodeBefore; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->helper = Bootstrap::getObjectManager()->get(Helper::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productCollection = Bootstrap::getObjectManager()->create(ProductCollection::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + + parent::setUp(); + } + /** * Tests AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts for single stock. * @@ -66,9 +84,8 @@ public function testAddStockStatusToProductsSingleSource(array $productsData) * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stores.php * @dataProvider addStockStatusToProductsMultiSourceDataProvider * @param string $storeCode * @param array $productsData @@ -132,7 +149,7 @@ public function addStockStatusToProductsMultiSourceDataProvider() { return [ [ - 'eu_store', + 'store_for_eu_website', [ ['sku' => 'SKU-1', 'expected' => 1], ['sku' => 'SKU-2', 'expected' => 0], @@ -140,7 +157,7 @@ public function addStockStatusToProductsMultiSourceDataProvider() ], ], [ - 'us_store', + 'store_for_us_website', [ ['sku' => 'SKU-1', 'expected' => 0], ['sku' => 'SKU-2', 'expected' => 1], @@ -148,10 +165,10 @@ public function addStockStatusToProductsMultiSourceDataProvider() ], ], [ - 'global_store', + 'store_for_global_website', [ - ['sku' => 'SKU-1', 'expected' => 0], - ['sku' => 'SKU-2', 'expected' => 0], + ['sku' => 'SKU-1', 'expected' => 1], + ['sku' => 'SKU-2', 'expected' => 1], ['sku' => 'SKU-3', 'expected' => 0], ], ], @@ -161,11 +178,12 @@ public function addStockStatusToProductsMultiSourceDataProvider() /** * @inheritdoc */ - protected function setUp() + protected function tearDown() { - $this->helper = Bootstrap::getObjectManager()->get(Helper::class); - $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); - $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); - $this->productCollection = Bootstrap::getObjectManager()->create(ProductCollection::class); + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + + parent::tearDown(); } } diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stores.php b/app/code/Magento/InventorySalesApi/Test/_files/stores.php deleted file mode 100644 index 003e32cc90e0..000000000000 --- a/app/code/Magento/InventorySalesApi/Test/_files/stores.php +++ /dev/null @@ -1,32 +0,0 @@ -create(Store::class); - $website = Bootstrap::getObjectManager()->create(Website::class); - $website->load($websiteCode); - $store->setData( - [ - 'code' => $storeCode, - 'website_id' => $website->getId(), - 'group_id' => '1', - 'name' => $storeCode, - 'sort_order' => '0', - 'is_active' => '1', - ] - ); - $store->save(); -} -Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface')->reinitStores(); diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php b/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php deleted file mode 100644 index 995beafb9b05..000000000000 --- a/app/code/Magento/InventorySalesApi/Test/_files/stores_rollback.php +++ /dev/null @@ -1,28 +0,0 @@ -get(Registry::class); - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); - -$storeCodes = ['eu_store', 'us_store', 'global_store']; - -foreach ($storeCodes as $storeCode) { - /** @var store $store */ - $store = Bootstrap::getObjectManager()->create(Store::class); - $store->load($storeCode); - $store->delete(); -} - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); From a59d1c60854f691f8988cb57ebd28dd90dd8e86e Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Wed, 24 Jan 2018 20:00:07 +0200 Subject: [PATCH 09/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../AdaptAddStockStatusToProductsPlugin.php | 64 ++++++ ...> AdaptAddIsInStockFilterToCollection.php} | 12 +- ....php => AdaptAddStockDataToCollection.php} | 12 +- ...ks.php => AdaptAddStockStatusToSelect.php} | 12 +- ...dStockStatusToProductsMultistockPlugin.php | 92 --------- ...tockStatusToProductsOnDefaultStockTest.php | 53 +++++ .../Stock/AddStockStatusToProductsTest.php | 117 +++++++++++ ...kFilterToCollectionOnDefaultStockTest.php} | 4 +- .../AddIsInStockFilterToCollectionTest.php | 8 +- ...ockDataToCollectionOnDefaultStockTest.php} | 4 +- .../Status/AddStockDataToCollectionTest.php | 2 +- ...StockStatusToSelectOnDefaultStockTest.php} | 4 +- .../Status/AddStockStatusToSelectTest.php | 2 +- ...ckStatusToProductsMultistockPluginTest.php | 189 ------------------ app/code/Magento/InventoryCatalog/etc/di.xml | 15 +- .../InventoryCatalog/etc/frontend/di.xml | 13 -- 16 files changed, 273 insertions(+), 330 deletions(-) create mode 100644 app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Helper/Stock/AdaptAddStockStatusToProductsPlugin.php rename app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/{AdaptAddIsInStockFilterToCollectionToMultiStocks.php => AdaptAddIsInStockFilterToCollection.php} (80%) rename app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/{AdaptAddStockDataToCollectionToMultiStocks.php => AdaptAddStockDataToCollection.php} (81%) rename app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/{AdaptAddStockStatusToSelectToMultiStocks.php => AdaptAddStockStatusToSelect.php} (82%) delete mode 100644 app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php create mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php create mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php rename app/code/Magento/InventoryCatalog/Test/Integration/{Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionWithDefaultStockTest.php => CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionOnDefaultStockTest.php} (87%) rename app/code/Magento/InventoryCatalog/Test/Integration/{ => CatalogInventory}/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php (92%) rename app/code/Magento/InventoryCatalog/Test/Integration/{Model/ResourceModel/Stock/Status/AddStockDataToCollectionWithDefaultStockTest.php => CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionOnDefaultStockTest.php} (90%) rename app/code/Magento/InventoryCatalog/Test/Integration/{ => CatalogInventory}/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php (96%) rename app/code/Magento/InventoryCatalog/Test/Integration/{Model/ResourceModel/Stock/Status/AddStockStatusToSelectWithDefaultStockTest.php => CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectOnDefaultStockTest.php} (92%) rename app/code/Magento/InventoryCatalog/Test/Integration/{ => CatalogInventory}/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php (97%) delete mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php delete mode 100644 app/code/Magento/InventoryCatalog/etc/frontend/di.xml diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Helper/Stock/AdaptAddStockStatusToProductsPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Helper/Stock/AdaptAddStockStatusToProductsPlugin.php new file mode 100644 index 000000000000..0d3edf8da2de --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Helper/Stock/AdaptAddStockStatusToProductsPlugin.php @@ -0,0 +1,64 @@ +getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; + $this->isProductInStock = $isProductInStock; + } + + /** + * @param Stock $subject + * @param callable $proceed + * @param AbstractCollection $productCollection + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundAddStockStatusToProducts( + Stock $subject, + callable $proceed, + AbstractCollection $productCollection + ) { + $stockId = $this->getStockIdForCurrentWebsite->execute(); + + /** @var Product $product */ + foreach ($productCollection as $product) { + $isSalable = (int)$this->isProductInStock->execute($product->getSku(), $stockId); + $product->setIsSalable($isSalable); + } + } +} diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollectionToMultiStocks.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollection.php similarity index 80% rename from app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollectionToMultiStocks.php rename to app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollection.php index f53423023b79..b532236f8ef4 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollectionToMultiStocks.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddIsInStockFilterToCollection.php @@ -14,12 +14,12 @@ /** * Adapt adding is in stock filter to collection for multi stocks. */ -class AdaptAddIsInStockFilterToCollectionToMultiStocks +class AdaptAddIsInStockFilterToCollection { /** * @var GetStockIdForCurrentWebsite */ - private $stockIdForCurrentWebsite; + private $getStockIdForCurrentWebsite; /** * @var AddIsInStockFilterToCollection @@ -27,14 +27,14 @@ class AdaptAddIsInStockFilterToCollectionToMultiStocks private $adaptedAddIsInStockFilterToCollection; /** - * @param GetStockIdForCurrentWebsite $stockIdForCurrentWebsite + * @param GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite * @param AddIsInStockFilterToCollection $adaptedAddIsInStockFilterToCollection */ public function __construct( - GetStockIdForCurrentWebsite $stockIdForCurrentWebsite, + GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite, AddIsInStockFilterToCollection $adaptedAddIsInStockFilterToCollection ) { - $this->stockIdForCurrentWebsite = $stockIdForCurrentWebsite; + $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; $this->adaptedAddIsInStockFilterToCollection = $adaptedAddIsInStockFilterToCollection; } @@ -51,7 +51,7 @@ public function aroundAddIsInStockFilterToCollection( callable $proceed, $collection ) { - $stockId = $this->stockIdForCurrentWebsite->execute(); + $stockId = $this->getStockIdForCurrentWebsite->execute(); $this->adaptedAddIsInStockFilterToCollection->addIsInStockFilterToCollection($collection, $stockId); return $stockStatus; diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollectionToMultiStocks.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollection.php similarity index 81% rename from app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollectionToMultiStocks.php rename to app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollection.php index e587fd90f634..ab0856e97bc6 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollectionToMultiStocks.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockDataToCollection.php @@ -15,12 +15,12 @@ /** * Adapt adding stock data to collection for multi stocks. */ -class AdaptAddStockDataToCollectionToMultiStocks +class AdaptAddStockDataToCollection { /** * @var GetStockIdForCurrentWebsite */ - private $stockIdForCurrentWebsite; + private $getStockIdForCurrentWebsite; /** * @var AddStockDataToCollection @@ -28,14 +28,14 @@ class AdaptAddStockDataToCollectionToMultiStocks private $addStockDataToCollection; /** - * @param GetStockIdForCurrentWebsite $stockIdForCurrentWebsite + * @param GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite * @param AddStockDataToCollection $addStockDataToCollection */ public function __construct( - GetStockIdForCurrentWebsite $stockIdForCurrentWebsite, + GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite, AddStockDataToCollection $addStockDataToCollection ) { - $this->stockIdForCurrentWebsite = $stockIdForCurrentWebsite; + $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; $this->addStockDataToCollection = $addStockDataToCollection; } @@ -54,7 +54,7 @@ public function aroundAddStockDataToCollection( $collection, $isFilterInStock ) { - $stockId = $this->stockIdForCurrentWebsite->execute(); + $stockId = $this->getStockIdForCurrentWebsite->execute(); $this->addStockDataToCollection->addStockDataToCollection($collection, (bool)$isFilterInStock, $stockId); return $collection; diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelectToMultiStocks.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelect.php similarity index 82% rename from app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelectToMultiStocks.php rename to app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelect.php index 6b3f50652fff..544b2a491bc7 100644 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelectToMultiStocks.php +++ b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/Model/ResourceModel/Stock/Status/AdaptAddStockStatusToSelect.php @@ -18,12 +18,12 @@ /** * Adapt adding stock status to select for multi stocks. */ -class AdaptAddStockStatusToSelectToMultiStocks +class AdaptAddStockStatusToSelect { /** * @var StockResolverInterface */ - private $stockResolver; + private $getStockIdForCurrentWebsite; /** * @var AddStockStatusToSelect @@ -31,14 +31,14 @@ class AdaptAddStockStatusToSelectToMultiStocks private $adaptedAddStockStatusToSelect; /** - * @param StockResolverInterface $stockResolver + * @param StockResolverInterface $getStockIdForCurrentWebsite * @param AddStockStatusToSelect $adaptedAddStockStatusToSelect */ public function __construct( - StockResolverInterface $stockResolver, + StockResolverInterface $getStockIdForCurrentWebsite, AddStockStatusToSelect $adaptedAddStockStatusToSelect ) { - $this->stockResolver = $stockResolver; + $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; $this->adaptedAddStockStatusToSelect = $adaptedAddStockStatusToSelect; } @@ -62,7 +62,7 @@ public function aroundAddStockStatusToSelect( throw new LocalizedException(__('Website code is empty')); } - $stock = $this->stockResolver->get(SalesChannelInterface::TYPE_WEBSITE, $websiteCode); + $stock = $this->getStockIdForCurrentWebsite->get(SalesChannelInterface::TYPE_WEBSITE, $websiteCode); $stockId = (int)$stock->getStockId(); $this->adaptedAddStockStatusToSelect->addStockStatusToSelect($select, $stockId); diff --git a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php b/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php deleted file mode 100644 index 95c3c56958a8..000000000000 --- a/app/code/Magento/InventoryCatalog/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPlugin.php +++ /dev/null @@ -1,92 +0,0 @@ -stockResolver = $stockResolver; - $this->storeManager = $storeManager; - $this->isProductInStockInterface = $isProductInStockInterface; - } - - /** - * Around plugin for Magento\CatalogInventory\Helper::addStockStatusToProducts. - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @param Helper $subject - * @param callable $proceed - * @param AbstractCollection $productCollection - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function aroundAddStockStatusToProducts( - Helper $subject, - callable $proceed, - AbstractCollection $productCollection - ) { - $proceed($productCollection); - $this->addStockStatusToProducts($productCollection); - } - - /** - * Assign stock status information to products for MSI. - * - * @param AbstractCollection $productCollection - * - * @throws \Magento\Framework\Exception\LocalizedException - */ - private function addStockStatusToProducts(AbstractCollection $productCollection) - { - /** @var WebsiteInterface $website */ - $website = $this->storeManager->getWebsite(); - /** @var StockInterface $stock */ - $stock = $this->stockResolver->get(SalesChannelInterface::TYPE_WEBSITE, $website->getCode()); - /** @var Product $product */ - foreach ($productCollection as $product) { - $status = (int)$this->isProductInStockInterface->execute($product->getSku(), (int)$stock->getStockId()); - $product->setIsSalable($status); - } - } -} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php new file mode 100644 index 000000000000..de1c5f1742ea --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php @@ -0,0 +1,53 @@ +stockHelper = Bootstrap::getObjectManager()->get(Stock::class); + } + + public function testAddStockStatusToProducts() + { + $productsData = [ + 'SKU-1' => 1, + 'SKU-2' => 1, + 'SKU-3' => 0, + ]; + + /** @var Collection $collection */ + $collection = Bootstrap::getObjectManager()->create(Collection::class); + $collection->addFieldToFilter(ProductInterface::SKU, ['in' => array_keys($productsData)]); + $collection->load(); + + $this->stockHelper->addStockStatusToProducts($collection); + + /** @var ProductInterface $product */ + foreach ($collection as $product) { + self::assertEquals($productsData[$product->getSku()], $product->isSalable()); + } + } +} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php new file mode 100644 index 000000000000..6948353e2722 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php @@ -0,0 +1,117 @@ +stockHelper = Bootstrap::getObjectManager()->get(Stock::class); + $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + } + + /** + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @dataProvider addStockStatusToProductsDataProvider + * @param string $storeCode + * @param array $productsData + */ + public function testAddStockStatusToProducts(string $storeCode, array $productsData) + { + $this->storeManager->setCurrentStore($storeCode); + + /** @var Collection $collection */ + $collection = Bootstrap::getObjectManager()->create(Collection::class); + $collection->addFieldToFilter(ProductInterface::SKU, ['in' => array_keys($productsData)]); + $collection->load(); + + $this->stockHelper->addStockStatusToProducts($collection); + + /** @var ProductInterface $product */ + foreach ($collection as $product) { + self::assertEquals($productsData[$product->getSku()], $product->isSalable()); + } + } + + /** + * @return array + */ + public function addStockStatusToProductsDataProvider(): array + { + return [ + 'eu_website' => [ + 'store_for_eu_website', + [ + 'SKU-1' => 1, + 'SKU-2' => 0, + 'SKU-3' => 0, + ], + ], + 'us_website' => [ + 'store_for_us_website', + [ + 'SKU-1' => 0, + 'SKU-2' => 1, + 'SKU-3' => 0, + ], + ], + 'global_website' => [ + 'store_for_global_website', + [ + 'SKU-1' => 1, + 'SKU-2' => 1, + 'SKU-3' => 0, + ], + ], + ]; + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + + parent::tearDown(); + } +} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionWithDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionOnDefaultStockTest.php similarity index 87% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionWithDefaultStockTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionOnDefaultStockTest.php index de569c52c46a..d1a486384f2d 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionWithDefaultStockTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionOnDefaultStockTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; @@ -15,7 +15,7 @@ /** * Test add in in stock filter to collection on default website. */ -class AddIsInStockFilterToCollectionWithDefaultStockTest extends TestCase +class AddIsInStockFilterToCollectionOnDefaultStockTest extends TestCase { /** * @var StockStatus diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php similarity index 92% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php index 3e1f630f6bd5..5bf1bbed495b 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; @@ -79,9 +79,9 @@ public function testAddIsInStockFilterToCollection(string $store, int $expectedS public function addIsInStockFilterToCollectionDataProvider(): array { return [ - ['store_for_eu_website', 1, true], - ['store_for_us_website', 1, true], - ['store_for_global_website', 2, true], + ['store_for_eu_website', 1], + ['store_for_us_website', 1], + ['store_for_global_website', 2], ]; } diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionWithDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionOnDefaultStockTest.php similarity index 90% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionWithDefaultStockTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionOnDefaultStockTest.php index 9758f28cd4c8..e06e579a6fdb 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionWithDefaultStockTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionOnDefaultStockTest.php @@ -5,14 +5,14 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; -class AddStockDataToCollectionWithDefaultStockTest extends TestCase +class AddStockDataToCollectionOnDefaultStockTest extends TestCase { /** * @var StockStatus diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php similarity index 96% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php index 7007acad114b..0dcd90163522 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectWithDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectOnDefaultStockTest.php similarity index 92% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectWithDefaultStockTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectOnDefaultStockTest.php index d61de19b5628..4394caa7e998 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectWithDefaultStockTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectOnDefaultStockTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; @@ -16,7 +16,7 @@ /** * Test add stock status to select on default website. */ -class AddStockStatusToSelectWithDefaultStockTest extends TestCase +class AddStockStatusToSelectOnDefaultStockTest extends TestCase { /** * @var StockStatus diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php similarity index 97% rename from app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php rename to app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php index 12422348c5f2..2802e9e9b6f0 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\CatalogInventory\Model\ResourceModel\Stock\Status as StockStatus; diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php deleted file mode 100644 index cb23f44faaff..000000000000 --- a/app/code/Magento/InventoryCatalog/Test/Integration/Plugin/CatalogInventory/StockHelper/AddStockStatusToProductsMultistockPluginTest.php +++ /dev/null @@ -1,189 +0,0 @@ -helper = Bootstrap::getObjectManager()->get(Helper::class); - $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); - $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); - $this->productCollection = Bootstrap::getObjectManager()->create(ProductCollection::class); - $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); - - parent::setUp(); - } - - /** - * Tests AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts for single stock. - * - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryCatalog/Test/_files/source_items_on_default_source.php - * @dataProvider addStockStatusToProductsSingleSourceDataProvider - * @param array $productsData - */ - public function testAddStockStatusToProductsSingleSource(array $productsData) - { - $this->addStockStatusToProducts($productsData); - } - - /** - * Tests AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts for multiple stocks. - * - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php - * @dataProvider addStockStatusToProductsMultiSourceDataProvider - * @param string $storeCode - * @param array $productsData - */ - public function testAddStockStatusToProductsMultiSource(string $storeCode, array $productsData) - { - $this->storeManager->setCurrentStore($storeCode); - $this->addStockStatusToProducts($productsData); - } - - /** - * Base test for AddStockStatusToProductsMultistockPlugin::aroundAddStockStatusToProducts. - * - * @param array $productsData - */ - private function addStockStatusToProducts(array $productsData) - { - $this->productCollection->clear(); - $this->productCollection->addFieldToFilter('sku', ['in' => null]); - $this->productCollection->load(); - foreach ($productsData as $productData) { - $product = $this->productRepository->get($productData['sku']); - $this->productCollection->addItem($product); - } - $this->helper->addStockStatusToProducts($this->productCollection); - foreach ($productsData as $productData) { - /** @var ProductInterface $product */ - $product = $this->productRepository->get($productData['sku']); - $actual = $product->isSalable(); - self::assertEquals( - $productData['expected'], - $actual - ); - } - } - - /** - * Data provider for testAddStockStatusToProductsSingleSource. - * - * @return array - */ - public function addStockStatusToProductsSingleSourceDataProvider() - { - return [ - [ - [ - ['sku' => 'SKU-1', 'expected' => 1], - ['sku' => 'SKU-2', 'expected' => 1], - ['sku' => 'SKU-3', 'expected' => 0], - ], - ], - ]; - } - - /** - * Data provider for testAddStockStatusToProductsMultiSource. - * - * @return array - */ - public function addStockStatusToProductsMultiSourceDataProvider() - { - return [ - [ - 'store_for_eu_website', - [ - ['sku' => 'SKU-1', 'expected' => 1], - ['sku' => 'SKU-2', 'expected' => 0], - ['sku' => 'SKU-3', 'expected' => 0], - ], - ], - [ - 'store_for_us_website', - [ - ['sku' => 'SKU-1', 'expected' => 0], - ['sku' => 'SKU-2', 'expected' => 1], - ['sku' => 'SKU-3', 'expected' => 0], - ], - ], - [ - 'store_for_global_website', - [ - ['sku' => 'SKU-1', 'expected' => 1], - ['sku' => 'SKU-2', 'expected' => 1], - ['sku' => 'SKU-3', 'expected' => 0], - ], - ], - ]; - } - - /** - * @inheritdoc - */ - protected function tearDown() - { - if (null !== $this->storeCodeBefore) { - $this->storeManager->setCurrentStore($this->storeCodeBefore); - } - - parent::tearDown(); - } -} diff --git a/app/code/Magento/InventoryCatalog/etc/di.xml b/app/code/Magento/InventoryCatalog/etc/di.xml index a25431283c75..af9c2cc8c827 100644 --- a/app/code/Magento/InventoryCatalog/etc/di.xml +++ b/app/code/Magento/InventoryCatalog/etc/di.xml @@ -38,11 +38,14 @@ type="Magento\InventoryCatalog\Plugin\CatalogInventory\UpdateSourceItemAtLegacyStockItemSavePlugin"/> - - - + + + + + + diff --git a/app/code/Magento/InventoryCatalog/etc/frontend/di.xml b/app/code/Magento/InventoryCatalog/etc/frontend/di.xml deleted file mode 100644 index c8cb83e7af5f..000000000000 --- a/app/code/Magento/InventoryCatalog/etc/frontend/di.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - From 01a9701e5bf24c36d4f0e6000c68393c30ede71b Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Wed, 24 Jan 2018 20:24:31 +0200 Subject: [PATCH 10/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../Helper/Stock/AddStockStatusToProductsTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php index 6948353e2722..58371e62230a 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php @@ -51,6 +51,7 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * @dataProvider addStockStatusToProductsDataProvider * @param string $storeCode * @param array $productsData From 6ddfc9b6ff71731d8a636de65b88bae0e66c57a5 Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Thu, 25 Jan 2018 12:44:02 +0200 Subject: [PATCH 11/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../AddIsInStockFilterToCollectionTest.php | 4 +-- .../Status/AddStockDataToCollectionTest.php | 4 +-- .../Status/AddStockStatusToSelectTest.php | 4 +-- .../Model/GetStockItemQuantity.php | 29 ++++--------------- .../Test/_files/stock_website_link.php | 5 ++-- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php index 5bf1bbed495b..d3329953986b 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php @@ -47,12 +47,12 @@ protected function setUp() } /** - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php index 0dcd90163522..69686379b455 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php @@ -47,12 +47,12 @@ protected function setUp() } /** - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php index 2802e9e9b6f0..c782788e55fe 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php @@ -41,12 +41,12 @@ protected function setUp() } /** - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * diff --git a/app/code/Magento/InventoryIndexer/Model/GetStockItemQuantity.php b/app/code/Magento/InventoryIndexer/Model/GetStockItemQuantity.php index 2cb5d4117951..ab3c5b850757 100644 --- a/app/code/Magento/InventoryIndexer/Model/GetStockItemQuantity.php +++ b/app/code/Magento/InventoryIndexer/Model/GetStockItemQuantity.php @@ -8,12 +8,8 @@ namespace Magento\InventoryIndexer\Model; use Magento\Framework\App\ResourceConnection; -use Magento\Framework\MultiDimensionalIndexer\Alias; -use Magento\Framework\MultiDimensionalIndexer\IndexNameBuilder; -use Magento\Framework\MultiDimensionalIndexer\IndexNameResolverInterface; use Magento\Inventory\Model\GetStockItemQuantityInterface; use Magento\InventoryIndexer\Indexer\IndexStructure; -use Magento\InventoryIndexer\Indexer\InventoryIndexer; /** * @inheritdoc @@ -26,28 +22,20 @@ class GetStockItemQuantity implements GetStockItemQuantityInterface private $resource; /** - * @var IndexNameBuilder + * @var StockIndexTableNameResolverInterface */ - private $indexNameBuilder; - - /** - * @var IndexNameResolverInterface - */ - private $indexNameResolver; + private $stockIndexTableNameResolver; /** * @param ResourceConnection $resource - * @param IndexNameBuilder $indexNameBuilder - * @param IndexNameResolverInterface $indexNameResolver + * @param StockIndexTableNameResolverInterface $stockIndexTableNameResolver */ public function __construct( ResourceConnection $resource, - IndexNameBuilder $indexNameBuilder, - IndexNameResolverInterface $indexNameResolver + StockIndexTableNameResolverInterface $stockIndexTableNameResolver ) { $this->resource = $resource; - $this->indexNameBuilder = $indexNameBuilder; - $this->indexNameResolver = $indexNameResolver; + $this->stockIndexTableNameResolver = $stockIndexTableNameResolver; } /** @@ -55,12 +43,7 @@ public function __construct( */ public function execute(string $sku, int $stockId): float { - $indexName = $this->indexNameBuilder - ->setIndexId(InventoryIndexer::INDEXER_ID) - ->addDimension('stock_', (string)$stockId) - ->setAlias(Alias::ALIAS_MAIN) - ->build(); - $stockItemTableName = $this->indexNameResolver->resolveName($indexName); + $stockItemTableName = $this->stockIndexTableNameResolver->execute($stockId); $connection = $this->resource->getConnection(); $select = $connection->select() diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php b/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php index 8421bc12470f..434b9839d228 100644 --- a/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php +++ b/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php @@ -18,11 +18,12 @@ /** * EU-stock(id:10) - EU-website (code:eu_website) * US-stock(id:20) - US-website (code:us_website) + * Global-stock(id:30) - Global-website (code:global_website) */ $salesChannelData = [10 => 'eu_website', 20 => 'us_website', 30 => 'global_website']; -foreach ($salesChannelData as $storeId => $websiteCode) { - $stock = $stockRepository->get($storeId); +foreach ($salesChannelData as $stockId => $websiteCode) { + $stock = $stockRepository->get($stockId); $extensionAttributes = $stock->getExtensionAttributes(); $salesChannels = $extensionAttributes->getSalesChannels(); From 164762d5b14e2834dc60988575cdb196d4c538b0 Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Thu, 25 Jan 2018 13:04:36 +0200 Subject: [PATCH 12/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../InventoryApi/Test/_files/products.php | 5 ----- .../Test/_files/reindex_inventory_rollback.php | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/InventoryApi/Test/_files/products.php b/app/code/Magento/InventoryApi/Test/_files/products.php index e00b275d4bc8..1bd0b39eff11 100644 --- a/app/code/Magento/InventoryApi/Test/_files/products.php +++ b/app/code/Magento/InventoryApi/Test/_files/products.php @@ -27,11 +27,6 @@ $productRepository = $objectManager->get(ProductRepositoryInterface::class); $productRepository->cleanCache(); -/** @var IndexerInterface $indexer */ -$indexer = Bootstrap::getObjectManager()->create(IndexerInterface::class); -$indexer->load(InventoryIndexer::INDEXER_ID); -$indexer->reindexAll(); - $stockData = [ 'SKU-1' => [ 'qty' => 8.5, diff --git a/app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory_rollback.php b/app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory_rollback.php index ad95707b9092..ee7a1090276e 100644 --- a/app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory_rollback.php +++ b/app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory_rollback.php @@ -5,7 +5,9 @@ */ declare(strict_types=1); +use Magento\Framework\Module\Manager; use Magento\InventoryApi\Api\StockRepositoryInterface; +use Magento\InventoryCatalog\Api\DefaultStockProviderInterface; use Magento\InventoryIndexer\Test\Integration\Indexer\RemoveIndexData; use Magento\TestFramework\Helper\Bootstrap; @@ -16,6 +18,16 @@ $stockIds = []; foreach ($stockRepository->getList()->getItems() as $stock) { - $stockIds[] = $stock->getStockId(); + $stockIds[$stock->getStockId()] = $stock->getStockId(); } -$removeIndexData->execute($stockIds); + +/** @var Manager $moduleManager */ +$moduleManager = Bootstrap::getObjectManager()->get(Manager::class); +// soft dependency in tests because we don't have possibility replace fixture from different modules +if ($moduleManager->isEnabled('Magento_InventoryCatalog')) { + /** @var DefaultStockProviderInterface $defaultStockProvider */ + $defaultStockProvider = Bootstrap::getObjectManager()->get(DefaultStockProviderInterface::class); + unset($stockIds[$defaultStockProvider->getId()]); +} + +$removeIndexData->execute(array_values($stockIds)); From 79e80dcca7d8d5fb042750477ed725e204fbd9fb Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Thu, 25 Jan 2018 13:15:12 +0200 Subject: [PATCH 13/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../Stock/GetProductQuantityInStockTest.php | 4 ++-- .../Test/Integration/Stock/IsProductInStockTest.php | 4 ++-- .../StockSourceLink/GetAssignedSourcesForStockTest.php | 4 ++-- .../StockSourceLink/UnassignSourceFromStockTest.php | 2 +- .../{stock_source_link.php => stock_source_links.php} | 0 ...nk_rollback.php => stock_source_links_rollback.php} | 0 .../Helper/Stock/AddStockStatusToProductsTest.php | 4 ++-- .../Status/AddIsInStockFilterToCollectionTest.php | 4 ++-- .../Stock/Status/AddStockDataToCollectionTest.php | 4 ++-- .../Stock/Status/AddStockStatusToSelectTest.php | 4 ++-- .../Test/Integration/Model/Export/SourcesTest.php | 10 +++++----- .../Test/Integration/Model/Import/SourcesTest.php | 8 ++++---- .../Magento/InventoryIndexer/Indexer/SelectBuilder.php | 8 ++++---- .../Indexer/SourceItem/GetSkuListInStock.php | 6 +++--- .../Test/Integration/Indexer/SourceIndexerTest.php | 6 +++--- .../Test/Integration/Indexer/SourceItemIndexerTest.php | 8 ++++---- .../Test/Integration/Indexer/StockIndexerTest.php | 6 +++--- .../Integration/IsBackorderedProductInStockTest.php | 2 +- .../ReservationPlacingDuringBackItemQtyTest.php | 4 ++-- ...eservationPlacingDuringRegisterProductsSaleTest.php | 4 ++-- .../ReservationPlacingDuringRevertProductsSaleTest.php | 4 ++-- ...bsite_link.php => stock_website_sales_channels.php} | 0 ...k.php => stock_website_sales_channels_rollback.php} | 0 .../Test/Integration/DefaultShippingAlgorithmTest.php | 2 +- 24 files changed, 49 insertions(+), 49 deletions(-) rename app/code/Magento/InventoryApi/Test/_files/{stock_source_link.php => stock_source_links.php} (100%) rename app/code/Magento/InventoryApi/Test/_files/{stock_source_link_rollback.php => stock_source_links_rollback.php} (100%) rename app/code/Magento/InventorySalesApi/Test/_files/{stock_website_link.php => stock_website_sales_channels.php} (100%) rename app/code/Magento/InventorySalesApi/Test/_files/{stock_website_link_rollback.php => stock_website_sales_channels_rollback.php} (100%) diff --git a/app/code/Magento/Inventory/Test/Integration/Stock/GetProductQuantityInStockTest.php b/app/code/Magento/Inventory/Test/Integration/Stock/GetProductQuantityInStockTest.php index 843fbd644059..d8b12b3335a3 100644 --- a/app/code/Magento/Inventory/Test/Integration/Stock/GetProductQuantityInStockTest.php +++ b/app/code/Magento/Inventory/Test/Integration/Stock/GetProductQuantityInStockTest.php @@ -58,7 +58,7 @@ protected function tearDown() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ @@ -71,7 +71,7 @@ public function testGetProductQuantity() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ diff --git a/app/code/Magento/Inventory/Test/Integration/Stock/IsProductInStockTest.php b/app/code/Magento/Inventory/Test/Integration/Stock/IsProductInStockTest.php index 56a6188ea776..58cffa4570f4 100644 --- a/app/code/Magento/Inventory/Test/Integration/Stock/IsProductInStockTest.php +++ b/app/code/Magento/Inventory/Test/Integration/Stock/IsProductInStockTest.php @@ -48,7 +48,7 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ @@ -61,7 +61,7 @@ public function testProductIsInStock() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php */ diff --git a/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/GetAssignedSourcesForStockTest.php b/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/GetAssignedSourcesForStockTest.php index 2b305ccca970..eaf1fbcdca56 100644 --- a/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/GetAssignedSourcesForStockTest.php +++ b/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/GetAssignedSourcesForStockTest.php @@ -24,7 +24,7 @@ class GetAssignedSourcesForStockTest extends WebapiAbstract /** * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testGetAssignedSourcesForStock() { @@ -51,7 +51,7 @@ public function testGetAssignedSourcesForStock() /** * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testGetAssignedSourcesWithNotNumericStockId() { diff --git a/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/UnassignSourceFromStockTest.php b/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/UnassignSourceFromStockTest.php index 9954108194f8..7fb8de0e3037 100644 --- a/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/UnassignSourceFromStockTest.php +++ b/app/code/Magento/InventoryApi/Test/Api/StockSourceLink/UnassignSourceFromStockTest.php @@ -41,7 +41,7 @@ class UnassignSourceFromStockTest extends WebapiAbstract * * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoApiDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testUnassignSourceFromStock() { diff --git a/app/code/Magento/InventoryApi/Test/_files/stock_source_link.php b/app/code/Magento/InventoryApi/Test/_files/stock_source_links.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/stock_source_link.php rename to app/code/Magento/InventoryApi/Test/_files/stock_source_links.php diff --git a/app/code/Magento/InventoryApi/Test/_files/stock_source_link_rollback.php b/app/code/Magento/InventoryApi/Test/_files/stock_source_links_rollback.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/stock_source_link_rollback.php rename to app/code/Magento/InventoryApi/Test/_files/stock_source_links_rollback.php diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php index 58371e62230a..3faab6e36d33 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php @@ -47,10 +47,10 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * @dataProvider addStockStatusToProductsDataProvider * @param string $storeCode diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php index d3329953986b..744f7d01bd08 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddIsInStockFilterToCollectionTest.php @@ -50,10 +50,10 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * * @param string $store diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php index 69686379b455..a1ee62abe77f 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockDataToCollectionTest.php @@ -50,10 +50,10 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * * @param string $store diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php index c782788e55fe..fd0e7a684239 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Stock/Status/AddStockStatusToSelectTest.php @@ -44,10 +44,10 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * * @param string $websiteCode diff --git a/app/code/Magento/InventoryImportExport/Test/Integration/Model/Export/SourcesTest.php b/app/code/Magento/InventoryImportExport/Test/Integration/Model/Export/SourcesTest.php index 5108636ef1cd..b9690a359d3d 100644 --- a/app/code/Magento/InventoryImportExport/Test/Integration/Model/Export/SourcesTest.php +++ b/app/code/Magento/InventoryImportExport/Test/Integration/Model/Export/SourcesTest.php @@ -51,7 +51,7 @@ protected function tearDown() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testExportWithoutAnyFiltering() { @@ -76,7 +76,7 @@ public function testExportWithoutAnyFiltering() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testExportWithSkuFilter() { @@ -98,7 +98,7 @@ public function testExportWithSkuFilter() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testExportWithSkuFilterByLikeQuery() { @@ -120,7 +120,7 @@ public function testExportWithSkuFilterByLikeQuery() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testExportWithSourceFilter() { @@ -142,7 +142,7 @@ public function testExportWithSourceFilter() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testExportFilteredWithoutStatusColumn() { diff --git a/app/code/Magento/InventoryImportExport/Test/Integration/Model/Import/SourcesTest.php b/app/code/Magento/InventoryImportExport/Test/Integration/Model/Import/SourcesTest.php index 5003dfae8ab3..635dbebc72a5 100755 --- a/app/code/Magento/InventoryImportExport/Test/Integration/Model/Import/SourcesTest.php +++ b/app/code/Magento/InventoryImportExport/Test/Integration/Model/Import/SourcesTest.php @@ -95,7 +95,7 @@ public function testImportDataWithWrongBehavior() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testImportDataWithAppendBehavior() { @@ -125,7 +125,7 @@ public function testImportDataWithAppendBehavior() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testImportDataWithDelteBehavior() { @@ -152,7 +152,7 @@ public function testImportDataWithDelteBehavior() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testImportDataWithReplaceBehavior() { @@ -179,7 +179,7 @@ public function testImportDataWithReplaceBehavior() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testImportDataWithReplaceBehaviorNoAffectOtherSources() { diff --git a/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php b/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php index f6e975543178..c171efd64270 100644 --- a/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php +++ b/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php @@ -71,16 +71,16 @@ public function execute($stockId): Select ] ) ->joinLeft( - ['stock_source_link' => $sourceStockLinkTable], + ['stock_source_links' => $sourceStockLinkTable], sprintf( - 'source_item.%s = stock_source_link.%s', + 'source_item.%s = stock_source_links.%s', SourceItemInterface::SOURCE_CODE, StockSourceLink::SOURCE_CODE ), [] ) - ->where('stock_source_link.' . StockSourceLink::STOCK_ID . ' = ?', $stockId) - ->where('stock_source_link.' . StockSourceLink::SOURCE_CODE . ' IN (?)', $sourceCodes) + ->where('stock_source_links.' . StockSourceLink::STOCK_ID . ' = ?', $stockId) + ->where('stock_source_links.' . StockSourceLink::SOURCE_CODE . ' IN (?)', $sourceCodes) ->group([SourceItemInterface::SKU]); return $select; } diff --git a/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php b/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php index c6407981ada4..dc5751dbe7e4 100644 --- a/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php +++ b/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php @@ -75,15 +75,15 @@ public function execute(array $sourceItemIds): array sprintf("GROUP_CONCAT(DISTINCT %s SEPARATOR ',')", 'source_item.' . SourceItemInterface::SKU) ] )->joinInner( - ['stock_source_link' => $sourceStockLinkTable], + ['stock_source_links' => $sourceStockLinkTable], sprintf( - 'source_item.%s = stock_source_link.%s', + 'source_item.%s = stock_source_links.%s', SourceItemInterface::SOURCE_CODE, StockSourceLink::SOURCE_CODE ), [StockSourceLink::STOCK_ID] )->where('source_item.source_item_id IN (?)', $sourceItemIds) - ->group(['stock_source_link.' . StockSourceLink::STOCK_ID]); + ->group(['stock_source_links.' . StockSourceLink::STOCK_ID]); $connection->query('SET group_concat_max_len = ' . $this->groupConcatMaxLen); $items = $connection->fetchAll($select); diff --git a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceIndexerTest.php b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceIndexerTest.php index 9d2a3fb4f0fa..be73380bd4d2 100644 --- a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceIndexerTest.php +++ b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceIndexerTest.php @@ -54,7 +54,7 @@ protected function tearDown() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexRow() { @@ -69,7 +69,7 @@ public function testReindexRow() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexList() { @@ -87,7 +87,7 @@ public function testReindexList() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexAll() { diff --git a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceItemIndexerTest.php b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceItemIndexerTest.php index 2aaf17c26e3c..78e87e6e1a42 100644 --- a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceItemIndexerTest.php +++ b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/SourceItemIndexerTest.php @@ -61,7 +61,7 @@ protected function tearDown() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexRow() { @@ -76,7 +76,7 @@ public function testReindexRow() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexList() { @@ -97,7 +97,7 @@ public function testReindexList() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexAll() { @@ -115,7 +115,7 @@ public function testReindexAll() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testStockItemsHasZeroQuantityIfSourceItemsAreOutOfStock() { diff --git a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/StockIndexerTest.php b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/StockIndexerTest.php index e4284817c680..5718a1c47b8e 100644 --- a/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/StockIndexerTest.php +++ b/app/code/Magento/InventoryIndexer/Test/Integration/Indexer/StockIndexerTest.php @@ -53,7 +53,7 @@ protected function tearDown() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexRow() { @@ -67,7 +67,7 @@ public function testReindexRow() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexList() { @@ -82,7 +82,7 @@ public function testReindexList() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testReindexAll() { diff --git a/app/code/Magento/InventorySales/Test/Integration/IsBackorderedProductInStockTest.php b/app/code/Magento/InventorySales/Test/Integration/IsBackorderedProductInStockTest.php index 14474b8d0bda..65711f2cdef4 100644 --- a/app/code/Magento/InventorySales/Test/Integration/IsBackorderedProductInStockTest.php +++ b/app/code/Magento/InventorySales/Test/Integration/IsBackorderedProductInStockTest.php @@ -73,7 +73,7 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php */ public function testBackorderedZeroQtyProductIsInStock() diff --git a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringBackItemQtyTest.php b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringBackItemQtyTest.php index 4f8269571703..3f0842499b21 100644 --- a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringBackItemQtyTest.php +++ b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringBackItemQtyTest.php @@ -55,11 +55,11 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php */ public function testRevertProductsSale() { diff --git a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRegisterProductsSaleTest.php b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRegisterProductsSaleTest.php index e2ec05375d13..85f57532ac11 100644 --- a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRegisterProductsSaleTest.php +++ b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRegisterProductsSaleTest.php @@ -55,11 +55,11 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php */ public function testRegisterProductsSale() { diff --git a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRevertProductsSaleTest.php b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRevertProductsSaleTest.php index 7a09dcaa893a..7458ef81a33c 100644 --- a/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRevertProductsSaleTest.php +++ b/app/code/Magento/InventorySales/Test/Integration/StockManagement/ReservationPlacingDuringRevertProductsSaleTest.php @@ -55,11 +55,11 @@ protected function setUp() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/products.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php */ public function testRevertProductsSale() { diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php b/app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php similarity index 100% rename from app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php rename to app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php diff --git a/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link_rollback.php b/app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels_rollback.php similarity index 100% rename from app/code/Magento/InventorySalesApi/Test/_files/stock_website_link_rollback.php rename to app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels_rollback.php diff --git a/app/code/Magento/InventoryShipping/Test/Integration/DefaultShippingAlgorithmTest.php b/app/code/Magento/InventoryShipping/Test/Integration/DefaultShippingAlgorithmTest.php index 5c49cbfa1ca7..c05d054aa234 100644 --- a/app/code/Magento/InventoryShipping/Test/Integration/DefaultShippingAlgorithmTest.php +++ b/app/code/Magento/InventoryShipping/Test/Integration/DefaultShippingAlgorithmTest.php @@ -86,7 +86,7 @@ public function testDefaultStockSource() * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/sources.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stocks.php * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/source_items.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/stock_source_links.php */ public function testStockSourceCombination() { From d27decb9ef0a3305e2a50728a20b6ee2fe4d1183 Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Thu, 25 Jan 2018 13:54:37 +0200 Subject: [PATCH 14/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php | 2 +- .../Helper/Stock/AddStockStatusToProductsTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php index de1c5f1742ea..661dcf7ad951 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsOnDefaultStockTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Helper\Stock; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\Collection; diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php index 3faab6e36d33..32be3aac31d5 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Stock\Status; +namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Helper\Stock; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\Collection; From 6ff5716679bf4988691f998ff6f241bf69ed8713 Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Thu, 25 Jan 2018 13:57:40 +0200 Subject: [PATCH 15/15] MSI: 386: Adapt `\Magento\CatalogInventory\Helper\Stock::addStockStatusToProducts` --- .../Magento/InventoryIndexer/Indexer/SelectBuilder.php | 8 ++++---- .../Indexer/SourceItem/GetSkuListInStock.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php b/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php index c171efd64270..f6e975543178 100644 --- a/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php +++ b/app/code/Magento/InventoryIndexer/Indexer/SelectBuilder.php @@ -71,16 +71,16 @@ public function execute($stockId): Select ] ) ->joinLeft( - ['stock_source_links' => $sourceStockLinkTable], + ['stock_source_link' => $sourceStockLinkTable], sprintf( - 'source_item.%s = stock_source_links.%s', + 'source_item.%s = stock_source_link.%s', SourceItemInterface::SOURCE_CODE, StockSourceLink::SOURCE_CODE ), [] ) - ->where('stock_source_links.' . StockSourceLink::STOCK_ID . ' = ?', $stockId) - ->where('stock_source_links.' . StockSourceLink::SOURCE_CODE . ' IN (?)', $sourceCodes) + ->where('stock_source_link.' . StockSourceLink::STOCK_ID . ' = ?', $stockId) + ->where('stock_source_link.' . StockSourceLink::SOURCE_CODE . ' IN (?)', $sourceCodes) ->group([SourceItemInterface::SKU]); return $select; } diff --git a/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php b/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php index dc5751dbe7e4..c6407981ada4 100644 --- a/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php +++ b/app/code/Magento/InventoryIndexer/Indexer/SourceItem/GetSkuListInStock.php @@ -75,15 +75,15 @@ public function execute(array $sourceItemIds): array sprintf("GROUP_CONCAT(DISTINCT %s SEPARATOR ',')", 'source_item.' . SourceItemInterface::SKU) ] )->joinInner( - ['stock_source_links' => $sourceStockLinkTable], + ['stock_source_link' => $sourceStockLinkTable], sprintf( - 'source_item.%s = stock_source_links.%s', + 'source_item.%s = stock_source_link.%s', SourceItemInterface::SOURCE_CODE, StockSourceLink::SOURCE_CODE ), [StockSourceLink::STOCK_ID] )->where('source_item.source_item_id IN (?)', $sourceItemIds) - ->group(['stock_source_links.' . StockSourceLink::STOCK_ID]); + ->group(['stock_source_link.' . StockSourceLink::STOCK_ID]); $connection->query('SET group_concat_max_len = ' . $this->groupConcatMaxLen); $items = $connection->fetchAll($select);