Skip to content

Commit

Permalink
Merge pull request #2854 from magento-earl-grey/MAGETWO-91606
Browse files Browse the repository at this point in the history
[earl] MAGETWO-91606: Upgrade to 2.2.2 and above took long time
  • Loading branch information
cpartica authored Jul 19, 2018
2 parents 0915691 + 031257c commit f54386d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,21 @@ private function processAttributeValues(array $attributeValueItems, $tableName)
*/
private function fetchAttributeValues($tableName)
{
//filter store groups which have more than 1 store
$multipleStoresInWebsite = array_values(
array_reduce(
array_filter($this->getGroupedStoreViews(), function ($storeViews) {
return is_array($storeViews) && count($storeViews) > 1;
}),
'array_merge',
[]
)
);

if (count($multipleStoresInWebsite) < 1) {
return [];
}

$connection = $this->moduleDataSetup->getConnection();
$batchSelectIterator = $this->batchQueryGenerator->generate(
'value_id',
Expand Down Expand Up @@ -184,9 +199,10 @@ private function fetchAttributeValues($tableName)
self::ATTRIBUTE_WEBSITE
)
->where(
'cpei.store_id <> ?',
self::GLOBAL_STORE_VIEW_ID
)
'cpei.store_id IN (?)',
$multipleStoresInWebsite
),
1000
);

foreach ($batchSelectIterator as $select) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magento\CatalogSearch\Setup\Patch\Data;

use Magento\Framework\App\State;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Framework\Indexer\IndexerInterfaceFactory;
Expand All @@ -27,17 +28,25 @@ class SetInitialSearchWeightForAttributes implements DataPatchInterface, PatchVe
*/
private $attributeRepository;

/**
* @var State
*/
private $state;

/**
* SetInitialSearchWeightForAttributes constructor.
* @param IndexerInterfaceFactory $indexerFactory
* @param ProductAttributeRepositoryInterface $attributeRepository
* @param State $state
*/
public function __construct(
IndexerInterfaceFactory $indexerFactory,
ProductAttributeRepositoryInterface $attributeRepository
ProductAttributeRepositoryInterface $attributeRepository,
State $state
) {
$this->indexerFactory = $indexerFactory;
$this->attributeRepository = $attributeRepository;
$this->state = $state;
}

/**
Expand All @@ -47,6 +56,13 @@ public function apply()
{
$this->setWeight('sku', 6);
$this->setWeight('name', 5);
$indexer = $this->indexerFactory->create()->load('catalogsearch_fulltext');
$this->state->emulateAreaCode(
\Magento\Framework\App\Area::AREA_CRONTAB,
function () use ($indexer) {
$indexer->reindexAll();
}
);
}

/**
Expand Down Expand Up @@ -76,8 +92,9 @@ public function getAliases()
/**
* Set attribute search weight.
*
* @param $attributeCode
* @param $weight
* @param string $attributeCode
* @param int $weight
* @return void
*/
private function setWeight($attributeCode, $weight)
{
Expand Down
62 changes: 0 additions & 62 deletions app/code/Magento/CatalogSearch/Setup/RecurringData.php

This file was deleted.

0 comments on commit f54386d

Please sign in to comment.