Skip to content

Commit

Permalink
ACP2E-1296: product price index (catalog_product_price) not working i…
Browse files Browse the repository at this point in the history
…f bundle product not assigned to any website
  • Loading branch information
dhorytskyi committed Oct 20, 2022
1 parent b025795 commit 0d90748
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
foreach ($this->getBundleIds($entityIds) as $entityId) {
$entityId = (int) $entityId;
foreach ($this->getWebsiteIdsOfProduct($entityId) as $websiteId) {
$websiteId = (int) $websiteId;
$productIdsDisabledRequired = $this->selectionProductsDisabledRequired
->getChildProductIds($entityId, (int)$websiteId);
->getChildProductIds($entityId, $websiteId);
if ($productIdsDisabledRequired) {
$connection = $this->resourceConnection->getConnection('indexer');
$select = $connection->select();
Expand Down Expand Up @@ -118,9 +119,8 @@ private function getWebsiteIdsOfProduct(int $entityId): array
['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;
}
$this->websiteIdsOfProduct[$entityId] = $connection->fetchCol($select);

return $this->websiteIdsOfProduct[$entityId];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magento\Bundle\Model\ResourceModel\Indexer;

use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Indexer\Product\Price;
use Magento\Customer\Model\Group;
Expand All @@ -14,6 +15,7 @@
use Magento\Store\Api\WebsiteRepositoryInterface;
use Magento\TestFramework\Catalog\Model\Product\Price\GetPriceIndexDataByProductId;
use Magento\CatalogInventory\Model\Indexer\Stock;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;

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

#[
DataFixture(
BundleProductFixture::class,
['sku' => 'bundle1', 'extension_attributes' => ['website_ids' => []]]
),
]
public function testExecuteForBundleWithoutWebsites(): void
{
$bundleProduct = $this->productRepository->get('bundle1');
$this->indexer->executeRow($bundleProduct->getId());
}

/**
* Asserts price data in index table.
*
Expand Down

0 comments on commit 0d90748

Please sign in to comment.