Skip to content

Commit 0826f34

Browse files
committed
MAGETWO-94086: [Forwardport] Run Catalog Search reindex in multithread mode with AdvancedSearch
1 parent 2e2771d commit 0826f34

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

app/code/Magento/AdvancedSearch/Model/ResourceModel/Index.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Catalog\Model\Indexer\Category\Product\AbstractAction;
1717
use Magento\Framework\Search\Request\IndexScopeResolverInterface as TableResolver;
1818
use Magento\Catalog\Model\Indexer\Product\Price\DimensionCollectionFactory;
19+
use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
1920

2021
/**
2122
* @api
@@ -47,6 +48,11 @@ class Index extends AbstractDb
4748
*/
4849
private $dimensionCollectionFactory;
4950

51+
/**
52+
* @var int|null
53+
*/
54+
private $websiteId;
55+
5056
/**
5157
* Index constructor.
5258
* @param Context $context
@@ -94,12 +100,17 @@ protected function _getCatalogProductPriceData($productIds = null)
94100
$catalogProductIndexPriceSelect = [];
95101

96102
foreach ($this->dimensionCollectionFactory->create() as $dimensions) {
97-
$catalogProductIndexPriceSelect[] = $connection->select()->from(
98-
$this->tableResolver->resolve('catalog_product_index_price', $dimensions),
99-
['entity_id', 'customer_group_id', 'website_id', 'min_price']
100-
);
101-
if ($productIds) {
102-
current($catalogProductIndexPriceSelect)->where('entity_id IN (?)', $productIds);
103+
if (!isset($dimensions[WebsiteDimensionProvider::DIMENSION_NAME]) ||
104+
$this->websiteId === null ||
105+
$dimensions[WebsiteDimensionProvider::DIMENSION_NAME]->getValue() === $this->websiteId) {
106+
$select = $connection->select()->from(
107+
$this->tableResolver->resolve('catalog_product_index_price', $dimensions),
108+
['entity_id', 'customer_group_id', 'website_id', 'min_price']
109+
);
110+
if ($productIds) {
111+
$select->where('entity_id IN (?)', $productIds);
112+
}
113+
$catalogProductIndexPriceSelect[] = $select;
103114
}
104115
}
105116

@@ -123,9 +134,12 @@ protected function _getCatalogProductPriceData($productIds = null)
123134
*/
124135
public function getPriceIndexData($productIds, $storeId)
125136
{
137+
$websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
138+
139+
$this->websiteId = $websiteId;
126140
$priceProductsIndexData = $this->_getCatalogProductPriceData($productIds);
141+
$this->websiteId = null;
127142

128-
$websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
129143
if (!isset($priceProductsIndexData[$websiteId])) {
130144
return [];
131145
}

app/code/Magento/Elasticsearch/etc/indexer.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<indexer id="catalogsearch_fulltext">
1010
<dependencies>
1111
<indexer id="cataloginventory_stock" />
12+
<indexer id="catalog_product_price" />
1213
</dependencies>
1314
</indexer>
1415
</config>

dev/tests/integration/testsuite/Magento/Catalog/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function setUp()
125125

126126
/**
127127
* @magentoDataFixture Magento/Catalog/_files/product_has_tier_price_show_as_low_as.php
128-
* @magentoDbIsolation enabled
128+
* @magentoDbIsolation disabled
129129
* @magentoAppIsolation enabled
130130
*/
131131
public function testRenderAmountMinimalProductWithTierPricesShouldShowMinTierPrice()
@@ -136,7 +136,7 @@ public function testRenderAmountMinimalProductWithTierPricesShouldShowMinTierPri
136136

137137
/**
138138
* @magentoDataFixture Magento/Catalog/_files/product_different_store_prices.php
139-
* @magentoDbIsolation enabled
139+
* @magentoDbIsolation disabled
140140
* @magentoAppIsolation enabled
141141
* @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1
142142
*/

dev/tests/integration/testsuite/Magento/Sales/Model/Order/Address/RendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp()
4646

4747
/**
4848
* @magentoDataFixture Magento/Sales/_files/order_fixture_store.php
49-
* @magentoDbIsolation enabled
49+
* @magentoDbIsolation disabled
5050
* @magentoAppIsolation enabled
5151
*/
5252
public function testFormat()

0 commit comments

Comments
 (0)