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/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/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/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/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..661dcf7ad951 --- /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..32be3aac31d5 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Helper/Stock/AddStockStatusToProductsTest.php @@ -0,0 +1,118 @@ +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_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_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.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 89% 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..744f7d01bd08 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; @@ -47,13 +47,13 @@ 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/stock_source_links.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/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.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 @@ -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 93% 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..a1ee62abe77f 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; @@ -47,13 +47,13 @@ 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/stock_source_links.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/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.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/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 95% 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..fd0e7a684239 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; @@ -41,13 +41,13 @@ 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/stock_source_links.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/stock_website_link.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.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/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/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/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/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/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)); 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 88% 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 index 8421bc12470f..434b9839d228 100644 --- a/app/code/Magento/InventorySalesApi/Test/_files/stock_website_link.php +++ b/app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.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(); 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() {