Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit f54386d

Browse files
authored
Merge pull request #2854 from magento-earl-grey/MAGETWO-91606
[earl] MAGETWO-91606: Upgrade to 2.2.2 and above took long time
2 parents 0915691 + 031257c commit f54386d

File tree

3 files changed

+39
-68
lines changed

3 files changed

+39
-68
lines changed

app/code/Magento/Catalog/Setup/Patch/Data/UpgradeWebsiteAttributes.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ private function processAttributeValues(array $attributeValueItems, $tableName)
156156
*/
157157
private function fetchAttributeValues($tableName)
158158
{
159+
//filter store groups which have more than 1 store
160+
$multipleStoresInWebsite = array_values(
161+
array_reduce(
162+
array_filter($this->getGroupedStoreViews(), function ($storeViews) {
163+
return is_array($storeViews) && count($storeViews) > 1;
164+
}),
165+
'array_merge',
166+
[]
167+
)
168+
);
169+
170+
if (count($multipleStoresInWebsite) < 1) {
171+
return [];
172+
}
173+
159174
$connection = $this->moduleDataSetup->getConnection();
160175
$batchSelectIterator = $this->batchQueryGenerator->generate(
161176
'value_id',
@@ -184,9 +199,10 @@ private function fetchAttributeValues($tableName)
184199
self::ATTRIBUTE_WEBSITE
185200
)
186201
->where(
187-
'cpei.store_id <> ?',
188-
self::GLOBAL_STORE_VIEW_ID
189-
)
202+
'cpei.store_id IN (?)',
203+
$multipleStoresInWebsite
204+
),
205+
1000
190206
);
191207

192208
foreach ($batchSelectIterator as $select) {

app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php

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

77
namespace Magento\CatalogSearch\Setup\Patch\Data;
88

9+
use Magento\Framework\App\State;
910
use Magento\Framework\Setup\Patch\DataPatchInterface;
1011
use Magento\Framework\Setup\Patch\PatchVersionInterface;
1112
use Magento\Framework\Indexer\IndexerInterfaceFactory;
@@ -27,17 +28,25 @@ class SetInitialSearchWeightForAttributes implements DataPatchInterface, PatchVe
2728
*/
2829
private $attributeRepository;
2930

31+
/**
32+
* @var State
33+
*/
34+
private $state;
35+
3036
/**
3137
* SetInitialSearchWeightForAttributes constructor.
3238
* @param IndexerInterfaceFactory $indexerFactory
3339
* @param ProductAttributeRepositoryInterface $attributeRepository
40+
* @param State $state
3441
*/
3542
public function __construct(
3643
IndexerInterfaceFactory $indexerFactory,
37-
ProductAttributeRepositoryInterface $attributeRepository
44+
ProductAttributeRepositoryInterface $attributeRepository,
45+
State $state
3846
) {
3947
$this->indexerFactory = $indexerFactory;
4048
$this->attributeRepository = $attributeRepository;
49+
$this->state = $state;
4150
}
4251

4352
/**
@@ -47,6 +56,13 @@ public function apply()
4756
{
4857
$this->setWeight('sku', 6);
4958
$this->setWeight('name', 5);
59+
$indexer = $this->indexerFactory->create()->load('catalogsearch_fulltext');
60+
$this->state->emulateAreaCode(
61+
\Magento\Framework\App\Area::AREA_CRONTAB,
62+
function () use ($indexer) {
63+
$indexer->reindexAll();
64+
}
65+
);
5066
}
5167

5268
/**
@@ -76,8 +92,9 @@ public function getAliases()
7692
/**
7793
* Set attribute search weight.
7894
*
79-
* @param $attributeCode
80-
* @param $weight
95+
* @param string $attributeCode
96+
* @param int $weight
97+
* @return void
8198
*/
8299
private function setWeight($attributeCode, $weight)
83100
{

app/code/Magento/CatalogSearch/Setup/RecurringData.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)