diff --git a/vendor/magento/module-bundle/Model/Product/SelectionProductsDisabledRequired.php b/vendor/magento/module-bundle/Model/Product/SelectionProductsDisabledRequired.php deleted file mode 100644 index d3f1c2f1c999..000000000000 --- a/vendor/magento/module-bundle/Model/Product/SelectionProductsDisabledRequired.php +++ /dev/null @@ -1,164 +0,0 @@ -bundleSelection = $bundleSelection; - $this->storeManager = $storeManager; - $this->catalogProductStatus = $catalogProductStatus; - $this->productCollectionFactory = $productCollectionFactory; - $this->metadataPool = $metadataPool; - } - - /** - * Return ids of options and child products when all products in required option are disabled in bundle product - * - * @param int $bundleId - * @param int|null $websiteId - * @return array - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function getChildProductIds(int $bundleId, ?int $websiteId = null): array - { - if (!$websiteId) { - $websiteId = (int)$this->storeManager->getStore()->getWebsiteId(); - } - $cacheKey = $this->getCacheKey($bundleId, $websiteId); - if (isset($this->productsDisabledRequired[$cacheKey])) { - return $this->productsDisabledRequired[$cacheKey]; - } - $selectionProductIds = $this->bundleSelection->getChildrenIds($bundleId); - /** for cases when no required products found */ - if (count($selectionProductIds) === 1 && isset($selectionProductIds[0])) { - $this->productsDisabledRequired[$cacheKey] = []; - return $this->productsDisabledRequired[$cacheKey]; - } - $products = $this->getProducts($selectionProductIds, $websiteId); - if (!$products) { - $this->productsDisabledRequired[$cacheKey] = []; - return $this->productsDisabledRequired[$cacheKey]; - } - foreach ($selectionProductIds as $optionId => $optionProductIds) { - foreach ($optionProductIds as $productId) { - if (isset($products[$productId])) { - /** @var Product $product */ - $product = $products[$productId]; - if (in_array($product->getStatus(), $this->catalogProductStatus->getVisibleStatusIds())) { - unset($selectionProductIds[$optionId]); - } - } - } - } - $this->productsDisabledRequired[$cacheKey] = $selectionProductIds; - return $this->productsDisabledRequired[$cacheKey]; - } - - /** - * Get products objects - * - * @param array $selectionProductIds - * @param int $websiteId - * @return ProductInterface[] - */ - private function getProducts(array $selectionProductIds, int $websiteId): array - { - $productIds = []; - $defaultStore = $this->storeManager->getWebsite($websiteId)->getDefaultStore(); - $defaultStoreId = $defaultStore ? $defaultStore->getId() : null; - foreach ($selectionProductIds as $optionProductIds) { - $productIds[] = $optionProductIds; - } - $productIds = array_merge([], ...$productIds); - $productCollection = $this->productCollectionFactory->create(); - $productCollection->joinAttribute( - ProductInterface::STATUS, - Product::ENTITY . '/' . ProductInterface::STATUS, - $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(), - null, - 'inner', - $defaultStoreId - ); - $productCollection->addIdFilter($productIds); - $productCollection->addStoreFilter($defaultStoreId); - $productCollection->setFlag($this->hasStockStatusFilter, true); - return $productCollection->getItems(); - } - - /** - * Get cache key - * - * @param int $bundleId - * @param int $websiteId - * @return string - */ - private function getCacheKey(int $bundleId, int $websiteId): string - { - return $bundleId . '-' . $websiteId; - } -} diff --git a/vendor/magento/module-bundle/Model/ResourceModel/Indexer/Price/DisabledProductOptionPriceModifier.php b/vendor/magento/module-bundle/Model/ResourceModel/Indexer/Price/DisabledProductOptionPriceModifier.php deleted file mode 100644 index dcd85414748c..000000000000 --- a/vendor/magento/module-bundle/Model/ResourceModel/Indexer/Price/DisabledProductOptionPriceModifier.php +++ /dev/null @@ -1,141 +0,0 @@ -resourceConnection = $resourceConnection; - $this->config = $config; - $this->metadataPool = $metadataPool; - $this->bundleSelection = $bundleSelection; - $this->selectionProductsDisabledRequired = $selectionProductsDisabledRequired; - } - - /** - * Remove bundle product from price index when all products in required option are disabled - * - * @param IndexTableStructure $priceTable - * @param array $entityIds - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) : void - { - foreach ($entityIds as $entityId) { - $entityId = (int) $entityId; - if (!$this->isBundle($entityId)) { - continue; - } - foreach ($this->getWebsiteIdsOfProduct($entityId) as $websiteId) { - $productIdsDisabledRequired = $this->selectionProductsDisabledRequired - ->getChildProductIds($entityId, (int)$websiteId); - if ($productIdsDisabledRequired) { - $connection = $this->resourceConnection->getConnection('indexer'); - $select = $connection->select(); - $select->from(['price_index' => $priceTable->getTableName()], []); - $priceEntityField = $priceTable->getEntityField(); - $select->where('price_index.website_id = ?', $websiteId); - $select->where("price_index.{$priceEntityField} = ?", $entityId); - $query = $select->deleteFromSelect('price_index'); - $connection->query($query); - } - } - } - } - - /** - * Get all website ids of product - * - * @param int $entityId - * @return array - */ - private function getWebsiteIdsOfProduct(int $entityId): array - { - if (isset($this->websiteIdsOfProduct[$entityId])) { - return $this->websiteIdsOfProduct[$entityId]; - } - $connection = $this->resourceConnection->getConnection('indexer'); - $select = $connection->select(); - $select->from( - ['product_in_websites' => $this->resourceConnection->getTableName('catalog_product_website')], - ['website_id'] - )->where('product_in_websites.product_id = ?', $entityId); - foreach ($connection->fetchCol($select) as $websiteId) { - $this->websiteIdsOfProduct[$entityId][] = (int)$websiteId; - } - return $this->websiteIdsOfProduct[$entityId]; - } - - /** - * Is product bundle - * - * @param int $entityId - * @return bool - */ - private function isBundle(int $entityId): bool - { - if (isset($this->isBundle[$entityId])) { - return $this->isBundle[$entityId]; - } - $connection = $this->resourceConnection->getConnection('indexer'); - $select = $connection->select(); - $select->from( - ['cpe' => $this->resourceConnection->getTableName('catalog_product_entity')], - ['type_id'] - )->where('cpe.entity_id = ?', $entityId); - $typeId = $connection->fetchOne($select); - $this->isBundle[$entityId] = $typeId === Type::TYPE_BUNDLE; - return $this->isBundle[$entityId]; - } -} diff --git a/vendor/magento/module-bundle/Plugin/Catalog/Helper/Product.php b/vendor/magento/module-bundle/Plugin/Catalog/Helper/Product.php deleted file mode 100644 index 0b090b2cbad7..000000000000 --- a/vendor/magento/module-bundle/Plugin/Catalog/Helper/Product.php +++ /dev/null @@ -1,82 +0,0 @@ -selectionProductsDisabledRequired = $selectionProductsDisabledRequired; - $this->scopeConfig = $scopeConfig; - $this->productRepository = $productRepository; - } - - /** - * Do not show bundle product when all products in required option are disabled - * - * @param Subject $subject - * @param bool $result - * @param ProductModel|int $product - * @return bool - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function afterCanShow(Subject $subject, $result, $product) - { - if (is_int($product)) { - $product = $this->productRepository->getById($product); - } - $productId = (int)$product->getEntityId(); - if ($result == false || $product->getTypeId() !== Type::TYPE_BUNDLE) { - return $result; - } - $isShowOutOfStock = $this->scopeConfig->getValue( - Configuration::XML_PATH_SHOW_OUT_OF_STOCK, - ScopeInterface::SCOPE_STORE - ); - if ($isShowOutOfStock) { - return $result; - } - $productIdsDisabledRequired = $this->selectionProductsDisabledRequired->getChildProductIds($productId); - return $productIdsDisabledRequired ? false : $result; - } -} diff --git a/vendor/magento/module-bundle/etc/di.xml b/vendor/magento/module-bundle/etc/di.xml index c5c4a491234e..47329a0afdcd 100644 --- a/vendor/magento/module-bundle/etc/di.xml +++ b/vendor/magento/module-bundle/etc/di.xml @@ -276,13 +276,6 @@ - - - - Magento\Bundle\Model\ResourceModel\Indexer\Price\DisabledProductOptionPriceModifier - - - diff --git a/vendor/magento/module-bundle/etc/frontend/di.xml b/vendor/magento/module-bundle/etc/frontend/di.xml index 411cf91cbc8b..54f5ff0a1f48 100644 --- a/vendor/magento/module-bundle/etc/frontend/di.xml +++ b/vendor/magento/module-bundle/etc/frontend/di.xml @@ -22,7 +22,4 @@ - - - diff --git a/vendor/magento/module-bundle-graph-ql/Model/Resolver/Products/DataProvider/Product/DisabledProductOptionPostProcessor.php b/vendor/magento/module-bundle-graph-ql/Model/Resolver/Products/DataProvider/Product/DisabledProductOptionPostProcessor.php deleted file mode 100644 index 8887fa14fd8c..000000000000 --- a/vendor/magento/module-bundle-graph-ql/Model/Resolver/Products/DataProvider/Product/DisabledProductOptionPostProcessor.php +++ /dev/null @@ -1,70 +0,0 @@ -selectionProductsDisabledRequired = $selectionProductsDisabledRequired; - } - - /** - * Remove bundle product from collection when all products in required option are disabled - * - * @param Collection $collection - * @param array $attributeNames - * @param ContextInterface|null $context - * @return Collection - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\NoSuchEntityException - */ - public function process( - Collection $collection, - array $attributeNames, - ?ContextInterface $context = null - ): Collection { - if (!$collection->isLoaded()) { - $collection->load(); - } - /** @var Product $product */ - foreach ($collection as $key => $product) { - if ($product->getTypeId() !== Product\Type::TYPE_BUNDLE || $context === null) { - continue; - } - $productId = (int)$product->getEntityId(); - $websiteId = (int)$context->getExtensionAttributes()->getStore()->getWebsiteId(); - $productIdsDisabledRequired = $this->selectionProductsDisabledRequired->getChildProductIds( - $productId, - $websiteId - ); - if ($productIdsDisabledRequired) { - $collection->removeItemByKey($key); - } - } - return $collection; - } -} diff --git a/vendor/magento/module-bundle-graph-ql/etc/di.xml b/vendor/magento/module-bundle-graph-ql/etc/di.xml index 879359839a64..15acad7c6bf0 100644 --- a/vendor/magento/module-bundle-graph-ql/etc/di.xml +++ b/vendor/magento/module-bundle-graph-ql/etc/di.xml @@ -23,11 +23,4 @@ - - - - Magento\BundleGraphQl\Model\Resolver\Products\DataProvider\Product\DisabledProductOptionPostProcessor - - - diff --git a/vendor/magento/module-catalog-inventory/Model/ResourceModel/Stock/Status.php b/vendor/magento/module-catalog-inventory/Model/ResourceModel/Stock/Status.php index adf62b75b2ad..a98b3daad4cc 100644 --- a/vendor/magento/module-catalog-inventory/Model/ResourceModel/Stock/Status.php +++ b/vendor/magento/module-catalog-inventory/Model/ResourceModel/Stock/Status.php @@ -23,7 +23,8 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @api * - * @deprecated 100.3.0 Replaced with Multi Source Inventory + * @deprecated 100.3.0 + * @see Replaced with Multi Source Inventory * @link https://devdocs.magento.com/guides/v2.4/inventory/index.html * @link https://devdocs.magento.com/guides/v2.4/inventory/inventory-api-reference.html * @since 100.0.2 @@ -35,6 +36,7 @@ class Status extends AbstractDb * * @var StoreManagerInterface * @deprecated 100.1.0 + * @see Not used anymore */ protected $_storeManager; @@ -227,7 +229,7 @@ public function getProductCollection($lastEntityId = 0, $limit = 1000) */ public function addStockStatusToSelect(Select $select, Website $website) { - $websiteId = $this->getWebsiteId($website->getId()); + $websiteId = $this->getWebsiteId(); $select->joinLeft( ['stock_status' => $this->getMainTable()], 'e.entity_id = stock_status.product_id AND stock_status.website_id=' . $websiteId,