Skip to content

Commit 0d90748

Browse files
committed
ACP2E-1296: product price index (catalog_product_price) not working if bundle product not assigned to any website
1 parent b025795 commit 0d90748

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price/DisabledProductOptionPriceModifier.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
8585
foreach ($this->getBundleIds($entityIds) as $entityId) {
8686
$entityId = (int) $entityId;
8787
foreach ($this->getWebsiteIdsOfProduct($entityId) as $websiteId) {
88+
$websiteId = (int) $websiteId;
8889
$productIdsDisabledRequired = $this->selectionProductsDisabledRequired
89-
->getChildProductIds($entityId, (int)$websiteId);
90+
->getChildProductIds($entityId, $websiteId);
9091
if ($productIdsDisabledRequired) {
9192
$connection = $this->resourceConnection->getConnection('indexer');
9293
$select = $connection->select();
@@ -118,9 +119,8 @@ private function getWebsiteIdsOfProduct(int $entityId): array
118119
['product_in_websites' => $this->resourceConnection->getTableName('catalog_product_website')],
119120
['website_id']
120121
)->where('product_in_websites.product_id = ?', $entityId);
121-
foreach ($connection->fetchCol($select) as $websiteId) {
122-
$this->websiteIdsOfProduct[$entityId][] = (int)$websiteId;
123-
}
122+
$this->websiteIdsOfProduct[$entityId] = $connection->fetchCol($select);
123+
124124
return $this->websiteIdsOfProduct[$entityId];
125125
}
126126

dev/tests/integration/testsuite/Magento/Bundle/Model/ResourceModel/Indexer/PriceTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Bundle\Model\ResourceModel\Indexer;
88

9+
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
910
use Magento\Catalog\Api\ProductRepositoryInterface;
1011
use Magento\Catalog\Model\Indexer\Product\Price;
1112
use Magento\Customer\Model\Group;
@@ -14,6 +15,7 @@
1415
use Magento\Store\Api\WebsiteRepositoryInterface;
1516
use Magento\TestFramework\Catalog\Model\Product\Price\GetPriceIndexDataByProductId;
1617
use Magento\CatalogInventory\Model\Indexer\Stock;
18+
use Magento\TestFramework\Fixture\DataFixture;
1719
use Magento\TestFramework\Helper\Bootstrap;
1820
use PHPUnit\Framework\TestCase;
1921

@@ -91,6 +93,18 @@ public function testExecuteRowWithShowOutOfStock(): void
9193
$this->assertIndexTableData($bundleProduct->getId(), $expectedPrices);
9294
}
9395

96+
#[
97+
DataFixture(
98+
BundleProductFixture::class,
99+
['sku' => 'bundle1', 'extension_attributes' => ['website_ids' => []]]
100+
),
101+
]
102+
public function testExecuteForBundleWithoutWebsites(): void
103+
{
104+
$bundleProduct = $this->productRepository->get('bundle1');
105+
$this->indexer->executeRow($bundleProduct->getId());
106+
}
107+
94108
/**
95109
* Asserts price data in index table.
96110
*

0 commit comments

Comments
 (0)