Skip to content

Commit b495fe2

Browse files
author
Geza Buza
committed
SHOP-141: Do not try to reindex Elasticsearch data
When the engine is not active, do not build the indexes.
1 parent b2a2f0a commit b495fe2

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

src/app/code/community/Smile/ElasticSearch/Model/Indexer/Fulltext.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public function getCurrentIndex()
188188
*/
189189
public function reindexAll()
190190
{
191+
$helper = Mage::helper('smile_elasticsearch');
192+
193+
if (!$helper->isActiveEngine()) {
194+
return;
195+
}
191196
$index = $this->getCurrentIndex();
192197

193198
$index->prepareNewIndex();

src/app/code/community/Smile/ElasticSearch/Model/Indexer/Search/Terms/Position.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ protected function _registerEvent(Mage_Index_Model_Event $event)
116116
*/
117117
public function reindexAll()
118118
{
119+
$helper = Mage::helper('smile_elasticsearch');
120+
if (!$helper->isActiveEngine()) {
121+
return;
122+
}
123+
119124
/** Reindex all data from search terms custom positions index */
120125
$engine = Mage::helper('catalogsearch')->getEngine();
121126
$mapping = $engine->getCurrentIndex()->getMapping('product');

src/app/code/community/Smile/ElasticSearch/Model/Observer.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818
*/
1919
class Smile_ElasticSearch_Model_Observer
2020
{
21+
private $_factory;
22+
23+
public function __construct($services = [])
24+
{
25+
if (isset($services['factory']) && $services['factory'] instanceof Mage_Core_Model_Factory) {
26+
$this->_factory = $services['factory'];
27+
} else {
28+
$this->_factory = new Mage_Core_Model_Factory();
29+
}
30+
}
31+
2132
/**
2233
* Adds search weight parameter in attribute form.
2334
*

src/app/code/community/Smile/VirtualCategories/Model/Indexer/VirtualCategories/Product/Position.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ protected function _registerEvent(Mage_Index_Model_Event $event)
125125
*/
126126
public function reindexAll()
127127
{
128+
$helper = Mage::helper('smile_elasticsearch');
129+
if (!$helper->isActiveEngine()) {
130+
return;
131+
}
132+
128133
/** Reindex all data from search terms custom positions index */
129134
$engine = Mage::helper('catalogsearch')->getEngine();
130135
$mapping = $engine->getCurrentIndex()->getMapping('product');

0 commit comments

Comments
 (0)