From d606a5e7211072c42a7ac2cbf2d449f816af7b98 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 2 Feb 2018 15:47:50 +0200 Subject: [PATCH 01/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../Test/_files/product_configurable.php | 148 ++++++++++++++++++ .../product_configurable_out_of_stock.php | 148 ++++++++++++++++++ ...uct_configurable_out_of_stock_rollback.php | 36 +++++ .../_files/product_configurable_rollback.php | 36 +++++ .../Test/_files/source_items_configurable.php | 68 ++++++++ .../source_items_configurable_rollback.php | 34 ++++ .../StockStatusBaseSelectProcessor.php | 71 +++++++++ ...sBaseSelectProcessorOnDefaultStockTest.php | 65 ++++++++ .../StockStatusBaseSelectProcessorTest.php | 99 ++++++++++++ app/code/Magento/InventoryCatalog/etc/di.xml | 7 + .../product_configurable_out_of_stock.php | 142 +++++++++++++++++ ...uct_configurable_out_of_stock_rollback.php | 36 +++++ 12 files changed, 890 insertions(+) create mode 100644 app/code/Magento/InventoryApi/Test/_files/product_configurable.php create mode 100644 app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php create mode 100644 app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php create mode 100644 app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php create mode 100644 app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php create mode 100644 app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php create mode 100644 app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php create mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php create mode 100644 app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php new file mode 100644 index 000000000000..8ad2d2f0b58b --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php @@ -0,0 +1,148 @@ +reinitialize(); + +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute.php'; + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class); + +/** @var $installer CategorySetup */ +$installer = Bootstrap::getObjectManager()->create(CategorySetup::class); + +/** @var Website $website */ +$website = Bootstrap::getObjectManager()->create(Website::class); +$website->load('us_website', 'code'); +$websiteIds = [$website->getId()]; +/* Create simple products per each option value*/ +/** @var AttributeOptionInterface[] $options */ +$options = $attribute->getOptions(); + +$attributeValues = []; +$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); +$associatedProductIds = []; +$productIds = [10, 20]; +array_shift($options); //remove the first option which is empty + +foreach ($options as $option) { + /** @var $product Product */ + $product = Bootstrap::getObjectManager()->create(Product::class); + $productId = array_shift($productIds); + $product->setTypeId(Type::TYPE_SIMPLE) + ->setId($productId) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds($websiteIds) + ->setName('Configurable Option' . $option->getLabel()) + ->setSku('simple_' . $productId) + ->setPrice($productId) + ->setTestConfigurable($option->getValue()) + ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]); + + $product = $productRepository->save($product); + + /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + $stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); + $stockItem->load($productId, 'product_id'); + + if (!$stockItem->getProductId()) { + $stockItem->setProductId($productId); + } + $stockItem->setUseConfigManageStock(1); + $stockItem->setQty(1000); + $stockItem->setIsQtyDecimal(0); + $stockItem->setIsInStock(1); + $stockItem->save(); + + $attributeValues[] = [ + 'label' => 'test', + 'attribute_id' => $attribute->getId(), + 'value_index' => $option->getValue(), + ]; + $associatedProductIds[] = $product->getId(); +} + +/** @var $product Product */ +$product = Bootstrap::getObjectManager()->create(Product::class); + +/** @var Factory $optionsFactory */ +$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class); + +$configurableAttributesData = [ + [ + 'attribute_id' => $attribute->getId(), + 'code' => $attribute->getAttributeCode(), + 'label' => $attribute->getStoreLabel(), + 'position' => '0', + 'values' => $attributeValues, + ], +]; + +$configurableOptions = $optionsFactory->create($configurableAttributesData); + +$extensionConfigurableAttributes = $product->getExtensionAttributes(); +$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions); +$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds); + +$product->setExtensionAttributes($extensionConfigurableAttributes); + +// Remove any previously created product with the same id. +/** @var \Magento\Framework\Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); +try { + $productToDelete = $productRepository->getById(1); + $productRepository->delete($productToDelete); + + /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */ + $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class); + $itemResource->getConnection()->delete( + $itemResource->getMainTable(), + 'product_id = ' . $productToDelete->getId() + ); +} catch (\Exception $e) { + // Nothing to remove +} +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +$product->setTypeId(Configurable::TYPE_CODE) + ->setId(1) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds($websiteIds) + ->setName('Configurable Product') + ->setSku('configurable') + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 1]); + +$productRepository->save($product); + +/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */ +$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); + +$categoryLinkManagement->assignProductToCategories( + $product->getSku(), + [2] +); + diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php new file mode 100644 index 000000000000..20bc3448a24c --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php @@ -0,0 +1,148 @@ +reinitialize(); + +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute.php'; + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = Bootstrap::getObjectManager() + ->create(ProductRepositoryInterface::class); + +/** @var $installer CategorySetup */ +$installer = Bootstrap::getObjectManager()->create(CategorySetup::class); + +/** @var Website $website */ +$website = Bootstrap::getObjectManager()->create(Website::class); +$website->load('us_website', 'code'); +$websiteIds = [$website->getId()]; + +/* Create simple products per each option value*/ +/** @var AttributeOptionInterface[] $options */ +$options = $attribute->getOptions(); + +$attributeValues = []; +$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); +$associatedProductIds = []; +$productIds = [30, 40]; +array_shift($options); //remove the first option which is empty + +foreach ($options as $option) { + /** @var $product Product */ + $product = Bootstrap::getObjectManager()->create(Product::class); + $productId = array_shift($productIds); + $product->setTypeId(Type::TYPE_SIMPLE) + ->setId($productId) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds($websiteIds) + ->setName('Configurable Option' . $option->getLabel()) + ->setSku('simple_' . $productId) + ->setPrice($productId) + ->setTestConfigurable($option->getValue()) + ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); + + $product = $productRepository->save($product); + + /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + $stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); + $stockItem->load($productId, 'product_id'); + + if (!$stockItem->getProductId()) { + $stockItem->setProductId($productId); + } + $stockItem->setUseConfigManageStock(1); + $stockItem->setQty(0); + $stockItem->setIsQtyDecimal(0); + $stockItem->setIsInStock(0); + $stockItem->save(); + + $attributeValues[] = [ + 'label' => 'test', + 'attribute_id' => $attribute->getId(), + 'value_index' => $option->getValue(), + ]; + $associatedProductIds[] = $product->getId(); +} + +/** @var $product Product */ +$product = Bootstrap::getObjectManager()->create(Product::class); + +/** @var Factory $optionsFactory */ +$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class); + +$configurableAttributesData = [ + [ + 'attribute_id' => $attribute->getId(), + 'code' => $attribute->getAttributeCode(), + 'label' => $attribute->getStoreLabel(), + 'position' => '0', + 'values' => $attributeValues, + ], +]; + +$configurableOptions = $optionsFactory->create($configurableAttributesData); + +$extensionConfigurableAttributes = $product->getExtensionAttributes(); +$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions); +$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds); + +$product->setExtensionAttributes($extensionConfigurableAttributes); + +// Remove any previously created product with the same id. +/** @var \Magento\Framework\Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); +try { + $productToDelete = $productRepository->getById(2); + $productRepository->delete($productToDelete); + + /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */ + $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class); + $itemResource->getConnection()->delete( + $itemResource->getMainTable(), + 'product_id = ' . $productToDelete->getId() + ); +} catch (\Exception $e) { + // Nothing to remove +} +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +$product->setTypeId(Configurable::TYPE_CODE) + ->setId(2) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds($websiteIds) + ->setName('Configurable Product Out of Stock') + ->setSku('configurable_out_of_stock') + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 0]); + +$productRepository->save($product); + +/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */ +$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); + +$categoryLinkManagement->assignProductToCategories( + $product->getSku(), + [2] +); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php new file mode 100644 index 000000000000..5a7431a7055c --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php @@ -0,0 +1,36 @@ +get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +foreach (['simple_30', 'simple_40', 'configurable_out_of_stock'] as $sku) { + try { + $product = $productRepository->get($sku, false, null, true); + + $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); + $stockStatus->load($product->getEntityId(), 'product_id'); + $stockStatus->delete(); + + $productRepository->delete($product); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + //Product already removed + } +} + +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_rollback.php'; + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php new file mode 100644 index 000000000000..910db0410162 --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php @@ -0,0 +1,36 @@ +get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +foreach (['simple_10', 'simple_20', 'configurable'] as $sku) { + try { + $product = $productRepository->get($sku, false, null, true); + + $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); + $stockStatus->load($product->getEntityId(), 'product_id'); + $stockStatus->delete(); + + $productRepository->delete($product); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + //Product already removed + } +} + +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_rollback.php'; + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php b/app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php new file mode 100644 index 000000000000..695a4cc05327 --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php @@ -0,0 +1,68 @@ +get(DataObjectHelper::class); +/** @var SourceItemInterfaceFactory $sourceItemFactory */ +$sourceItemFactory = Bootstrap::getObjectManager()->get(SourceItemInterfaceFactory::class); +/** @var SourceItemsSaveInterface $sourceItemsSave */ +$sourceItemsSave = Bootstrap::getObjectManager()->get(SourceItemsSaveInterface::class); + +$sourcesItemsData = [ + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'configurable_out_of_stock', + SourceItemInterface::QUANTITY => 0, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, + ], + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'simple_30', + SourceItemInterface::QUANTITY => 0, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, + ], + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'simple_40', + SourceItemInterface::QUANTITY => 0, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, + ], + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'configurable', + SourceItemInterface::QUANTITY => 100, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, + ], + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'simple_10', + SourceItemInterface::QUANTITY => 100, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, + ], + [ + SourceItemInterface::SOURCE_CODE => 'us-1', + SourceItemInterface::SKU => 'simple_20', + SourceItemInterface::QUANTITY => 100, + SourceItemInterface::STATUS => SourceItemInterface::STATUS_IN_STOCK, + ], + +]; + +$sourceItems = []; +foreach ($sourcesItemsData as $sourceItemData) { + /** @var SourceItemInterface $source */ + $sourceItem = $sourceItemFactory->create(); + $dataObjectHelper->populateWithArray($sourceItem, $sourceItemData, SourceItemInterface::class); + $sourceItems[] = $sourceItem; +} +$sourceItemsSave->execute($sourceItems); diff --git a/app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php b/app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php new file mode 100644 index 000000000000..9ae12ef95ebb --- /dev/null +++ b/app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php @@ -0,0 +1,34 @@ +get(SourceItemRepositoryInterface::class); +/** @var SourceItemsDeleteInterface $sourceItemsDelete */ +$sourceItemsDelete = Bootstrap::getObjectManager()->get(SourceItemsDeleteInterface::class); +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class); + +$searchCriteria = $searchCriteriaBuilder->addFilter( + SourceItemInterface::SKU, + ['configurable_out_of_stock', 'configurable', 'simple_10', 'simple_20', 'simple_30', 'simple_40'], + 'in' +)->create(); +$sourceItems = $sourceItemRepository->getList($searchCriteria)->getItems(); + +/** + * Tests which are wrapped with MySQL transaction clear all data by transaction rollback. + * In that case there is "if" which checks that SKU1, SKU2 and SKU3 still exists in database. + */ +if (!empty($sourceItems)) { + $sourceItemsDelete->execute($sourceItems); +} diff --git a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php new file mode 100644 index 000000000000..c420a6949528 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php @@ -0,0 +1,71 @@ +stockIndexTableNameResolver = $stockIndexTableNameResolver; + $this->stockConfig = $stockConfig; + $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; + } + + /** + * @param Select $select + * @return Select + */ + public function process(Select $select) + { + if (!$this->stockConfig->isShowOutOfStock()) { + $stockId = $this->getStockIdForCurrentWebsite->execute(); + $stockTable = $this->stockIndexTableNameResolver->execute($stockId); + + /** @var Select $select */ + $select->join( + ['stock' => $stockTable], + sprintf('stock.sku = parent.sku'), + [] + )->where('stock.quantity > 0'); + //todo )->where('stock.is_salable = ?', 1); + } + + return $select; + } +} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php new file mode 100644 index 000000000000..f49ce1fa9514 --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php @@ -0,0 +1,65 @@ +productResourceModel = Bootstrap::getObjectManager()->get(BaseSelectProcessorInterface::class); + $this->resourceConnection = Bootstrap::getObjectManager()->get(ResourceConnection::class); + } + + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php + * + * @return void + */ + public function testProcess() + { + $select = $this->resourceConnection->getConnection()->select(); + $productTable = $this->resourceConnection->getTableName('catalog_product_entity'); + $select + ->from(['parent' => $productTable]) + ->joinInner( + ['link' => $this->resourceConnection->getTableName('catalog_product_relation')], + 'link.parent_id = parent.entity_id', + [] + ) + ->joinInner( + ['child' => $productTable], + 'child.entity_id = link.child_id', + [] + ); + + $this->productResourceModel->process($select); + + self::assertEquals(2, count($select->query()->fetchAll())); + } +} diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php new file mode 100644 index 000000000000..f33a16573bdb --- /dev/null +++ b/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php @@ -0,0 +1,99 @@ +productResourceModel = Bootstrap::getObjectManager()->get(BaseSelectProcessorInterface::class); + $this->resourceConnection = Bootstrap::getObjectManager()->get(ResourceConnection::class); + $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + } + + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/product_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.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_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * + * @return void + */ + public function testProcess() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $select = $this->resourceConnection->getConnection()->select(); + $productTable = $this->resourceConnection->getTableName('catalog_product_entity'); + $select + ->from(['parent' => $productTable]) + ->joinInner( + ['link' => $this->resourceConnection->getTableName('catalog_product_relation')], + 'link.parent_id = parent.entity_id', + [] + ) + ->joinInner( + ['child' => $productTable], + 'child.entity_id = link.child_id', + [] + ); + + $this->productResourceModel->process($select); + + self::assertEquals(2, count($select->query()->fetchAll())); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryCatalog/etc/di.xml b/app/code/Magento/InventoryCatalog/etc/di.xml index b60723aa6bd7..1eba738afd91 100644 --- a/app/code/Magento/InventoryCatalog/etc/di.xml +++ b/app/code/Magento/InventoryCatalog/etc/di.xml @@ -49,4 +49,11 @@ + + + + Magento\InventoryCatalog\Model\ResourceModel\Product\StockStatusBaseSelectProcessor + + + diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php new file mode 100644 index 000000000000..fe7a86716de5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php @@ -0,0 +1,142 @@ +reinitialize(); + +require __DIR__ . '/configurable_attribute.php'; + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = Bootstrap::getObjectManager() + ->create(ProductRepositoryInterface::class); + +/** @var $installer CategorySetup */ +$installer = Bootstrap::getObjectManager()->create(CategorySetup::class); + +/* Create simple products per each option value*/ +/** @var AttributeOptionInterface[] $options */ +$options = $attribute->getOptions(); + +$attributeValues = []; +$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); +$associatedProductIds = []; +$productIds = [30, 40]; +array_shift($options); //remove the first option which is empty + +foreach ($options as $option) { + /** @var $product Product */ + $product = Bootstrap::getObjectManager()->create(Product::class); + $productId = array_shift($productIds); + $product->setTypeId(Type::TYPE_SIMPLE) + ->setId($productId) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds([1]) + ->setName('Configurable Option' . $option->getLabel()) + ->setSku('simple_' . $productId) + ->setPrice($productId) + ->setTestConfigurable($option->getValue()) + ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); + + $product = $productRepository->save($product); + + /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + $stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); + $stockItem->load($productId, 'product_id'); + + if (!$stockItem->getProductId()) { + $stockItem->setProductId($productId); + } + $stockItem->setUseConfigManageStock(1); + $stockItem->setQty(0); + $stockItem->setIsQtyDecimal(0); + $stockItem->setIsInStock(0); + $stockItem->save(); + + $attributeValues[] = [ + 'label' => 'test', + 'attribute_id' => $attribute->getId(), + 'value_index' => $option->getValue(), + ]; + $associatedProductIds[] = $product->getId(); +} + +/** @var $product Product */ +$product = Bootstrap::getObjectManager()->create(Product::class); + +/** @var Factory $optionsFactory */ +$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class); + +$configurableAttributesData = [ + [ + 'attribute_id' => $attribute->getId(), + 'code' => $attribute->getAttributeCode(), + 'label' => $attribute->getStoreLabel(), + 'position' => '0', + 'values' => $attributeValues, + ], +]; + +$configurableOptions = $optionsFactory->create($configurableAttributesData); + +$extensionConfigurableAttributes = $product->getExtensionAttributes(); +$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions); +$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds); + +$product->setExtensionAttributes($extensionConfigurableAttributes); + +// Remove any previously created product with the same id. +/** @var \Magento\Framework\Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); +try { + $productToDelete = $productRepository->getById(2); + $productRepository->delete($productToDelete); + + /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */ + $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class); + $itemResource->getConnection()->delete( + $itemResource->getMainTable(), + 'product_id = ' . $productToDelete->getId() + ); +} catch (\Exception $e) { + // Nothing to remove +} +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +$product->setTypeId(Configurable::TYPE_CODE) + ->setId(2) + ->setAttributeSetId($attributeSetId) + ->setWebsiteIds([1]) + ->setName('Configurable Product Out of Stock') + ->setSku('configurable_out_of_stock') + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 0]); + +$productRepository->save($product); + +/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */ +$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); + +$categoryLinkManagement->assignProductToCategories( + $product->getSku(), + [2] +); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php new file mode 100644 index 000000000000..8d655a39a827 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php @@ -0,0 +1,36 @@ +get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +foreach (['simple_30', 'simple_40', 'configurable_out_of_stock'] as $sku) { + try { + $product = $productRepository->get($sku, false, null, true); + + $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); + $stockStatus->load($product->getEntityId(), 'product_id'); + $stockStatus->delete(); + + $productRepository->delete($product); + } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + //Product already removed + } +} + +require __DIR__ . '/configurable_attribute_rollback.php'; + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From fdd42c41abb7df03987d9e233a8e5b8c06d38f15 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 2 Feb 2018 15:49:58 +0200 Subject: [PATCH 02/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../ResourceModel/Product/StockStatusBaseSelectProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php index c420a6949528..69ae7296c419 100644 --- a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php +++ b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php @@ -63,7 +63,7 @@ public function process(Select $select) sprintf('stock.sku = parent.sku'), [] )->where('stock.quantity > 0'); - //todo )->where('stock.is_salable = ?', 1); + //todo https://github.com/magento-engcom/msi/pull/442 )->where('stock.is_salable = ?', 1); } return $select; From fea73fd6857465701035f749a0adcc0d471c173e Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 2 Feb 2018 16:28:54 +0200 Subject: [PATCH 03/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../InventoryApi/Test/_files/product_configurable.php | 5 +++-- .../Test/_files/product_configurable_out_of_stock.php | 3 ++- .../_files/product_configurable_out_of_stock_rollback.php | 3 ++- .../Test/_files/product_configurable_rollback.php | 3 ++- .../ResourceModel/Product/StockStatusBaseSelectProcessor.php | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php index 8ad2d2f0b58b..c8dcc86ae1ad 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php @@ -14,12 +14,13 @@ use Magento\ConfigurableProduct\Helper\Product\Options\Factory; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Eav\Api\Data\AttributeOptionInterface; -use Magento\TestFramework\Helper\Bootstrap; use Magento\Store\Model\Website; +use Magento\TestFramework\Helper\Bootstrap; \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute.php'; +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' + . '_files/configurable_attribute.php'; /** @var ProductRepositoryInterface $productRepository */ $productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php index 20bc3448a24c..91bfd17d8eae 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php @@ -18,7 +18,8 @@ \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute.php'; +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' + . '_files/configurable_attribute.php'; /** @var ProductRepositoryInterface $productRepository */ $productRepository = Bootstrap::getObjectManager() diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php index 5a7431a7055c..d2f5e5ee93d0 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php @@ -30,7 +30,8 @@ } } -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_rollback.php'; +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' + . '_files/configurable_attribute_rollback.php'; $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php index 910db0410162..2300209b99ee 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php @@ -30,7 +30,8 @@ } } -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_rollback.php'; +require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' + . '_files/configurable_attribute_rollback.php'; $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php index 69ae7296c419..e41e43a0a9dd 100644 --- a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php +++ b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\InventoryCatalog\Model\ResourceModel\Product; From 99c71c048b84e6c4aa4cea50dd40002ba33aa355 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Mon, 5 Feb 2018 11:07:18 +0200 Subject: [PATCH 04/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../InventoryApi/Test/_files/product_configurable.php | 1 - .../Test/_files/product_configurable_out_of_stock.php | 1 + .../_files/product_configurable_out_of_stock_rollback.php | 1 + .../Test/_files/product_configurable_rollback.php | 1 + .../ResourceModel/Product/StockStatusBaseSelectProcessor.php | 5 ++--- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php index c8dcc86ae1ad..7ee181af7834 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable.php @@ -146,4 +146,3 @@ $product->getSku(), [2] ); - diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php index 91bfd17d8eae..6c1aa4ef70cb 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product; diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php index d2f5e5ee93d0..8786010c1e6b 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php index 2300209b99ee..ce1f65f8d13f 100644 --- a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php +++ b/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); diff --git a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php index e41e43a0a9dd..f3df2b7ce1b2 100644 --- a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php +++ b/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php @@ -61,10 +61,9 @@ public function process(Select $select) /** @var Select $select */ $select->join( ['stock' => $stockTable], - sprintf('stock.sku = parent.sku'), + sprintf('stock.sku = %s.sku', BaseSelectProcessorInterface::PRODUCT_TABLE_ALIAS), [] - )->where('stock.quantity > 0'); - //todo https://github.com/magento-engcom/msi/pull/442 )->where('stock.is_salable = ?', 1); + )->where('stock.is_salable = ?', 1); } return $select; From b30f59c2268cfef64f51f830914d67528dfeceae Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 9 Feb 2018 17:01:31 +0200 Subject: [PATCH 05/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- app/code/Magento/InventoryCatalog/etc/di.xml | 7 ----- .../StockStatusBaseSelectProcessor.php | 28 +++++++++++++++++-- ...sBaseSelectProcessorOnDefaultStockTest.php | 2 +- .../StockStatusBaseSelectProcessorTest.php | 10 ++++--- .../Test/_files/product_configurable.php | 0 .../product_configurable_out_of_stock.php | 0 ...uct_configurable_out_of_stock_rollback.php | 0 .../_files/product_configurable_rollback.php | 0 .../Test/_files/source_items_configurable.php | 0 .../source_items_configurable_rollback.php | 0 .../composer.json | 8 +++++- .../InventoryConfigurableProduct/etc/di.xml | 16 +++++++++++ 12 files changed, 55 insertions(+), 16 deletions(-) rename app/code/Magento/{InventoryCatalog => InventoryConfigurableProduct}/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php (69%) rename app/code/Magento/{InventoryCatalog/Test/Integration/CatalogInventory => InventoryConfigurableProduct/Test}/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php (94%) rename app/code/Magento/{InventoryCatalog/Test/Integration/CatalogInventory => InventoryConfigurableProduct/Test}/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php (89%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/product_configurable.php (100%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/product_configurable_out_of_stock.php (100%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/product_configurable_out_of_stock_rollback.php (100%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/product_configurable_rollback.php (100%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/source_items_configurable.php (100%) rename app/code/Magento/{InventoryApi => InventoryConfigurableProduct}/Test/_files/source_items_configurable_rollback.php (100%) create mode 100644 app/code/Magento/InventoryConfigurableProduct/etc/di.xml diff --git a/app/code/Magento/InventoryCatalog/etc/di.xml b/app/code/Magento/InventoryCatalog/etc/di.xml index d3c51c630ce1..990f3d3c4454 100644 --- a/app/code/Magento/InventoryCatalog/etc/di.xml +++ b/app/code/Magento/InventoryCatalog/etc/di.xml @@ -62,11 +62,4 @@ - - - - Magento\InventoryCatalog\Model\ResourceModel\Product\StockStatusBaseSelectProcessor - - - diff --git a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php similarity index 69% rename from app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php rename to app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php index f3df2b7ce1b2..855aa1faa8ad 100644 --- a/app/code/Magento/InventoryCatalog/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php +++ b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/Product/StockStatusBaseSelectProcessor.php @@ -5,13 +5,16 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Model\ResourceModel\Product; +namespace Magento\InventoryConfigurableProduct\Model\ResourceModel\Product; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\Framework\DB\Select; use Magento\InventoryCatalog\Model\GetStockIdForCurrentWebsite; use Magento\InventoryIndexer\Model\StockIndexTableNameResolverInterface; +use Magento\InventorySalesApi\Api\Data\SalesChannelInterface; +use Magento\InventorySalesApi\Api\StockResolverInterface; +use Magento\Store\Model\StoreManagerInterface; /** * Add stock item filter to selects. @@ -33,19 +36,35 @@ class StockStatusBaseSelectProcessor implements BaseSelectProcessorInterface */ private $getStockIdForCurrentWebsite; + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var StockResolverInterface + */ + private $stockResolver; + /** * @param StockIndexTableNameResolverInterface $stockIndexTableNameResolver * @param StockConfigurationInterface $stockConfig * @param GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite + * @param StoreManagerInterface $storeManager + * @param StockResolverInterface $stockResolver */ public function __construct( StockIndexTableNameResolverInterface $stockIndexTableNameResolver, StockConfigurationInterface $stockConfig, - GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite + GetStockIdForCurrentWebsite $getStockIdForCurrentWebsite, + StoreManagerInterface $storeManager, + StockResolverInterface $stockResolver ) { $this->stockIndexTableNameResolver = $stockIndexTableNameResolver; $this->stockConfig = $stockConfig; $this->getStockIdForCurrentWebsite = $getStockIdForCurrentWebsite; + $this->storeManager = $storeManager; + $this->stockResolver = $stockResolver; } /** @@ -55,7 +74,10 @@ public function __construct( public function process(Select $select) { if (!$this->stockConfig->isShowOutOfStock()) { - $stockId = $this->getStockIdForCurrentWebsite->execute(); + $websiteCode = $this->storeManager->getWebsite()->getCode(); + $stock = $this->stockResolver->get(SalesChannelInterface::TYPE_WEBSITE, $websiteCode); + $stockId = (int)$stock->getStockId(); + $stockTable = $this->stockIndexTableNameResolver->execute($stockId); /** @var Select $select */ diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php similarity index 94% rename from app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php rename to app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php index f49ce1fa9514..a3f75e6fba63 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Product; +namespace Magento\InventoryConfigurableProduct\Test\Integration\CatalogInventory\Model\ResourceModel\Product; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; use Magento\Framework\App\ResourceConnection; diff --git a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php similarity index 89% rename from app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php rename to app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php index f33a16573bdb..12fbbb96f08b 100644 --- a/app/code/Magento/InventoryCatalog/Test/Integration/CatalogInventory/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryCatalog\Test\Integration\CatalogInventory\Model\ResourceModel\Product; +namespace Magento\InventoryConfigurableProduct\Test\Integration\CatalogInventory\Model\ResourceModel\Product; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; use Magento\Framework\App\ResourceConnection; @@ -48,19 +48,21 @@ protected function setUp() $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); } + // @codingStandardsIgnoreStart /** * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/product_configurable.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.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_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php * * @return void */ + // @codingStandardsIgnoreEnd public function testProcess() { $this->storeManager->setCurrentStore('store_for_us_website'); diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/product_configurable.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/product_configurable_out_of_stock_rollback.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php diff --git a/app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/product_configurable_rollback.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php diff --git a/app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/source_items_configurable.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php diff --git a/app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable_rollback.php similarity index 100% rename from app/code/Magento/InventoryApi/Test/_files/source_items_configurable_rollback.php rename to app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable_rollback.php diff --git a/app/code/Magento/InventoryConfigurableProduct/composer.json b/app/code/Magento/InventoryConfigurableProduct/composer.json index 8b21cd3cb47f..2dd48ea0381e 100644 --- a/app/code/Magento/InventoryConfigurableProduct/composer.json +++ b/app/code/Magento/InventoryConfigurableProduct/composer.json @@ -3,7 +3,13 @@ "description": "N/A", "require": { "php": "7.0.2|7.0.4|~7.0.6|~7.1.0", - "magento/framework": "100.2.*" + "magento/framework": "100.2.*", + "magento/module-inventory-sales-api": "100.0.0-dev", + "magento/module-inventory-catalog": "100.0.0-dev", + "magento/module-inventory-indexer": "100.0.0-dev", + "magento/module-store": "100.3.*", + "magento/module-catalog-inventory": "100.3.*", + "magento/module-catalog": "101.2.*" }, "type": "magento2-module", "version": "100.0.0-dev", diff --git a/app/code/Magento/InventoryConfigurableProduct/etc/di.xml b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml new file mode 100644 index 000000000000..4730fcb0417b --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml @@ -0,0 +1,16 @@ + + + + + + + Magento\InventoryConfigurableProduct\Model\ResourceModel\Product\StockStatusBaseSelectProcessor + + + + From 9b57c1377820edeeec1b432062f41937cbdebba3 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 9 Feb 2018 17:38:06 +0200 Subject: [PATCH 06/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../StockStatusBaseSelectProcessorOnDefaultStockTest.php | 2 +- .../Product/StockStatusBaseSelectProcessorTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/code/Magento/InventoryConfigurableProduct/Test/{ => Integration}/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php (97%) rename app/code/Magento/InventoryConfigurableProduct/Test/{ => Integration}/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php (98%) diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php similarity index 97% rename from app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php rename to app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php index a3f75e6fba63..a1254d644c54 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryConfigurableProduct\Test\Integration\CatalogInventory\Model\ResourceModel\Product; +namespace Magento\InventoryConfigurableProduct\Test\Integration\Model\ResourceModel\Product; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; use Magento\Framework\App\ResourceConnection; diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php similarity index 98% rename from app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php rename to app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php index 12fbbb96f08b..8b0a5ac2ac71 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\InventoryConfigurableProduct\Test\Integration\CatalogInventory\Model\ResourceModel\Product; +namespace Magento\InventoryConfigurableProduct\Test\Integration\Model\ResourceModel\Product; use Magento\Catalog\Model\ResourceModel\Product\BaseSelectProcessorInterface; use Magento\Framework\App\ResourceConnection; From 2c755d30034b87cee6cf965782b7d96f5bf8dc65 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 13 Feb 2018 13:26:14 +0200 Subject: [PATCH 07/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../GetConfigurableCondition.php | 29 +++ ...sBaseSelectProcessorOnDefaultStockTest.php | 65 ------- .../StockStatusBaseSelectProcessorTest.php | 101 ----------- .../Price/FinalPriceResolverTest.php | 116 ++++++++++++ .../Price/LowestPriceOptionProviderTest.php | 133 ++++++++++++++ .../Price/RegularPriceResolverTest.php | 116 ++++++++++++ .../Integration/Price/SpecialPriceTest.php | 130 +++++++++++++ .../Test/Integration/Price/TierPriceTest.php | 171 ++++++++++++++++++ .../Test/_files/product_configurable.php | 9 +- .../product_configurable_out_of_stock.php | 150 --------------- ...uct_configurable_out_of_stock_rollback.php | 38 ---- .../_files/product_configurable_rollback.php | 4 - .../set_product_configurable_out_of_stock.php | 30 +++ .../Test/_files/source_items_configurable.php | 18 -- .../InventoryConfigurableProduct/etc/di.xml | 7 + .../Controller/Adminhtml/ProductTest.php | 2 - .../Indexer/Price/ConfigurableTest.php | 4 - .../Price/LowestPriceOptionProviderTest.php | 8 - .../product_configurable_out_of_stock.php | 142 --------------- ...uct_configurable_out_of_stock_rollback.php | 36 ---- 20 files changed, 738 insertions(+), 571 deletions(-) create mode 100644 app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php delete mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorOnDefaultStockTest.php delete mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/FinalPriceResolverTest.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/LowestPriceOptionProviderTest.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/RegularPriceResolverTest.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/SpecialPriceTest.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php delete mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php delete mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php create mode 100644 app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php delete mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php delete mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php diff --git a/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php new file mode 100644 index 000000000000..e221640b536f --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php @@ -0,0 +1,29 @@ +productResourceModel = Bootstrap::getObjectManager()->get(BaseSelectProcessorInterface::class); - $this->resourceConnection = Bootstrap::getObjectManager()->get(ResourceConnection::class); - } - - /** - * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php - * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php - * - * @return void - */ - public function testProcess() - { - $select = $this->resourceConnection->getConnection()->select(); - $productTable = $this->resourceConnection->getTableName('catalog_product_entity'); - $select - ->from(['parent' => $productTable]) - ->joinInner( - ['link' => $this->resourceConnection->getTableName('catalog_product_relation')], - 'link.parent_id = parent.entity_id', - [] - ) - ->joinInner( - ['child' => $productTable], - 'child.entity_id = link.child_id', - [] - ); - - $this->productResourceModel->process($select); - - self::assertEquals(2, count($select->query()->fetchAll())); - } -} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php deleted file mode 100644 index 8b0a5ac2ac71..000000000000 --- a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Model/ResourceModel/Product/StockStatusBaseSelectProcessorTest.php +++ /dev/null @@ -1,101 +0,0 @@ -productResourceModel = Bootstrap::getObjectManager()->get(BaseSelectProcessorInterface::class); - $this->resourceConnection = Bootstrap::getObjectManager()->get(ResourceConnection::class); - $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); - $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); - } - - // @codingStandardsIgnoreStart - /** - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php - * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php - * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php - * - * @return void - */ - // @codingStandardsIgnoreEnd - public function testProcess() - { - $this->storeManager->setCurrentStore('store_for_us_website'); - - $select = $this->resourceConnection->getConnection()->select(); - $productTable = $this->resourceConnection->getTableName('catalog_product_entity'); - $select - ->from(['parent' => $productTable]) - ->joinInner( - ['link' => $this->resourceConnection->getTableName('catalog_product_relation')], - 'link.parent_id = parent.entity_id', - [] - ) - ->joinInner( - ['child' => $productTable], - 'child.entity_id = link.child_id', - [] - ); - - $this->productResourceModel->process($select); - - self::assertEquals(2, count($select->query()->fetchAll())); - } - - /** - * @inheritdoc - */ - protected function tearDown() - { - parent::tearDown(); - - if (null !== $this->storeCodeBefore) { - $this->storeManager->setCurrentStore($this->storeCodeBefore); - } - } -} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/FinalPriceResolverTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/FinalPriceResolverTest.php new file mode 100644 index 000000000000..e9ea4cb55831 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/FinalPriceResolverTest.php @@ -0,0 +1,116 @@ +storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + $finalPrice = Bootstrap::getObjectManager()->get(FinalPriceResolver::class); + + $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( + ConfigurablePriceResolver::class, + ['priceResolver' => $finalPrice] + ); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceWithAllChildren() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals(10, $actualPrice); + } + + /// @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceIfOneOfChildIsOutOfStock() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + self::assertEquals(20, $actualPrice); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/LowestPriceOptionProviderTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/LowestPriceOptionProviderTest.php new file mode 100644 index 000000000000..bf8e6a22c137 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/LowestPriceOptionProviderTest.php @@ -0,0 +1,133 @@ +storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + $finalPrice = Bootstrap::getObjectManager()->get(FinalPriceResolver::class); + + $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( + ConfigurablePriceResolver::class, + ['priceResolver' => $finalPrice] + ); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testGetProductsWithAllChildren() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); + self::assertCount(1, $lowestPriceChildrenProducts); + $lowestPriceChildrenProduct = reset($lowestPriceChildrenProducts); + self::assertEquals(10, $lowestPriceChildrenProduct->getPrice()); + } + + /// @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testGetProductsIfOneOfChildIsOutOfStock() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); + self::assertCount(1, $lowestPriceChildrenProducts); + $lowestPriceChildrenProduct = reset($lowestPriceChildrenProducts); + self::assertEquals(20, $lowestPriceChildrenProduct->getPrice()); + } + + /** + * As LowestPriceOptionsProviderInterface used multiple times in scope + * of one test we need to always recreate it and prevent internal caching in property + * + * @return LowestPriceOptionsProviderInterface + */ + private function createLowestPriceOptionsProvider() + { + return Bootstrap::getObjectManager()->create( + LowestPriceOptionsProviderInterface::class + ); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/RegularPriceResolverTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/RegularPriceResolverTest.php new file mode 100644 index 000000000000..b088c7da4699 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/RegularPriceResolverTest.php @@ -0,0 +1,116 @@ +storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + $regularPrice = Bootstrap::getObjectManager()->get(RegularPriceResolver::class); + + $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( + ConfigurablePriceResolver::class, + ['priceResolver' => $regularPrice] + ); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceWithAllChildren() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals(10, $actualPrice); + } + + /// @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceIfOneOfChildIsOutOfStock() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + self::assertEquals(20, $actualPrice); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/SpecialPriceTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/SpecialPriceTest.php new file mode 100644 index 000000000000..f925910dfe67 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/SpecialPriceTest.php @@ -0,0 +1,130 @@ +storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + $finalPrice = Bootstrap::getObjectManager()->get(FinalPriceResolver::class); + + $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( + ConfigurablePriceResolver::class, + ['priceResolver' => $finalPrice] + ); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePrice() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $specialPrice = 2; + + /** @var Product $childProduct */ + $childProduct = $this->productRepository->get('simple_10', true); + $childProduct->setData('special_price', $specialPrice); + $this->productRepository->save($childProduct); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals($specialPrice, $actualPrice); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceIfChildWithSpecialPriceOutOfStock() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + /** @var Product $childProduct */ + $childProduct = $this->productRepository->get('simple_10', true); + $childProduct->setData('special_price', 2); + $this->productRepository->save($childProduct); + + $configurableProduct = $this->productRepository->get('configurable', false, null, true); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals(20, $actualPrice); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php new file mode 100644 index 000000000000..8661aab8b8a1 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php @@ -0,0 +1,171 @@ +storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $this->productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); + $this->storeCodeBefore = $this->storeManager->getStore()->getCode(); + $finalPrice = Bootstrap::getObjectManager()->get(FinalPriceResolver::class); + $this->extensionAttributesFactory = Bootstrap::getObjectManager()->get(ProductTierPriceExtensionFactory::class); + $this->tierPriceFactory = Bootstrap::getObjectManager()->get(ProductTierPriceInterfaceFactory::class); + + + $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( + ConfigurablePriceResolver::class, + ['priceResolver' => $finalPrice] + ); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePrice() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + $tierPrice = 3; + + /** @var Product $simpleProduct */ + $simpleProduct = $this->productRepository->get('simple_10', true); + + $simpleProduct->setTierPrice([ + [ + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, + 'price_qty' => 1, + 'price' => $tierPrice, + ], + ]); + $this->productRepository->save($simpleProduct); + + $configurableProduct = $this->productRepository->get( + 'configurable', + false, + $this->storeManager->getStore()->getStoreId(), + true + ); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals($tierPrice, $actualPrice); + } + + // @codingStandardsIgnoreStart + /** + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/websites_with_stores.php + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.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/InventoryConfigurableProduct/Test/_files/source_items_configurable.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php + * @magentoDataFixture ../../../../app/code/Magento/InventorySalesApi/Test/_files/stock_website_sales_channels.php + * @magentoDataFixture ../../../../app/code/Magento/InventoryIndexer/Test/_files/reindex_inventory.php + * @return void + */ + // @codingStandardsIgnoreEnd + public function testResolvePriceIfChildWithTierPriceIsOutOfStock() + { + $this->storeManager->setCurrentStore('store_for_us_website'); + + /** @var Product $simpleProduct */ + $simpleProduct = $this->productRepository->get('simple_10', true); + + $simpleProduct->setTierPrice([ + [ + 'website_id' => 0, + 'cust_group' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, + 'price_qty' => 1, + 'price' => 3, + ], + ]); + $this->productRepository->save($simpleProduct); + + $configurableProduct = $this->productRepository->get( + 'configurable', + false, + $this->storeManager->getStore()->getStoreId(), + true + ); + $actualPrice = $this->configurablePriceResolver->resolvePrice($configurableProduct); + + self::assertEquals(20, $actualPrice); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + if (null !== $this->storeCodeBefore) { + $this->storeManager->setCurrentStore($this->storeCodeBefore); + } + } +} diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php index 7ee181af7834..6e00a1b5a604 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable.php @@ -14,14 +14,12 @@ use Magento\ConfigurableProduct\Helper\Product\Options\Factory; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\Eav\Api\Data\AttributeOptionInterface; +use Magento\Eav\Model\Config; use Magento\Store\Model\Website; use Magento\TestFramework\Helper\Bootstrap; \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' - . '_files/configurable_attribute.php'; - /** @var ProductRepositoryInterface $productRepository */ $productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class); @@ -32,6 +30,11 @@ $website = Bootstrap::getObjectManager()->create(Website::class); $website->load('us_website', 'code'); $websiteIds = [$website->getId()]; + +/** @var Config $eavConfig */ +$eavConfig = Bootstrap::getObjectManager()->create(Config::class); +$attribute = $eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'test_configurable'); + /* Create simple products per each option value*/ /** @var AttributeOptionInterface[] $options */ $options = $attribute->getOptions(); diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php deleted file mode 100644 index 6c1aa4ef70cb..000000000000 --- a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock.php +++ /dev/null @@ -1,150 +0,0 @@ -reinitialize(); - -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' - . '_files/configurable_attribute.php'; - -/** @var ProductRepositoryInterface $productRepository */ -$productRepository = Bootstrap::getObjectManager() - ->create(ProductRepositoryInterface::class); - -/** @var $installer CategorySetup */ -$installer = Bootstrap::getObjectManager()->create(CategorySetup::class); - -/** @var Website $website */ -$website = Bootstrap::getObjectManager()->create(Website::class); -$website->load('us_website', 'code'); -$websiteIds = [$website->getId()]; - -/* Create simple products per each option value*/ -/** @var AttributeOptionInterface[] $options */ -$options = $attribute->getOptions(); - -$attributeValues = []; -$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); -$associatedProductIds = []; -$productIds = [30, 40]; -array_shift($options); //remove the first option which is empty - -foreach ($options as $option) { - /** @var $product Product */ - $product = Bootstrap::getObjectManager()->create(Product::class); - $productId = array_shift($productIds); - $product->setTypeId(Type::TYPE_SIMPLE) - ->setId($productId) - ->setAttributeSetId($attributeSetId) - ->setWebsiteIds($websiteIds) - ->setName('Configurable Option' . $option->getLabel()) - ->setSku('simple_' . $productId) - ->setPrice($productId) - ->setTestConfigurable($option->getValue()) - ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE) - ->setStatus(Status::STATUS_ENABLED) - ->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); - - $product = $productRepository->save($product); - - /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ - $stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); - $stockItem->load($productId, 'product_id'); - - if (!$stockItem->getProductId()) { - $stockItem->setProductId($productId); - } - $stockItem->setUseConfigManageStock(1); - $stockItem->setQty(0); - $stockItem->setIsQtyDecimal(0); - $stockItem->setIsInStock(0); - $stockItem->save(); - - $attributeValues[] = [ - 'label' => 'test', - 'attribute_id' => $attribute->getId(), - 'value_index' => $option->getValue(), - ]; - $associatedProductIds[] = $product->getId(); -} - -/** @var $product Product */ -$product = Bootstrap::getObjectManager()->create(Product::class); - -/** @var Factory $optionsFactory */ -$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class); - -$configurableAttributesData = [ - [ - 'attribute_id' => $attribute->getId(), - 'code' => $attribute->getAttributeCode(), - 'label' => $attribute->getStoreLabel(), - 'position' => '0', - 'values' => $attributeValues, - ], -]; - -$configurableOptions = $optionsFactory->create($configurableAttributesData); - -$extensionConfigurableAttributes = $product->getExtensionAttributes(); -$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions); -$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds); - -$product->setExtensionAttributes($extensionConfigurableAttributes); - -// Remove any previously created product with the same id. -/** @var \Magento\Framework\Registry $registry */ -$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); -try { - $productToDelete = $productRepository->getById(2); - $productRepository->delete($productToDelete); - - /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */ - $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class); - $itemResource->getConnection()->delete( - $itemResource->getMainTable(), - 'product_id = ' . $productToDelete->getId() - ); -} catch (\Exception $e) { - // Nothing to remove -} -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); - -$product->setTypeId(Configurable::TYPE_CODE) - ->setId(2) - ->setAttributeSetId($attributeSetId) - ->setWebsiteIds($websiteIds) - ->setName('Configurable Product Out of Stock') - ->setSku('configurable_out_of_stock') - ->setVisibility(Visibility::VISIBILITY_BOTH) - ->setStatus(Status::STATUS_ENABLED) - ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 0]); - -$productRepository->save($product); - -/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */ -$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); - -$categoryLinkManagement->assignProductToCategories( - $product->getSku(), - [2] -); diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php deleted file mode 100644 index 8786010c1e6b..000000000000 --- a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_out_of_stock_rollback.php +++ /dev/null @@ -1,38 +0,0 @@ -get(\Magento\Framework\Registry::class); - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); - -/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ -$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); - -foreach (['simple_30', 'simple_40', 'configurable_out_of_stock'] as $sku) { - try { - $product = $productRepository->get($sku, false, null, true); - - $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); - $stockStatus->load($product->getEntityId(), 'product_id'); - $stockStatus->delete(); - - $productRepository->delete($product); - } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - //Product already removed - } -} - -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' - . '_files/configurable_attribute_rollback.php'; - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php index ce1f65f8d13f..eff19d1da23f 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/_files/product_configurable_rollback.php @@ -30,9 +30,5 @@ //Product already removed } } - -require __DIR__ . '/../../../../../../dev/tests/integration/testsuite/Magento/ConfigurableProduct/' - . '_files/configurable_attribute_rollback.php'; - $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php new file mode 100644 index 000000000000..a23b78169e77 --- /dev/null +++ b/app/code/Magento/InventoryConfigurableProduct/Test/_files/set_product_configurable_out_of_stock.php @@ -0,0 +1,30 @@ +create(SourceItemRepositoryInterface::class); + +$searchCriteriaBuilder = Bootstrap::getObjectManager()->create(SearchCriteriaBuilder::class); +$searchCriteria = $searchCriteriaBuilder + ->addFilter(SourceItemInterface::SKU, 'simple_10') + ->addFilter(SourceItemInterface::SOURCE_CODE, 'us-1') + ->create(); + +$sourceItems = $sourceItemRepository->getList($searchCriteria)->getItems(); +$sourceItem = reset($sourceItems); +$sourceItem->setQuantity(0); +$sourceItem->setStatus(0); + +/** @var SourceItemsSave $sourceItemSave */ +$sourceItemSave = Bootstrap::getObjectManager()->create(SourceItemsSave::class); +$sourceItemSave->execute([$sourceItem]); diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php b/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php index 695a4cc05327..2af51efd6a91 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/_files/source_items_configurable.php @@ -19,24 +19,6 @@ $sourceItemsSave = Bootstrap::getObjectManager()->get(SourceItemsSaveInterface::class); $sourcesItemsData = [ - [ - SourceItemInterface::SOURCE_CODE => 'us-1', - SourceItemInterface::SKU => 'configurable_out_of_stock', - SourceItemInterface::QUANTITY => 0, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'us-1', - SourceItemInterface::SKU => 'simple_30', - SourceItemInterface::QUANTITY => 0, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, - ], - [ - SourceItemInterface::SOURCE_CODE => 'us-1', - SourceItemInterface::SKU => 'simple_40', - SourceItemInterface::QUANTITY => 0, - SourceItemInterface::STATUS => SourceItemInterface::STATUS_OUT_OF_STOCK, - ], [ SourceItemInterface::SOURCE_CODE => 'us-1', SourceItemInterface::SKU => 'configurable', diff --git a/app/code/Magento/InventoryConfigurableProduct/etc/di.xml b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml index 4730fcb0417b..ee78eb69ad2c 100644 --- a/app/code/Magento/InventoryConfigurableProduct/etc/di.xml +++ b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml @@ -13,4 +13,11 @@ + + + + Magento\InventoryConfigurableProduct\Model\ResourceModel\IsSalableCondition\GetConfigurableCondition + + + diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php index fc571d13aee5..4254a6ce9c71 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php @@ -21,8 +21,6 @@ class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendControl */ public function testSaveActionAssociatedProductIds() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - $associatedProductIds = ['3', '14', '15', '92']; $associatedProductIdsJSON = json_encode($associatedProductIds); $this->getRequest()->setPostValue( diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php index a0d00f661188..9d6ef7dfb1ae 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/ResourceModel/Product/Indexer/Price/ConfigurableTest.php @@ -39,8 +39,6 @@ protected function setUp() */ public function testGetProductFinalPriceIfOneOfChildIsDisabled() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - /** @var Collection $collection */ $collection = Bootstrap::getObjectManager()->get(CollectionFactory::class) ->create(); @@ -75,8 +73,6 @@ public function testGetProductFinalPriceIfOneOfChildIsDisabled() */ public function testGetProductFinalPriceIfOneOfChildIsDisabledPerStore() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - /** @var Collection $collection */ $collection = Bootstrap::getObjectManager()->get(CollectionFactory::class) ->create(); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php index 44da28e2dbd9..c24baa36461c 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Price/LowestPriceOptionProviderTest.php @@ -34,8 +34,6 @@ protected function setUp() */ public function testGetProductsIfOneOfChildIsDisabled() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - $configurableProduct = $this->productRepository->get('configurable', false, null, true); $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); self::assertCount(1, $lowestPriceChildrenProducts); @@ -67,8 +65,6 @@ public function testGetProductsIfOneOfChildIsDisabled() */ public function testGetProductsIfOneOfChildIsDisabledPerStore() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - $configurableProduct = $this->productRepository->get('configurable', false, null, true); $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); self::assertCount(1, $lowestPriceChildrenProducts); @@ -101,8 +97,6 @@ public function testGetProductsIfOneOfChildIsDisabledPerStore() */ public function testGetProductsIfOneOfChildIsOutOfStock() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - $configurableProduct = $this->productRepository->get('configurable', false, null, true); $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); self::assertCount(1, $lowestPriceChildrenProducts); @@ -131,8 +125,6 @@ public function testGetProductsIfOneOfChildIsOutOfStock() */ public function testGetProductsIfOneOfChildrenIsAssignedToOtherWebsite() { - $this->markTestSkipped('https://github.com/magento-engcom/msi/issues/456'); - $configurableProduct = $this->productRepository->getById(1, false, null, true); $lowestPriceChildrenProducts = $this->createLowestPriceOptionsProvider()->getProducts($configurableProduct); self::assertCount(1, $lowestPriceChildrenProducts); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php deleted file mode 100644 index fe7a86716de5..000000000000 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock.php +++ /dev/null @@ -1,142 +0,0 @@ -reinitialize(); - -require __DIR__ . '/configurable_attribute.php'; - -/** @var ProductRepositoryInterface $productRepository */ -$productRepository = Bootstrap::getObjectManager() - ->create(ProductRepositoryInterface::class); - -/** @var $installer CategorySetup */ -$installer = Bootstrap::getObjectManager()->create(CategorySetup::class); - -/* Create simple products per each option value*/ -/** @var AttributeOptionInterface[] $options */ -$options = $attribute->getOptions(); - -$attributeValues = []; -$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); -$associatedProductIds = []; -$productIds = [30, 40]; -array_shift($options); //remove the first option which is empty - -foreach ($options as $option) { - /** @var $product Product */ - $product = Bootstrap::getObjectManager()->create(Product::class); - $productId = array_shift($productIds); - $product->setTypeId(Type::TYPE_SIMPLE) - ->setId($productId) - ->setAttributeSetId($attributeSetId) - ->setWebsiteIds([1]) - ->setName('Configurable Option' . $option->getLabel()) - ->setSku('simple_' . $productId) - ->setPrice($productId) - ->setTestConfigurable($option->getValue()) - ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE) - ->setStatus(Status::STATUS_ENABLED) - ->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]); - - $product = $productRepository->save($product); - - /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ - $stockItem = Bootstrap::getObjectManager()->create(\Magento\CatalogInventory\Model\Stock\Item::class); - $stockItem->load($productId, 'product_id'); - - if (!$stockItem->getProductId()) { - $stockItem->setProductId($productId); - } - $stockItem->setUseConfigManageStock(1); - $stockItem->setQty(0); - $stockItem->setIsQtyDecimal(0); - $stockItem->setIsInStock(0); - $stockItem->save(); - - $attributeValues[] = [ - 'label' => 'test', - 'attribute_id' => $attribute->getId(), - 'value_index' => $option->getValue(), - ]; - $associatedProductIds[] = $product->getId(); -} - -/** @var $product Product */ -$product = Bootstrap::getObjectManager()->create(Product::class); - -/** @var Factory $optionsFactory */ -$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class); - -$configurableAttributesData = [ - [ - 'attribute_id' => $attribute->getId(), - 'code' => $attribute->getAttributeCode(), - 'label' => $attribute->getStoreLabel(), - 'position' => '0', - 'values' => $attributeValues, - ], -]; - -$configurableOptions = $optionsFactory->create($configurableAttributesData); - -$extensionConfigurableAttributes = $product->getExtensionAttributes(); -$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions); -$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds); - -$product->setExtensionAttributes($extensionConfigurableAttributes); - -// Remove any previously created product with the same id. -/** @var \Magento\Framework\Registry $registry */ -$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); -try { - $productToDelete = $productRepository->getById(2); - $productRepository->delete($productToDelete); - - /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */ - $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class); - $itemResource->getConnection()->delete( - $itemResource->getMainTable(), - 'product_id = ' . $productToDelete->getId() - ); -} catch (\Exception $e) { - // Nothing to remove -} -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); - -$product->setTypeId(Configurable::TYPE_CODE) - ->setId(2) - ->setAttributeSetId($attributeSetId) - ->setWebsiteIds([1]) - ->setName('Configurable Product Out of Stock') - ->setSku('configurable_out_of_stock') - ->setVisibility(Visibility::VISIBILITY_BOTH) - ->setStatus(Status::STATUS_ENABLED) - ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 0]); - -$productRepository->save($product); - -/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */ -$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); - -$categoryLinkManagement->assignProductToCategories( - $product->getSku(), - [2] -); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php deleted file mode 100644 index 8d655a39a827..000000000000 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_out_of_stock_rollback.php +++ /dev/null @@ -1,36 +0,0 @@ -get(\Magento\Framework\Registry::class); - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', true); - -/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ -$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); - -foreach (['simple_30', 'simple_40', 'configurable_out_of_stock'] as $sku) { - try { - $product = $productRepository->get($sku, false, null, true); - - $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class); - $stockStatus->load($product->getEntityId(), 'product_id'); - $stockStatus->delete(); - - $productRepository->delete($product); - } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { - //Product already removed - } -} - -require __DIR__ . '/configurable_attribute_rollback.php'; - -$registry->unregister('isSecureArea'); -$registry->register('isSecureArea', false); From fbbf428dffb8f2794bc8282bbc00a2987ccb6be2 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 13 Feb 2018 14:34:39 +0200 Subject: [PATCH 08/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../Test/Integration/Price/TierPriceTest.php | 1 - app/code/Magento/InventoryConfigurableProduct/composer.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php index 8661aab8b8a1..2afcb44815c4 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php +++ b/app/code/Magento/InventoryConfigurableProduct/Test/Integration/Price/TierPriceTest.php @@ -63,7 +63,6 @@ protected function setUp() $this->extensionAttributesFactory = Bootstrap::getObjectManager()->get(ProductTierPriceExtensionFactory::class); $this->tierPriceFactory = Bootstrap::getObjectManager()->get(ProductTierPriceInterfaceFactory::class); - $this->configurablePriceResolver = Bootstrap::getObjectManager()->create( ConfigurablePriceResolver::class, ['priceResolver' => $finalPrice] diff --git a/app/code/Magento/InventoryConfigurableProduct/composer.json b/app/code/Magento/InventoryConfigurableProduct/composer.json index 2dd48ea0381e..bdd4e831463b 100644 --- a/app/code/Magento/InventoryConfigurableProduct/composer.json +++ b/app/code/Magento/InventoryConfigurableProduct/composer.json @@ -7,6 +7,7 @@ "magento/module-inventory-sales-api": "100.0.0-dev", "magento/module-inventory-catalog": "100.0.0-dev", "magento/module-inventory-indexer": "100.0.0-dev", + "magento/module-inventory": "100.0.0-dev", "magento/module-store": "100.3.*", "magento/module-catalog-inventory": "100.3.*", "magento/module-catalog": "101.2.*" From 7059d4c5a9bb0f430c031b65da4530a922411da8 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Mon, 12 Mar 2018 16:43:49 +0200 Subject: [PATCH 09/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- .../GetConfigurableCondition.php | 6 +++--- app/code/Magento/InventoryConfigurableProduct/etc/di.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/{IsSalableCondition => IsStockItemSalableCondition}/GetConfigurableCondition.php (71%) diff --git a/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsStockItemSalableCondition/GetConfigurableCondition.php similarity index 71% rename from app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php rename to app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsStockItemSalableCondition/GetConfigurableCondition.php index e221640b536f..aca1cd9ca531 100644 --- a/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsSalableCondition/GetConfigurableCondition.php +++ b/app/code/Magento/InventoryConfigurableProduct/Model/ResourceModel/IsStockItemSalableCondition/GetConfigurableCondition.php @@ -5,16 +5,16 @@ */ declare(strict_types=1); -namespace Magento\InventoryConfigurableProduct\Model\ResourceModel\IsSalableCondition; +namespace Magento\InventoryConfigurableProduct\Model\ResourceModel\IsStockItemSalableCondition; use Magento\Framework\DB\Select; -use Magento\Inventory\Model\ResourceModel\IsSalableCondition\GetIsSalableConditionInterface; +use Magento\InventorySales\Model\ResourceModel\IsStockItemSalableCondition\GetIsStockItemSalableConditionInterface; /** * //todo https://github.com/magento-engcom/msi/issues/524 * Condition for configurable products. */ -class GetConfigurableCondition implements GetIsSalableConditionInterface +class GetConfigurableCondition implements GetIsStockItemSalableConditionInterface { /** * @inheritdoc diff --git a/app/code/Magento/InventoryConfigurableProduct/etc/di.xml b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml index dd39c8e38850..f77c7e46dafb 100644 --- a/app/code/Magento/InventoryConfigurableProduct/etc/di.xml +++ b/app/code/Magento/InventoryConfigurableProduct/etc/di.xml @@ -21,10 +21,10 @@ - + - - Magento\InventoryConfigurableProduct\Model\ResourceModel\IsSalableCondition\GetConfigurableCondition + + Magento\InventoryConfigurableProduct\Model\ResourceModel\IsStockItemSalableCondition\GetConfigurableCondition From 34f00f71dea2ba6c1164791a4b090e35aab53247 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Mon, 12 Mar 2018 18:13:19 +0200 Subject: [PATCH 10/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- app/code/Magento/InventoryConfigurableProduct/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/InventoryConfigurableProduct/composer.json b/app/code/Magento/InventoryConfigurableProduct/composer.json index 7248708f243a..db8616196ee5 100644 --- a/app/code/Magento/InventoryConfigurableProduct/composer.json +++ b/app/code/Magento/InventoryConfigurableProduct/composer.json @@ -7,6 +7,7 @@ "magento/module-catalog": "101.2.*", "magento/module-configurable-product": "100.3.*", "magento/module-ui": "100.3.*", + "magento/module-inventory-sales": "100.0.0-dev", "magento/module-inventory-sales-api": "100.0.0-dev", "magento/module-inventory-catalog": "100.0.0-dev", "magento/module-inventory-indexer": "100.0.0-dev", From 95455b6efda67b8c474d048f333a5f885678bef1 Mon Sep 17 00:00:00 2001 From: RomanKis Date: Tue, 13 Mar 2018 09:47:59 +0200 Subject: [PATCH 11/11] MSI: 392: Adapt `Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor` --- app/code/Magento/InventoryConfigurableProduct/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/InventoryConfigurableProduct/composer.json b/app/code/Magento/InventoryConfigurableProduct/composer.json index db8616196ee5..6e348f0778f9 100644 --- a/app/code/Magento/InventoryConfigurableProduct/composer.json +++ b/app/code/Magento/InventoryConfigurableProduct/composer.json @@ -11,7 +11,6 @@ "magento/module-inventory-sales-api": "100.0.0-dev", "magento/module-inventory-catalog": "100.0.0-dev", "magento/module-inventory-indexer": "100.0.0-dev", - "magento/module-inventory": "100.0.0-dev", "magento/module-store": "100.3.*", "magento/module-catalog-inventory": "100.3.*" },