diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnConfigurationPageCustomStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnConfigurationPageCustomStockTest.xml
index dde2a233a4ad..ae78a3940135 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnConfigurationPageCustomStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnConfigurationPageCustomStockTest.xml
@@ -18,7 +18,7 @@
-
+
@@ -47,7 +47,6 @@
-
@@ -57,6 +56,7 @@
+
@@ -95,7 +95,7 @@
-
+
@@ -103,7 +103,7 @@
-
+
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnProductPageCustomStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnProductPageCustomStockTest.xml
index c065628c1c7f..15c586ce5d99 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnProductPageCustomStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminBundleProductDisabledManageStockOnProductPageCustomStockTest.xml
@@ -18,7 +18,7 @@
-
+
@@ -89,7 +89,7 @@
-
+
@@ -101,7 +101,7 @@
-
+
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCancelOrderBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCancelOrderBundleProductCustomStock.xml
index 61a05eaf0c00..cafe65f6b0a1 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCancelOrderBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCancelOrderBundleProductCustomStock.xml
@@ -8,7 +8,7 @@
-
+
@@ -17,50 +17,106 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateBundleProductAdditionalStockAdditionalWebsiteTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateBundleProductAdditionalStockAdditionalWebsiteTest.xml
index 06af491a2fe1..56984da4e220 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateBundleProductAdditionalStockAdditionalWebsiteTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateBundleProductAdditionalStockAdditionalWebsiteTest.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundBundleProductCustomStock.xml
index 86ff83e83aa5..c221811d45ee 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentBundleProductCustomStock.xml
index 4873b6285511..c519439a963d 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentPartialInvoiceBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentPartialInvoiceBundleProductCustomStock.xml
index 9c5dc6be62e2..f5e04378fc2a 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentPartialInvoiceBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundPartialShipmentPartialInvoiceBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundBundleProductCustomStock.xml
index 356dce054767..fc9638f7430d 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
@@ -30,7 +27,7 @@
-
+
@@ -39,20 +36,18 @@
+
+
+
+
-
-
-
-
-
-
-
-
+
+
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundPartialShipmentBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundPartialShipmentBundleProductCustomStock.xml
index 8946aa3f2aca..cfb0e994e01c 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundPartialShipmentBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateCreditMemoTotalRefundPartialShipmentBundleProductCustomStock.xml
@@ -8,7 +8,7 @@
-
+
@@ -17,29 +17,115 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreatePartialShipmentBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreatePartialShipmentBundleProductCustomStock.xml
index bd3becfa9fd1..36b31b3cbbd4 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreatePartialShipmentBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreatePartialShipmentBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateScheduledPermanentUpdateBundleProductCustomStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateScheduledPermanentUpdateBundleProductCustomStockTest.xml
index 9b207a7cd49a..04b2a886b4ef 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateScheduledPermanentUpdateBundleProductCustomStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateScheduledPermanentUpdateBundleProductCustomStockTest.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/AdminCreateShipmentBundleProductCustomStock.xml b/InventoryAdminUi/Test/Mftf/Test/AdminCreateShipmentBundleProductCustomStock.xml
index 1de1cf1daa9f..ba094d03486a 100644
--- a/InventoryAdminUi/Test/Mftf/Test/AdminCreateShipmentBundleProductCustomStock.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/AdminCreateShipmentBundleProductCustomStock.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/CatalogPriceRuleBundleProductAdditionalStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/CatalogPriceRuleBundleProductAdditionalStockTest.xml
index e6b396d1ad2d..716c08682838 100644
--- a/InventoryAdminUi/Test/Mftf/Test/CatalogPriceRuleBundleProductAdditionalStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/CatalogPriceRuleBundleProductAdditionalStockTest.xml
@@ -17,9 +17,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/SimpleProductWithZeroQtyAndInStockStatusOnTestSourceVisibleOnHomePageIfBackordersEnabledOnConfigurationPageTest.xml b/InventoryAdminUi/Test/Mftf/Test/SimpleProductWithZeroQtyAndInStockStatusOnTestSourceVisibleOnHomePageIfBackordersEnabledOnConfigurationPageTest.xml
index a1583f68d15e..8a447927e226 100644
--- a/InventoryAdminUi/Test/Mftf/Test/SimpleProductWithZeroQtyAndInStockStatusOnTestSourceVisibleOnHomePageIfBackordersEnabledOnConfigurationPageTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/SimpleProductWithZeroQtyAndInStockStatusOnTestSourceVisibleOnHomePageIfBackordersEnabledOnConfigurationPageTest.xml
@@ -42,6 +42,7 @@
-
+
+
diff --git a/InventoryAdminUi/Test/Mftf/Test/StorefrontAdvancedSearchBundleProductCustomStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/StorefrontAdvancedSearchBundleProductCustomStockTest.xml
index c1ecfcbc181a..618bd9cd3f3f 100644
--- a/InventoryAdminUi/Test/Mftf/Test/StorefrontAdvancedSearchBundleProductCustomStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/StorefrontAdvancedSearchBundleProductCustomStockTest.xml
@@ -16,9 +16,6 @@
-
-
-
diff --git a/InventoryAdminUi/Test/Mftf/Test/StorefrontQuickSearchBundleProductCustomStockTest.xml b/InventoryAdminUi/Test/Mftf/Test/StorefrontQuickSearchBundleProductCustomStockTest.xml
index 60a44a5e7544..e0e4b30147ea 100644
--- a/InventoryAdminUi/Test/Mftf/Test/StorefrontQuickSearchBundleProductCustomStockTest.xml
+++ b/InventoryAdminUi/Test/Mftf/Test/StorefrontQuickSearchBundleProductCustomStockTest.xml
@@ -16,9 +16,6 @@
-
-
-
diff --git a/InventoryBundleProduct/Model/GetBundleProductStockStatus.php b/InventoryBundleProduct/Model/GetBundleProductStockStatus.php
new file mode 100644
index 000000000000..6eef19e2fc0b
--- /dev/null
+++ b/InventoryBundleProduct/Model/GetBundleProductStockStatus.php
@@ -0,0 +1,86 @@
+optionRepository = $optionRepository;
+ $this->getProductSelection = $getProductSelection;
+ $this->isProductSalable = $isProductSalable;
+ }
+
+ /**
+ * Provides bundle product stock status.
+ *
+ * @param ProductInterface $product
+ * @param OptionInterface[] $bundleOptions
+ * @param int $stockId
+ *
+ * @return bool
+ */
+ public function execute(ProductInterface $product, array $bundleOptions, int $stockId): bool
+ {
+ $isSalable = false;
+ foreach ($bundleOptions as $option) {
+ $hasSalable = false;
+ $bundleSelections = $this->getProductSelection->execute($product, $option);
+ foreach ($bundleSelections as $selection) {
+ if ($this->isProductSalable->execute((string)$selection->getSku(), $stockId)) {
+ $hasSalable = true;
+ break;
+ }
+ }
+
+ if ($hasSalable) {
+ $isSalable = true;
+ }
+
+ if (!$hasSalable && $option->getRequired()) {
+ $isSalable = false;
+ break;
+ }
+ }
+
+ return $isSalable;
+ }
+}
diff --git a/InventoryBundleProduct/Model/GetProductSelection.php b/InventoryBundleProduct/Model/GetProductSelection.php
new file mode 100644
index 000000000000..18ff7efe2a06
--- /dev/null
+++ b/InventoryBundleProduct/Model/GetProductSelection.php
@@ -0,0 +1,77 @@
+collectionFactory = $collectionFactory;
+ $this->metadataPool = $metadataPool;
+ $this->selectionCollectionFilterApplier = $selectionCollectionFilterApplier;
+ }
+
+ /**
+ * Retrieve bundle product selection for given bundle product and option.
+ *
+ * @param ProductInterface $product
+ * @param Option $option
+ * @return Collection
+ * @throws \Exception
+ */
+ public function execute(ProductInterface $product, Option $option): Collection
+ {
+ $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
+ $selectionsCollection = $this->collectionFactory->create();
+ $selectionsCollection->addAttributeToSelect('status');
+ $selectionsCollection->setFlag('product_children', true);
+ $selectionsCollection->addFilterByRequiredOptions();
+ $selectionsCollection->setOptionIdsFilter([$option->getId()]);
+
+ $this->selectionCollectionFilterApplier->apply(
+ $selectionsCollection,
+ 'parent_product_id',
+ $product->getData($metadata->getLinkField())
+ );
+
+ return $selectionsCollection;
+ }
+}
diff --git a/InventoryBundleProduct/Plugin/Bundle/Model/Product/Type/AdaptIsSalablePlugin.php b/InventoryBundleProduct/Plugin/Bundle/Model/Product/Type/AdaptIsSalablePlugin.php
new file mode 100644
index 000000000000..cc55064f3b01
--- /dev/null
+++ b/InventoryBundleProduct/Plugin/Bundle/Model/Product/Type/AdaptIsSalablePlugin.php
@@ -0,0 +1,105 @@
+isProductSalable = $isProductSalable;
+ $this->storeManager = $storeManager;
+ $this->stockByWebsiteIdResolver = $stockByWebsiteIdResolver;
+ $this->getBundleProductStockStatus = $getBundleProductStockStatus;
+ $this->defaultStockProvider = $defaultStockProvider;
+ }
+
+ /**
+ * Verify, is product salable in multi stock environment.
+ *
+ * @param Type $subject
+ * @param \Closure $proceed
+ * @param Product $product
+ * @return bool
+ */
+ public function aroundIsSalable(Type $subject, \Closure $proceed, $product): bool
+ {
+ $salable = $product->getStatus() == Status::STATUS_ENABLED;
+ if ($salable && $product->hasData('is_salable')) {
+ $salable = $product->getData('is_salable');
+ }
+
+ if (!(bool)(int)$salable) {
+ return false;
+ }
+
+ if ($product->hasData('all_items_salable')) {
+ return $product->getData('all_items_salable');
+ }
+
+ $website = $this->storeManager->getWebsite();
+ $stock = $this->stockByWebsiteIdResolver->execute((int)$website->getId());
+ if ($this->defaultStockProvider->getId() === $stock->getStockId()) {
+ return $proceed($product);
+ }
+ $options = $subject->getOptionsCollection($product);
+ $isSalable = $this->getBundleProductStockStatus->execute($product, $options->getItems(), $stock->getStockId());
+ $product->setData('all_items_salable', $isSalable);
+
+ return $isSalable;
+ }
+}
diff --git a/InventoryBundleProduct/Plugin/Bundle/Model/ResourceModel/Selection/Collection/AdaptAddQuantityFilterPlugin.php b/InventoryBundleProduct/Plugin/Bundle/Model/ResourceModel/Selection/Collection/AdaptAddQuantityFilterPlugin.php
new file mode 100644
index 000000000000..46f40f237ee0
--- /dev/null
+++ b/InventoryBundleProduct/Plugin/Bundle/Model/ResourceModel/Selection/Collection/AdaptAddQuantityFilterPlugin.php
@@ -0,0 +1,88 @@
+isProductSalable = $isProductSalable;
+ $this->storeManager = $storeManager;
+ $this->stockByWebsiteIdResolver = $stockByWebsiteIdResolver;
+ $this->defaultStockProvider = $defaultStockProvider;
+ }
+
+ /**
+ * Adapt quantity filter for multi stock environment.
+ *
+ * @param Collection $subject
+ * @param \Closure $proceed
+ * @return Collection
+ */
+ public function aroundAddQuantityFilter(
+ Collection $subject,
+ \Closure $proceed
+ ): Collection {
+ $website = $this->storeManager->getWebsite();
+ $stock = $this->stockByWebsiteIdResolver->execute((int)$website->getId());
+ if ($this->defaultStockProvider->getId() === $stock->getStockId()) {
+ return $proceed();
+ }
+ $skusToExclude = [];
+ foreach ($subject->getData() as $item) {
+ if (!$this->isProductSalable->execute((string)$item['sku'], $stock->getStockId())) {
+ $skusToExclude[] = (string)$item['sku'];
+ }
+ }
+ if ($skusToExclude) {
+ $subject->getSelect()->where('e.sku NOT IN(?)', implode(',', $skusToExclude));
+ }
+ $subject->resetData();
+
+ return $subject;
+ }
+}
diff --git a/InventoryBundleProduct/Plugin/InventorySalesApi/Model/GetSkuFromOrderItem/AdaptGetSkuFromOrderItemPlugin.php b/InventoryBundleProduct/Plugin/InventorySalesApi/Model/GetSkuFromOrderItem/AdaptGetSkuFromOrderItemPlugin.php
new file mode 100644
index 000000000000..961f6b7e59d5
--- /dev/null
+++ b/InventoryBundleProduct/Plugin/InventorySalesApi/Model/GetSkuFromOrderItem/AdaptGetSkuFromOrderItemPlugin.php
@@ -0,0 +1,43 @@
+getProductType() !== Type::TYPE_CODE) {
+ return $proceed($orderItem);
+ }
+
+ $orderItemOptions = $orderItem->getProductOptions();
+ $value = reset($orderItemOptions['bundle_options']);
+ $value = reset($value['value']);
+
+ return $value['title'];
+ }
+}
diff --git a/InventoryBundleProduct/composer.json b/InventoryBundleProduct/composer.json
index 02ccf4fd9f2b..06c7b81675f3 100644
--- a/InventoryBundleProduct/composer.json
+++ b/InventoryBundleProduct/composer.json
@@ -4,7 +4,12 @@
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0",
"magento/framework": "*",
- "magento/module-bundle": "*"
+ "magento/module-bundle": "*",
+ "magento/module-catalog": "*",
+ "magento/module-inventory-catalog-api": "*",
+ "magento/module-inventory-sales-api": "*",
+ "magento/module-sales": "*",
+ "magento/module-store": "*"
},
"suggest": {
"magento/module-inventory-configuration-api": "*"
diff --git a/InventoryBundleProduct/etc/di.xml b/InventoryBundleProduct/etc/di.xml
index b49148159d7f..361c83ab8392 100644
--- a/InventoryBundleProduct/etc/di.xml
+++ b/InventoryBundleProduct/etc/di.xml
@@ -7,7 +7,15 @@
-->
-
+
+
+
+
+
+
+
+
+
+
diff --git a/InventoryBundleProductAdminUi/Model/ProcessSourceItemsForSku.php b/InventoryBundleProductAdminUi/Model/ProcessSourceItemsForSku.php
new file mode 100644
index 000000000000..8775f0185929
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Model/ProcessSourceItemsForSku.php
@@ -0,0 +1,76 @@
+getSourceItemsBySku = $getSourceItemsBySku;
+ $this->sourceItemsProcessor = $sourceItemsProcessor;
+ $this->defaultSourceProvider = $defaultSourceProvider;
+ }
+
+ /**
+ * Process source items for given bundle selection sku.
+ *
+ * @param string $sku
+ * @throws InputException
+ */
+ public function execute(string $sku)
+ {
+ $processData = [];
+
+ foreach ($this->getSourceItemsBySku->execute($sku) as $sourceItem) {
+ if ($sourceItem->getSourceCode() === $this->defaultSourceProvider->getCode()) {
+ continue;
+ }
+ $processData[] = [
+ SourceItemInterface::SOURCE_CODE => $sourceItem->getSourceCode(),
+ SourceItemInterface::QUANTITY => $sourceItem->getQuantity(),
+ SourceItemInterface::STATUS => $sourceItem->getStatus(),
+ ];
+ }
+
+ if (!empty($processData)) {
+ $this->sourceItemsProcessor->process($sku, $processData);
+ }
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionBySkuPlugin.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionBySkuPlugin.php
new file mode 100644
index 000000000000..819a0cc8588e
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionBySkuPlugin.php
@@ -0,0 +1,56 @@
+processSourceItemsForSku = $processSourceItemsForSku;
+ }
+
+ /**
+ * Process source items after bundle selection has been added by product sku.
+ *
+ * @param ProductLinkManagementInterface $subject
+ * @param int $result
+ * @param string $sku
+ * @param int $optionId
+ * @param LinkInterface $linkedProduct
+ * @return int
+ * @throws InputException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterAddChildByProductSku(
+ ProductLinkManagementInterface $subject,
+ int $result,
+ $sku,
+ $optionId,
+ LinkInterface $linkedProduct
+ ): int {
+ $this->processSourceItemsForSku->execute((string)$linkedProduct->getSku());
+
+ return $result;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionPlugin.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionPlugin.php
new file mode 100644
index 000000000000..da395ffa6f44
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterAddBundleSelectionPlugin.php
@@ -0,0 +1,57 @@
+processSourceItemsForSku = $processSourceItemsForSku;
+ }
+
+ /**
+ * Process source items after selection has been added to bundle product.
+ *
+ * @param ProductLinkManagementInterface $subject
+ * @param int $result
+ * @param ProductInterface $product
+ * @param int $optionId
+ * @param LinkInterface $linkedProduct
+ * @return int
+ * @throws InputException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterAddChild(
+ ProductLinkManagementInterface $subject,
+ int $result,
+ ProductInterface $product,
+ $optionId,
+ LinkInterface $linkedProduct
+ ): int {
+ $this->processSourceItemsForSku->execute((string)$linkedProduct->getSku());
+
+ return $result;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterRemoveBundleSelectionPlugin.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterRemoveBundleSelectionPlugin.php
new file mode 100644
index 000000000000..d83b865cc405
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterRemoveBundleSelectionPlugin.php
@@ -0,0 +1,55 @@
+processSourceItemsForSku = $processSourceItemsForSku;
+ }
+
+ /**
+ * Process source items after bundle selection has been removed.
+ *
+ * @param ProductLinkManagementInterface $subject
+ * @param bool $result
+ * @param string $sku
+ * @param string $optionId
+ * @param string $childSku
+ * @return bool
+ * @throws InputException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterRemoveChild(
+ ProductLinkManagementInterface $subject,
+ bool $result,
+ $sku,
+ $optionId,
+ $childSku
+ ): bool {
+ $this->processSourceItemsForSku->execute((string)$childSku);
+
+ return $result;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterSaveBundleSelectionPlugin.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterSaveBundleSelectionPlugin.php
new file mode 100644
index 000000000000..280681d67439
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Model/LinkManagement/ProcessSourceItemsAfterSaveBundleSelectionPlugin.php
@@ -0,0 +1,54 @@
+processSourceItemsForSku = $processSourceItemsForSku;
+ }
+
+ /**
+ * Process source items after bundle selection has been updated.
+ *
+ * @param ProductLinkManagementInterface $subject
+ * @param bool $result
+ * @param string $sku
+ * @param LinkInterface $linkedProduct
+ * @return bool
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @throws InputException
+ */
+ public function afterSaveChild(
+ ProductLinkManagementInterface $subject,
+ bool $result,
+ $sku,
+ LinkInterface $linkedProduct
+ ): bool {
+ $this->processSourceItemsForSku->execute((string)$linkedProduct->getSku());
+
+ return $result;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddColumnQuantityPerSource.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddColumnQuantityPerSource.php
new file mode 100644
index 000000000000..657e010c45a7
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddColumnQuantityPerSource.php
@@ -0,0 +1,85 @@
+isSingleSourceMode = $isSingleSourceMode;
+ }
+
+ /**
+ * Add column "Quantity Per Source" to modal window for multi source mode.
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ *
+ * @param BundleDataProvider $subject
+ * @param array $result
+ * @return array
+ */
+ public function afterGetMeta(BundleDataProvider $subject, array $result): array
+ {
+ if (!$this->isSingleSourceMode->execute()) {
+ $result = array_replace_recursive($result, [
+ 'product_columns' => [
+ 'children' => [
+ 'quantity_per_source' => $this->getQuantityPerSourceMeta(),
+ 'qty' => [
+ 'arguments' => null,
+ ],
+ ],
+ ],
+ ]);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Config for column "Quantity Per Source".
+ *
+ * @return array
+ */
+ private function getQuantityPerSourceMeta(): array
+ {
+ $jsComponent = 'Magento_InventoryBundleProductAdminUi/js/form/element/grid-column-quantity-per-source';
+
+ return [
+ 'arguments' => [
+ 'data' => [
+ 'config' => [
+ 'filter' => false,
+ 'sortable' => false,
+ 'label' => __('Quantity per Source'),
+ 'dataType' => Text::NAME,
+ 'componentType' => Column::NAME,
+ 'component' => $jsComponent,
+ ]
+ ],
+ ],
+ ];
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php b/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php
new file mode 100644
index 000000000000..a6372158174b
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Plugin/Bundle/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php
@@ -0,0 +1,71 @@
+isSingleSourceMode = $isSingleSourceMode;
+ $this->getQuantityInformationPerSourceBySkus = $getQuantityInformationPerSourceBySkus;
+ }
+
+ /**
+ * Add data "Quantity Per Source" to items on modal window for multi source mode.
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ *
+ * @param BundleDataProvider $subject
+ * @param array $result
+ * @return array
+ * @throws NoSuchEntityException
+ */
+ public function afterGetData(BundleDataProvider $subject, array $result): array
+ {
+ if ($this->isSingleSourceMode->execute()) {
+ return $result;
+ }
+
+ $skus = [];
+ foreach ($result['items'] as $itemData) {
+ $skus[] = $itemData['sku'];
+ }
+
+ $sourceItemsData = $this->getQuantityInformationPerSourceBySkus->execute($skus);
+
+ foreach ($result['items'] as &$productLinkData) {
+ $productLinkData['quantity_per_source'] = $sourceItemsData[$productLinkData['sku']] ?? [];
+ }
+
+ return $result;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryBundlePanel.php b/InventoryBundleProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryBundlePanel.php
new file mode 100644
index 000000000000..5146f088c79f
--- /dev/null
+++ b/InventoryBundleProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryBundlePanel.php
@@ -0,0 +1,179 @@
+isSingleSourceMode = $isSingleSourceMode;
+ $this->locator = $locator;
+ $this->getQuantityInformationPerSourceBySkus = $getQuantityInformationPerSourceBySkus;
+ $this->arrayManager = $arrayManager;
+ }
+
+ /**
+ * Add source data to linked to bundle product items only for multi source mode.
+ *
+ * @param array $data
+ * @return array
+ * @throws NoSuchEntityException
+ */
+ public function modifyData(array $data)
+ {
+ $product = $this->locator->getProduct();
+ $modelId = (int)$product->getId();
+ if ($product->getTypeId() === Type::TYPE_CODE
+ && $modelId
+ && isset($data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS])
+ && !$this->isSingleSourceMode->execute()
+ ) {
+ $data = $this->addQuantityPerSource($data, $modelId);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Add column "Quantity Per Source" to bundle selections.
+ *
+ * @param array $meta
+ * @return array
+ */
+ public function modifyMeta(array $meta): array
+ {
+ if ($this->locator->getProduct()->getTypeId() === Type::TYPE_CODE
+ && !$this->isSingleSourceMode->execute()
+ ) {
+ $path = $this->arrayManager->findPath('bundle_selections', $meta, null);
+ $meta = $this->arrayManager->merge(
+ $path,
+ $meta,
+ [
+ 'children' => [
+ 'record' => [
+ 'children' => [
+ 'source_code' => [
+ 'arguments' => [
+ 'data' => [
+ 'config' => $this->getQtyPerSourceConfig(),
+ ],
+ ],
+ ],
+ ],
+
+ ],
+ ],
+ 'arguments' => [
+ 'data' => [
+ 'config' => [
+ 'map' => [
+ 'quantity_per_source' => 'quantity_per_source',
+ ],
+ ],
+ ],
+ ],
+ ]
+ );
+ }
+
+ return $meta;
+ }
+
+ /**
+ * Config for field "Quantity Per Source" on dynamic rows.
+ *
+ * @return array
+ */
+ private function getQtyPerSourceConfig(): array
+ {
+ return [
+ 'componentType' => 'text',
+ 'component' => 'Magento_InventoryBundleProductAdminUi/js/form/element/quantity-per-source',
+ 'template' => 'ui/form/field',
+ 'dataScope' => 'quantity_per_source',
+ 'label' => __('Quantity Per Source'),
+ 'formElement' => Input::NAME,
+ 'sortOrder' => 95,
+ ];
+ }
+
+ /**
+ * Add quantity per source to data.
+ *
+ * @param array $data
+ * @param int $modelId
+ * @return array
+ * @throws NoSuchEntityException
+ */
+ private function addQuantityPerSource(array $data, int $modelId): array
+ {
+ $selectionSkus = [];
+ $bundleOptions = &$data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS];
+ foreach ($bundleOptions as $option) {
+ if (isset($option['bundle_selections'])) {
+ foreach ($option['bundle_selections'] as $selection) {
+ $selectionSkus[] = $selection['sku'];
+ }
+ }
+ }
+ $sourceItemsData = $this->getQuantityInformationPerSourceBySkus->execute($selectionSkus);
+ foreach ($bundleOptions as &$option) {
+ if (isset($option['bundle_selections'])) {
+ foreach ($option['bundle_selections'] as &$selection) {
+ $selection['quantity_per_source'] = $sourceItemsData[$selection['sku']] ?? [];
+ }
+ }
+ }
+
+ return $data;
+ }
+}
diff --git a/InventoryBundleProductAdminUi/composer.json b/InventoryBundleProductAdminUi/composer.json
index f0d66d0076b9..ffd217a80b2c 100644
--- a/InventoryBundleProductAdminUi/composer.json
+++ b/InventoryBundleProductAdminUi/composer.json
@@ -3,7 +3,13 @@
"description": "N/A",
"require": {
"php": "~7.1.3||~7.2.0||~7.3.0",
- "magento/framework": "*"
+ "magento/framework": "*",
+ "magento/module-bundle": "*",
+ "magento/module-catalog": "*",
+ "magento/module-ui": "*",
+ "magento/module-inventory-api": "*",
+ "magento/module-inventory-catalog-api": "*",
+ "magento/module-inventory-catalog-admin-ui": "*"
},
"suggest": {
"magento/module-inventory-configuration-api": "*"
diff --git a/InventoryBundleProductAdminUi/etc/adminhtml/di.xml b/InventoryBundleProductAdminUi/etc/adminhtml/di.xml
new file mode 100644
index 000000000000..872be0339588
--- /dev/null
+++ b/InventoryBundleProductAdminUi/etc/adminhtml/di.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ -
+
- Magento\InventoryBundleProductAdminUi\Ui\DataProvider\Product\Form\Modifier\InventoryBundlePanel
+ - 310
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/grid-column-quantity-per-source.js b/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/grid-column-quantity-per-source.js
new file mode 100644
index 000000000000..2c9afa092c05
--- /dev/null
+++ b/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/grid-column-quantity-per-source.js
@@ -0,0 +1,28 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+define([
+ 'mage/translate',
+ 'Magento_Ui/js/grid/columns/column'
+], function ($t, Column) {
+ 'use strict';
+
+ return Column.extend({
+ defaults: {
+ bodyTmpl: 'Magento_InventoryBundleProductAdminUi/grid/column/quantity-per-source',
+ itemsToDisplay: 3,
+ showFullListDescription: $t('Show more...')
+ },
+
+ /**
+ * Get source items from product data.
+ *
+ * @param {Object} rowData
+ * @returns {Array}
+ */
+ getSourceItemsData: function (rowData) {
+ return rowData['quantity_per_source'];
+ }
+ });
+});
diff --git a/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/quantity-per-source.js b/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/quantity-per-source.js
new file mode 100644
index 000000000000..f4e5aba75e97
--- /dev/null
+++ b/InventoryBundleProductAdminUi/view/adminhtml/web/js/form/element/quantity-per-source.js
@@ -0,0 +1,45 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+define([
+ 'mage/translate',
+ 'Magento_Ui/js/form/element/abstract'
+], function ($t, Abstract) {
+ 'use strict';
+
+ return Abstract.extend({
+ defaults: {
+ elementTmpl: 'Magento_InventoryBundleProductAdminUi/dynamic-rows/cells/cell-source',
+ itemsToDisplay: 3,
+ isFullList: true,
+ showFullListDescription: $t('Show more...'),
+ listens: {
+ value: 'updateItems'
+ }
+ },
+
+ /**
+ * Observe elements.
+ *
+ * @returns {exports}
+ */
+ initObservable: function () {
+ this._super()
+ .observe(['items', 'isFullList']);
+
+ return this;
+ },
+
+ /**
+ * Prepare data to use.
+ *
+ * @param {Object} data
+ * @private
+ */
+ updateItems: function (data) {
+ this.isFullList(data.length > this.itemsToDisplay);
+ this.isFullList() ? this.items(data.slice(0, this.itemsToDisplay)) : this.items(data);
+ }
+ });
+});
diff --git a/InventoryBundleProductAdminUi/view/adminhtml/web/template/dynamic-rows/cells/cell-source.html b/InventoryBundleProductAdminUi/view/adminhtml/web/template/dynamic-rows/cells/cell-source.html
new file mode 100644
index 000000000000..db174ecb9349
--- /dev/null
+++ b/InventoryBundleProductAdminUi/view/adminhtml/web/template/dynamic-rows/cells/cell-source.html
@@ -0,0 +1,37 @@
+
+
+
diff --git a/InventoryBundleProductAdminUi/view/adminhtml/web/template/grid/column/quantity-per-source.html b/InventoryBundleProductAdminUi/view/adminhtml/web/template/grid/column/quantity-per-source.html
new file mode 100644
index 000000000000..905974e0ea8a
--- /dev/null
+++ b/InventoryBundleProductAdminUi/view/adminhtml/web/template/grid/column/quantity-per-source.html
@@ -0,0 +1,15 @@
+
+
diff --git a/InventoryBundleProductIndexer/Indexer/SelectBuilder.php b/InventoryBundleProductIndexer/Indexer/SelectBuilder.php
new file mode 100644
index 000000000000..dc78c4bfdb8b
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/SelectBuilder.php
@@ -0,0 +1,111 @@
+resourceConnection = $resourceConnection;
+ $this->indexNameBuilder = $indexNameBuilder;
+ $this->indexNameResolver = $indexNameResolver;
+ $this->metadataPool = $metadataPool;
+ }
+
+ /**
+ * Prepare select for getting bundle products on given stock.
+ *
+ * @param int $stockId
+ * @return Select
+ * @throws Exception
+ */
+ public function execute(int $stockId): Select
+ {
+ $connection = $this->resourceConnection->getConnection();
+
+ $indexName = $this->indexNameBuilder
+ ->setIndexId(InventoryIndexer::INDEXER_ID)
+ ->addDimension('stock_', (string)$stockId)
+ ->setAlias(Alias::ALIAS_MAIN)
+ ->build();
+
+ $indexTableName = $this->indexNameResolver->resolveName($indexName);
+
+ $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
+ $linkField = $metadata->getLinkField();
+
+ $select = $connection->select()
+ ->from(
+ ['stock' => $indexTableName],
+ [
+ IndexStructure::SKU => 'parent_product_entity.sku',
+ IndexStructure::QUANTITY => 'SUM(stock.quantity)',
+ IndexStructure::IS_SALABLE => 'MAX(stock.is_salable)',
+ ]
+ )->joinInner(
+ ['product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
+ 'product_entity.sku = stock.sku',
+ []
+ )->joinInner(
+ ['parent_link' => $this->resourceConnection->getTableName('catalog_product_bundle_selection')],
+ 'parent_link.product_id = product_entity.entity_id',
+ []
+ )->joinInner(
+ ['parent_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
+ 'parent_product_entity.' . $linkField . ' = parent_link.parent_product_id',
+ []
+ )
+ ->group(['parent_product_entity.sku']);
+
+ return $select;
+ }
+}
diff --git a/InventoryBundleProductIndexer/Indexer/SourceItem/IndexDataBySkuListProvider.php b/InventoryBundleProductIndexer/Indexer/SourceItem/IndexDataBySkuListProvider.php
new file mode 100644
index 000000000000..c6b83c5a22bd
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/SourceItem/IndexDataBySkuListProvider.php
@@ -0,0 +1,59 @@
+resourceConnection = $resourceConnection;
+ $this->selectBuilder = $selectBuilder;
+ }
+
+ /**
+ * Get index data by stock id and sku list.
+ *
+ * @param int $stockId
+ * @param array $skuList
+ * @return \ArrayIterator
+ * @throws \Exception
+ */
+ public function execute(int $stockId, array $skuList): \ArrayIterator
+ {
+ $select = $this->selectBuilder->execute($stockId);
+ if (count($skuList)) {
+ $select->where('stock.' . IndexStructure::SKU . ' IN (?)', $skuList);
+ }
+ $connection = $this->resourceConnection->getConnection();
+
+ return new \ArrayIterator($connection->fetchAll($select));
+ }
+}
diff --git a/InventoryBundleProductIndexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php b/InventoryBundleProductIndexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php
new file mode 100644
index 000000000000..2f138b7ac29a
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/SourceItem/SiblingSkuListInStockProvider.php
@@ -0,0 +1,143 @@
+resourceConnection = $resourceConnection;
+ $this->skuListInStockFactory = $skuListInStockFactory;
+ $this->metadataPool = $metadataPool;
+ $this->tableNameSourceItem = $tableNameSourceItem;
+ $this->tableNameStockSourceLink = $tableNameStockSourceLink;
+ }
+
+ /**
+ * Returns all assigned Stock ids by given Source Item ids
+ *
+ * @param int[] $sourceItemIds
+ * @return SkuListInStock[] List of stock id to sku1,sku2 assignment
+ * @throws \Exception
+ */
+ public function execute(array $sourceItemIds): array
+ {
+ $connection = $this->resourceConnection->getConnection();
+ $sourceStockLinkTable = $this->resourceConnection->getTableName($this->tableNameStockSourceLink);
+ $sourceItemTable = $this->resourceConnection->getTableName($this->tableNameSourceItem);
+
+ $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
+ $linkField = $metadata->getIdentifierField();
+ $items = [];
+
+ $select = $connection
+ ->select()
+ ->from(
+ ['source_item' => $sourceItemTable],
+ [SourceItemInterface::SKU => 'sibling_product_entity.' . SourceItemInterface::SKU]
+ )->joinInner(
+ ['stock_source_link' => $sourceStockLinkTable],
+ sprintf(
+ 'source_item.%s = stock_source_link.%s',
+ SourceItemInterface::SOURCE_CODE,
+ StockSourceLinkInterface::SOURCE_CODE
+ ),
+ [StockSourceLinkInterface::STOCK_ID]
+ )->joinInner(
+ ['child_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
+ 'child_product_entity.sku = source_item.sku',
+ []
+ )->joinInner(
+ ['sibling_link' => $this->resourceConnection->getTableName('catalog_product_bundle_selection')],
+ 'sibling_link.product_id = child_product_entity.' . $linkField,
+ []
+ )->joinInner(
+ ['sibling_product_entity' => $this->resourceConnection->getTableName('catalog_product_entity')],
+ 'sibling_product_entity.' . $linkField . ' = sibling_link.product_id',
+ []
+ )->where(
+ 'source_item.source_item_id IN (?)',
+ $sourceItemIds
+ );
+
+ $dbStatement = $connection->query($select);
+ while ($item = $dbStatement->fetch()) {
+ $items[$item[StockSourceLinkInterface::STOCK_ID]][$item[SourceItemInterface::SKU]] =
+ $item[SourceItemInterface::SKU];
+ }
+
+ return $this->getStockIdToSkuList($items);
+ }
+
+ /**
+ * Return the assigned stock id to sku list.
+ *
+ * @param array $items
+ * @return SkuListInStock[]
+ */
+ private function getStockIdToSkuList(array $items): array
+ {
+ $skuListInStockList = [];
+ foreach ($items as $stockId => $skuList) {
+ $skuListInStock = $this->skuListInStockFactory->create();
+ $skuListInStock->setStockId((int)$stockId);
+ $skuListInStock->setSkuList($skuList);
+ $skuListInStockList[] = $skuListInStock;
+ }
+
+ return $skuListInStockList;
+ }
+}
diff --git a/InventoryBundleProductIndexer/Indexer/SourceItem/SourceItemIndexer.php b/InventoryBundleProductIndexer/Indexer/SourceItem/SourceItemIndexer.php
new file mode 100644
index 000000000000..2c0d805ec8f9
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/SourceItem/SourceItemIndexer.php
@@ -0,0 +1,131 @@
+resourceConnection = $resourceConnection;
+ $this->indexNameBuilder = $indexNameBuilder;
+ $this->indexHandler = $indexHandler;
+ $this->indexDataBySkuListProvider = $indexDataBySkuListProvider;
+ $this->indexStructure = $indexStructure;
+ $this->siblingSkuListInStockProvider = $siblingSkuListInStockProvider;
+ $this->defaultStockProvider = $defaultStockProvider;
+ }
+
+ /**
+ * Reindex list of bundle source items.
+ *
+ * @param array $sourceItemIds
+ * @return void
+ * @throws StateException
+ * @throws \Exception
+ */
+ public function executeList(array $sourceItemIds): void
+ {
+ $skuListInStockList = $this->siblingSkuListInStockProvider->execute($sourceItemIds);
+
+ foreach ($skuListInStockList as $skuListInStock) {
+ $stockId = $skuListInStock->getStockId();
+
+ if ($this->defaultStockProvider->getId() === $stockId) {
+ continue;
+ }
+ $skuList = $skuListInStock->getSkuList();
+
+ $mainIndexName = $this->indexNameBuilder
+ ->setIndexId(InventoryIndexer::INDEXER_ID)
+ ->addDimension('stock_', (string)$stockId)
+ ->setAlias(Alias::ALIAS_MAIN)
+ ->build();
+
+ if (!$this->indexStructure->isExist($mainIndexName, ResourceConnection::DEFAULT_CONNECTION)) {
+ $this->indexStructure->create($mainIndexName, ResourceConnection::DEFAULT_CONNECTION);
+ }
+
+ $indexData = $this->indexDataBySkuListProvider->execute($stockId, $skuList);
+
+ $this->indexHandler->cleanIndex(
+ $mainIndexName,
+ $indexData,
+ ResourceConnection::DEFAULT_CONNECTION
+ );
+
+ $this->indexHandler->saveIndex(
+ $mainIndexName,
+ $indexData,
+ ResourceConnection::DEFAULT_CONNECTION
+ );
+ }
+ }
+}
diff --git a/InventoryBundleProductIndexer/Indexer/Stock/IndexDataByStockIdProvider.php b/InventoryBundleProductIndexer/Indexer/Stock/IndexDataByStockIdProvider.php
new file mode 100644
index 000000000000..f2c35d9f2f72
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/Stock/IndexDataByStockIdProvider.php
@@ -0,0 +1,53 @@
+selectBuilder = $selectBuilder;
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * Get bundle products for given stock id.
+ *
+ * @param int $stockId
+ *
+ * @return \ArrayIterator
+ * @throws \Exception
+ */
+ public function execute(int $stockId): \ArrayIterator
+ {
+ $select = $this->selectBuilder->execute($stockId);
+ $connection = $this->resourceConnection->getConnection();
+
+ return new \ArrayIterator($connection->fetchAll($select));
+ }
+}
diff --git a/InventoryBundleProductIndexer/Indexer/StockIndexer.php b/InventoryBundleProductIndexer/Indexer/StockIndexer.php
new file mode 100644
index 000000000000..9ffc7e3145e6
--- /dev/null
+++ b/InventoryBundleProductIndexer/Indexer/StockIndexer.php
@@ -0,0 +1,163 @@
+getAllStockIds = $getAllStockIds;
+ $this->indexStructure = $indexStructure;
+ $this->indexHandler = $indexHandler;
+ $this->indexNameBuilder = $indexNameBuilder;
+ $this->indexDataByStockIdProvider = $indexDataByStockIdProvider;
+ $this->indexTableSwitcher = $indexTableSwitcher;
+ $this->defaultStockProvider = $defaultStockProvider;
+ $this->prepareIndexDataForClearingIndex = $prepareIndexDataForClearingIndex;
+ }
+
+ /**
+ * Index bundle products for all stocks.
+ *
+ * @return void
+ * @throws StateException
+ */
+ public function executeFull()
+ {
+ $stockIds = $this->getAllStockIds->execute();
+ $this->executeList($stockIds);
+ }
+
+ /**
+ * Index bundle products for given stock.
+ *
+ * @param int $stockId
+ * @return void
+ * @throws StateException
+ */
+ public function executeRow(int $stockId)
+ {
+ $this->executeList([$stockId]);
+ }
+
+ /**
+ * Index bundle products for given stocks.
+ *
+ * @param array $stockIds
+ * @return void
+ * @throws StateException
+ */
+ public function executeList(array $stockIds)
+ {
+ foreach ($stockIds as $stockId) {
+ if ($this->defaultStockProvider->getId() === $stockId) {
+ continue;
+ }
+
+ $mainIndexName = $this->indexNameBuilder
+ ->setIndexId(InventoryIndexer::INDEXER_ID)
+ ->addDimension('stock_', (string)$stockId)
+ ->setAlias(Alias::ALIAS_MAIN)
+ ->build();
+
+ if (!$this->indexStructure->isExist($mainIndexName, ResourceConnection::DEFAULT_CONNECTION)) {
+ $this->indexStructure->create($mainIndexName, ResourceConnection::DEFAULT_CONNECTION);
+ }
+
+ $indexData = $this->indexDataByStockIdProvider->execute($stockId);
+
+ $this->indexHandler->cleanIndex(
+ $mainIndexName,
+ $this->prepareIndexDataForClearingIndex->execute($indexData),
+ ResourceConnection::DEFAULT_CONNECTION
+ );
+
+ $this->indexHandler->saveIndex(
+ $mainIndexName,
+ $indexData,
+ ResourceConnection::DEFAULT_CONNECTION
+ );
+ }
+ }
+}
diff --git a/InventoryBundleProductIndexer/LICENSE.txt b/InventoryBundleProductIndexer/LICENSE.txt
new file mode 100644
index 000000000000..36b2459f6aa6
--- /dev/null
+++ b/InventoryBundleProductIndexer/LICENSE.txt
@@ -0,0 +1,48 @@
+
+Open Software License ("OSL") v. 3.0
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
diff --git a/InventoryBundleProductIndexer/LICENSE_AFL.txt b/InventoryBundleProductIndexer/LICENSE_AFL.txt
new file mode 100644
index 000000000000..f39d641b18a1
--- /dev/null
+++ b/InventoryBundleProductIndexer/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+Academic Free License ("AFL") v. 3.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Academic Free License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
diff --git a/InventoryBundleProductIndexer/Plugin/InventoryIndexer/SourceItemIndexerPlugin.php b/InventoryBundleProductIndexer/Plugin/InventoryIndexer/SourceItemIndexerPlugin.php
new file mode 100644
index 000000000000..ed664742d8de
--- /dev/null
+++ b/InventoryBundleProductIndexer/Plugin/InventoryIndexer/SourceItemIndexerPlugin.php
@@ -0,0 +1,51 @@
+bundleProductsSourceItemIndexer = $configurableProductsSourceItemIndexer;
+ }
+
+ /**
+ * Reindex source items list for bundle products.
+ *
+ * @param SourceItemIndexer $subject
+ * @param void $result
+ * @param array $sourceItemIds
+ * @return void
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @throws StateException
+ */
+ public function afterExecuteList(
+ SourceItemIndexer $subject,
+ $result,
+ array $sourceItemIds
+ ) {
+ $this->bundleProductsSourceItemIndexer->executeList($sourceItemIds);
+ }
+}
diff --git a/InventoryBundleProductIndexer/Plugin/InventoryIndexer/StockIndexerPlugin.php b/InventoryBundleProductIndexer/Plugin/InventoryIndexer/StockIndexerPlugin.php
new file mode 100644
index 000000000000..1bd641eaaed7
--- /dev/null
+++ b/InventoryBundleProductIndexer/Plugin/InventoryIndexer/StockIndexerPlugin.php
@@ -0,0 +1,51 @@
+bundleProductsStockIndexer = $bundleProductsStockIndexer;
+ }
+
+ /**
+ * Index bundle products for given stocks.
+ *
+ * @param StockIndexer $subject
+ * @param void $result
+ * @param array $stockIds
+ * @return void
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @throws StateException
+ */
+ public function afterExecuteList(
+ StockIndexer $subject,
+ $result,
+ array $stockIds
+ ) {
+ $this->bundleProductsStockIndexer->executeList($stockIds);
+ }
+}
diff --git a/InventoryBundleProductIndexer/README.md b/InventoryBundleProductIndexer/README.md
new file mode 100644
index 000000000000..293e89693876
--- /dev/null
+++ b/InventoryBundleProductIndexer/README.md
@@ -0,0 +1,15 @@
+# InventoryBundleProductIndexer module
+
+The `InventoryBundleProductIndexer` module integrates inventory management business logic into Magento's indexation logic for bundle products.
+
+This module is part of the new inventory infrastructure. The
+[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
+describes the MSI (Multi-Source Inventory) project in more detail.
+
+## Installation details
+
+This module is installed as part of Magento Open Source. It cannot be deleted or disabled.
+
+## Extension points and service contracts
+
+There are no extension points or service contracts for this module.
diff --git a/InventoryBundleProductIndexer/composer.json b/InventoryBundleProductIndexer/composer.json
new file mode 100644
index 000000000000..ad2b14142197
--- /dev/null
+++ b/InventoryBundleProductIndexer/composer.json
@@ -0,0 +1,29 @@
+{
+ "name": "magento/module-inventory-bundle-product-indexer",
+ "description": "N/A",
+ "require": {
+ "php": "~7.1.3||~7.2.0||~7.3.0",
+ "magento/framework": "*",
+ "magento/module-catalog": "*",
+ "magento/module-inventory-api": "*",
+ "magento/module-inventory-catalog-api": "*",
+ "magento/module-inventory-indexer": "*",
+ "magento/module-inventory-multi-dimensional-indexer-api": "*"
+ },
+ "suggest": {
+ "magento/module-inventory": "*"
+ },
+ "type": "magento2-module",
+ "license": [
+ "OSL-3.0",
+ "AFL-3.0"
+ ],
+ "autoload": {
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Magento\\InventoryBundleProductIndexer\\": ""
+ }
+ }
+}
diff --git a/InventoryBundleProductIndexer/etc/di.xml b/InventoryBundleProductIndexer/etc/di.xml
new file mode 100644
index 000000000000..09166a2f440d
--- /dev/null
+++ b/InventoryBundleProductIndexer/etc/di.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+ Magento\InventoryIndexer\Indexer\IndexHandler
+ Magento\InventoryIndexer\Indexer\IndexStructure
+
+
+
+
+ Magento\InventoryIndexer\Indexer\IndexHandler
+ Magento\InventoryIndexer\Indexer\IndexStructure
+
+
+
+
+ Magento\Inventory\Model\ResourceModel\SourceItem::TABLE_NAME_SOURCE_ITEM
+ Magento\Inventory\Model\ResourceModel\StockSourceLink::TABLE_NAME_STOCK_SOURCE_LINK
+
+
+
diff --git a/InventoryBundleProductIndexer/etc/module.xml b/InventoryBundleProductIndexer/etc/module.xml
new file mode 100644
index 000000000000..aa84c748e2a2
--- /dev/null
+++ b/InventoryBundleProductIndexer/etc/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/InventoryBundleProductIndexer/registration.php b/InventoryBundleProductIndexer/registration.php
new file mode 100644
index 000000000000..a50aff5ea9ef
--- /dev/null
+++ b/InventoryBundleProductIndexer/registration.php
@@ -0,0 +1,12 @@
+
-
+
diff --git a/InventoryCatalogAdminUi/Model/GetQuantityInformationPerSourceBySkus.php b/InventoryCatalogAdminUi/Model/GetQuantityInformationPerSourceBySkus.php
new file mode 100644
index 000000000000..4307d8f635fa
--- /dev/null
+++ b/InventoryCatalogAdminUi/Model/GetQuantityInformationPerSourceBySkus.php
@@ -0,0 +1,78 @@
+sourceItemRepository = $sourceItemRepository;
+ $this->searchCriteriaBuilderFactory = $searchCriteriaBuilderFactory;
+ $this->sourceRepository = $sourceRepository;
+ }
+
+ /**
+ * Get products source items by skus.
+ *
+ * @param array $skus
+ * @return array
+ * @throws NoSuchEntityException
+ */
+ public function execute(array $skus): array
+ {
+ $sourceItemsInformation = [];
+
+ $searchCriteriaBuilder = $this->searchCriteriaBuilderFactory->create();
+ $searchCriteria = $searchCriteriaBuilder->addFilter(SourceItemInterface::SKU, $skus, 'in')->create();
+ $sourceItems = $this->sourceItemRepository->getList($searchCriteria)->getItems();
+
+ foreach ($sourceItems as $sourceItem) {
+ $source = $this->sourceRepository->get($sourceItem->getSourceCode());
+ $sourceItemsInformation[$sourceItem['sku']][] = [
+ SourceItemInterface::SOURCE_CODE => $sourceItem->getSourceCode(),
+ SourceItemInterface::QUANTITY => $sourceItem->getQuantity(),
+ 'source_name' => $source->getName(),
+ SourceItemInterface::STATUS => $sourceItem->getStatus(),
+ ];
+ }
+
+ return $sourceItemsInformation;
+ }
+}
diff --git a/InventoryGroupedProductAdminUi/Plugin/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php b/InventoryGroupedProductAdminUi/Plugin/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php
index e6de2e7166f8..82e00c10f571 100644
--- a/InventoryGroupedProductAdminUi/Plugin/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php
+++ b/InventoryGroupedProductAdminUi/Plugin/Ui/DataProvider/Product/Form/AddQuantityPerSourceToProductsData.php
@@ -8,8 +8,8 @@
namespace Magento\InventoryGroupedProductAdminUi\Plugin\Ui\DataProvider\Product\Form;
use Magento\GroupedProduct\Ui\DataProvider\Product\GroupedProductDataProvider;
+use Magento\InventoryCatalogAdminUi\Model\GetQuantityInformationPerSourceBySkus;
use Magento\InventoryCatalogApi\Model\IsSingleSourceModeInterface;
-use Magento\InventoryGroupedProductAdminUi\Model\GetQuantityInformationPerSourceBySkus;
/**
* On multi source mode add data "Quantity Per Source" to loaded items for modal window.
diff --git a/InventoryGroupedProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryGroupedPanel.php b/InventoryGroupedProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryGroupedPanel.php
index 7f5ce2cd4c9a..7d8e61a51134 100644
--- a/InventoryGroupedProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryGroupedPanel.php
+++ b/InventoryGroupedProductAdminUi/Ui/DataProvider/Product/Form/Modifier/InventoryGroupedPanel.php
@@ -11,8 +11,8 @@
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\GroupedProduct\Model\Product\Type\Grouped as GroupedProductType;
use Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\Grouped;
+use Magento\InventoryCatalogAdminUi\Model\GetQuantityInformationPerSourceBySkus;
use Magento\InventoryCatalogApi\Model\IsSingleSourceModeInterface;
-use Magento\InventoryGroupedProductAdminUi\Model\GetQuantityInformationPerSourceBySkus;
use Magento\Ui\Component\Form\Element\Input;
/**
@@ -93,36 +93,39 @@ public function modifyMeta(array $meta): array
if ($this->locator->getProduct()->getTypeId() === GroupedProductType::TYPE_CODE
&& !$this->isSingleSourceMode->execute()
) {
- $meta = array_replace_recursive($meta, [
- 'grouped' => [
- 'children' => [
- 'associated' => [
- 'children' => [
- 'record' => [
- 'children' => [
- 'source_code' => [
- 'arguments' => [
- 'data' => [
- 'config' => $this->getQuantityPerSourceConfig()
- ]
- ]
- ]
- ]
- ]
+ $meta = array_replace_recursive(
+ $meta,
+ [
+ 'grouped' => [
+ 'children' => [
+ 'associated' => [
+ 'children' => [
+ 'record' => [
+ 'children' => [
+ 'source_code' => [
+ 'arguments' => [
+ 'data' => [
+ 'config' => $this->getQuantityPerSourceConfig(),
+ ],
+ ],
+ ],
+ ],
+ ],
+ ],
+ 'arguments' => [
+ 'data' => [
+ 'config' => [
+ 'map' => [
+ 'quantity_per_source' => 'quantity_per_source',
+ ],
+ ],
+ ],
+ ],
],
- 'arguments' => [
- 'data' => [
- 'config' => [
- 'map' => [
- 'quantity_per_source' => 'quantity_per_source'
- ]
- ]
- ]
- ]
- ]
- ]
+ ],
+ ],
]
- ]);
+ );
}
return $meta;