Skip to content

Commit 33f230c

Browse files
committed
MAGETWO-87551: Convert existing data install/upgrade scripts
- moved full reindex to recurring
1 parent 9897dd6 commit 33f230c

File tree

2 files changed

+63
-11
lines changed

2 files changed

+63
-11
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogRuleSampleData\Setup;
8+
9+
use Magento\Framework\App\State;
10+
use Magento\Framework\Indexer\IndexerInterfaceFactory;
11+
use Magento\Framework\Setup\InstallDataInterface;
12+
use Magento\Framework\Setup\ModuleContextInterface;
13+
use Magento\Framework\Setup\ModuleDataSetupInterface;
14+
15+
/**
16+
* Recurring data install.
17+
*/
18+
class RecurringData implements InstallDataInterface
19+
{
20+
/**
21+
* @var State
22+
*/
23+
private $state;
24+
25+
/**
26+
* @var \Magento\Indexer\Model\Indexer\CollectionFactory
27+
*/
28+
private $indexerCollectionFactory;
29+
30+
/**
31+
* Init
32+
*
33+
* @param IndexerInterfaceFactory $indexerInterfaceFactory
34+
*/
35+
public function __construct(
36+
State $state,
37+
\Magento\Indexer\Model\Indexer\CollectionFactory $indexerCollectionFactory
38+
) {
39+
$this->state = $state;
40+
$this->indexerCollectionFactory = $indexerCollectionFactory;
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
47+
{
48+
$this->state->emulateAreaCode(
49+
\Magento\Framework\App\Area::AREA_CRONTAB,
50+
[$this, 'reindex']
51+
);
52+
}
53+
54+
/**
55+
* Perform full reindex
56+
*/
57+
public function reindex()
58+
{
59+
foreach ($this->indexerCollectionFactory->create()->getItems() as $indexer) {
60+
$indexer->reindexAll();
61+
}
62+
}
63+
}

app/code/Magento/ConfigurableSampleData/Model/Product.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,5 @@ public function install()
9898
chdir($currentPath);
9999

100100
$this->eavConfig->clear();
101-
$this->reindex();
102-
}
103-
104-
/**
105-
* Perform full reindex
106-
*/
107-
private function reindex()
108-
{
109-
foreach ($this->indexerCollectionFactory->create()->getItems() as $indexer) {
110-
$indexer->reindexAll();
111-
}
112101
}
113102
}

0 commit comments

Comments
 (0)