Version Notes
- FIX: Improve performance issue when backend-search
- FIX: Various small improvements
Download this release
Release Info
| Developer | Algolia Team |
| Extension | algoliasearch |
| Version | 1.4.5 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.4 to 1.4.5
- app/code/community/Algolia/Algoliasearch/Helper/Data.php +39 -8
- app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php +45 -15
- app/code/community/Algolia/Algoliasearch/Model/Indexer/Algolia.php +7 -1
- app/code/community/Algolia/Algoliasearch/Model/Resource/Fulltext.php +8 -0
- app/code/community/Algolia/Algoliasearch/etc/system.xml +1 -1
- app/design/frontend/base/default/template/algoliasearch/topsearch.phtml +1 -1
- package.xml +6 -6
- skin/frontend/base/default/algoliasearch/algoliasearch.css +7 -0
app/code/community/Algolia/Algoliasearch/Helper/Data.php
CHANGED
|
@@ -23,7 +23,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 23 |
|
| 24 |
public function __construct()
|
| 25 |
{
|
| 26 |
-
\AlgoliaSearch\Version::$custom_value = " Magento (1.4.
|
| 27 |
|
| 28 |
$this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
|
| 29 |
|
|
@@ -46,6 +46,9 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 46 |
{
|
| 47 |
$this->algolia_helper->resetCredentialsFromConfig();
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
$this->algolia_helper->setSettings($this->category_helper->getIndexName($storeId), $this->category_helper->getIndexSettings($storeId));
|
| 50 |
$this->algolia_helper->setSettings($this->page_helper->getIndexName($storeId), $this->page_helper->getIndexSettings($storeId));
|
| 51 |
$this->algolia_helper->setSettings($this->suggestion_helper->getIndexName($storeId), $this->suggestion_helper->getIndexSettings($storeId));
|
|
@@ -62,8 +65,13 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 62 |
|
| 63 |
$index_name = $this->product_helper->getIndexName($storeId);
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
$answer = $this->algolia_helper->query($index_name, $query, array(
|
| 66 |
-
'hitsPerPage' =>
|
| 67 |
'attributesToRetrieve' => 'objectID',
|
| 68 |
'attributesToHighlight' => '',
|
| 69 |
'attributesToSnippet' => '',
|
|
@@ -174,7 +182,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 174 |
|
| 175 |
while ($page <= $pages)
|
| 176 |
{
|
| 177 |
-
$this->rebuildStoreCategoryIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage());
|
| 178 |
|
| 179 |
$page++;
|
| 180 |
}
|
|
@@ -237,7 +245,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 237 |
|
| 238 |
while ($page <= $pages)
|
| 239 |
{
|
| 240 |
-
$this->rebuildStoreProductIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage());
|
| 241 |
|
| 242 |
$page++;
|
| 243 |
}
|
|
@@ -284,8 +292,13 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 284 |
unset($collection);
|
| 285 |
}
|
| 286 |
|
| 287 |
-
public function rebuildStoreCategoryIndexPage($storeId, $collectionDefault, $page, $pageSize)
|
| 288 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
$collection = clone $collectionDefault;
|
| 290 |
$collection->setCurPage($page)->setPageSize($pageSize);
|
| 291 |
$collection->load();
|
|
@@ -317,6 +330,9 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 317 |
$collection->clear();
|
| 318 |
|
| 319 |
unset($collection);
|
|
|
|
|
|
|
|
|
|
| 320 |
}
|
| 321 |
|
| 322 |
private function getProductsRecords($storeId, $collection)
|
|
@@ -336,8 +352,13 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 336 |
return $indexData;
|
| 337 |
}
|
| 338 |
|
| 339 |
-
public function rebuildStoreProductIndexPage($storeId, $collectionDefault, $page, $pageSize)
|
| 340 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
$collection = clone $collectionDefault;
|
| 342 |
$collection->setCurPage($page)->setPageSize($pageSize);
|
| 343 |
$collection->load();
|
|
@@ -346,7 +367,6 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 346 |
|
| 347 |
$index_name = $this->product_helper->getIndexName($storeId);
|
| 348 |
|
| 349 |
-
|
| 350 |
/**
|
| 351 |
* Normal Indexing
|
| 352 |
*/
|
|
@@ -361,11 +381,17 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 361 |
$collection->clear();
|
| 362 |
|
| 363 |
unset($collection);
|
|
|
|
|
|
|
|
|
|
| 364 |
}
|
| 365 |
|
| 366 |
public function startEmulation($storeId)
|
| 367 |
{
|
| 368 |
-
$
|
|
|
|
|
|
|
|
|
|
| 369 |
$info->setInitialStoreId(Mage::app()->getStore()->getId());
|
| 370 |
$info->setEmulatedStoreId($storeId);
|
| 371 |
$info->setUseProductFlat(Mage::getStoreConfigFlag(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, $storeId));
|
|
@@ -373,13 +399,18 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 373 |
Mage::app()->setCurrentStore($storeId);
|
| 374 |
Mage::app()->getStore($storeId)->setConfig(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, FALSE);
|
| 375 |
Mage::app()->getStore($storeId)->setConfig(Mage_Catalog_Helper_Category_Flat::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY, FALSE);
|
|
|
|
| 376 |
return $info;
|
| 377 |
}
|
| 378 |
|
| 379 |
public function stopEmulation($info)
|
| 380 |
{
|
|
|
|
|
|
|
| 381 |
Mage::app()->setCurrentStore($info->getInitialStoreId());
|
| 382 |
Mage::app()->getStore($info->getEmulatedStoreId())->setConfig(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, $info->getUseProductFlat());
|
| 383 |
Mage::app()->getStore($info->getEmulatedStoreId())->setConfig(Mage_Catalog_Helper_Category_Flat::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY, $info->getUseCategoryFlat());
|
|
|
|
|
|
|
| 384 |
}
|
| 385 |
}
|
| 23 |
|
| 24 |
public function __construct()
|
| 25 |
{
|
| 26 |
+
\AlgoliaSearch\Version::$custom_value = " Magento (1.4.5)";
|
| 27 |
|
| 28 |
$this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
|
| 29 |
|
| 46 |
{
|
| 47 |
$this->algolia_helper->resetCredentialsFromConfig();
|
| 48 |
|
| 49 |
+
if (! ($this->config->getApplicationID() && $this->config->getAPIKey()))
|
| 50 |
+
return;
|
| 51 |
+
|
| 52 |
$this->algolia_helper->setSettings($this->category_helper->getIndexName($storeId), $this->category_helper->getIndexSettings($storeId));
|
| 53 |
$this->algolia_helper->setSettings($this->page_helper->getIndexName($storeId), $this->page_helper->getIndexSettings($storeId));
|
| 54 |
$this->algolia_helper->setSettings($this->suggestion_helper->getIndexName($storeId), $this->suggestion_helper->getIndexSettings($storeId));
|
| 65 |
|
| 66 |
$index_name = $this->product_helper->getIndexName($storeId);
|
| 67 |
|
| 68 |
+
$number_of_results = 1000;
|
| 69 |
+
|
| 70 |
+
if ($this->config->isInstantEnabled())
|
| 71 |
+
$number_of_results = min($this->config->getNumberOfProductResults($storeId), 1000);
|
| 72 |
+
|
| 73 |
$answer = $this->algolia_helper->query($index_name, $query, array(
|
| 74 |
+
'hitsPerPage' => $number_of_results, // retrieve all the hits (hard limit is 1000)
|
| 75 |
'attributesToRetrieve' => 'objectID',
|
| 76 |
'attributesToHighlight' => '',
|
| 77 |
'attributesToSnippet' => '',
|
| 182 |
|
| 183 |
while ($page <= $pages)
|
| 184 |
{
|
| 185 |
+
$this->rebuildStoreCategoryIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage(), $emulationInfo);
|
| 186 |
|
| 187 |
$page++;
|
| 188 |
}
|
| 245 |
|
| 246 |
while ($page <= $pages)
|
| 247 |
{
|
| 248 |
+
$this->rebuildStoreProductIndexPage($storeId, $collection, $page, $this->config->getNumberOfElementByPage(), $emulationInfo);
|
| 249 |
|
| 250 |
$page++;
|
| 251 |
}
|
| 292 |
unset($collection);
|
| 293 |
}
|
| 294 |
|
| 295 |
+
public function rebuildStoreCategoryIndexPage($storeId, $collectionDefault, $page, $pageSize, $emulationInfo = null)
|
| 296 |
{
|
| 297 |
+
$emulationInfoPage = null;
|
| 298 |
+
|
| 299 |
+
if ($emulationInfo === null)
|
| 300 |
+
$emulationInfoPage = $this->startEmulation($storeId);
|
| 301 |
+
|
| 302 |
$collection = clone $collectionDefault;
|
| 303 |
$collection->setCurPage($page)->setPageSize($pageSize);
|
| 304 |
$collection->load();
|
| 330 |
$collection->clear();
|
| 331 |
|
| 332 |
unset($collection);
|
| 333 |
+
|
| 334 |
+
if ($emulationInfo === null)
|
| 335 |
+
$this->stopEmulation($emulationInfoPage);
|
| 336 |
}
|
| 337 |
|
| 338 |
private function getProductsRecords($storeId, $collection)
|
| 352 |
return $indexData;
|
| 353 |
}
|
| 354 |
|
| 355 |
+
public function rebuildStoreProductIndexPage($storeId, $collectionDefault, $page, $pageSize, $emulationInfo = null)
|
| 356 |
{
|
| 357 |
+
$emulationInfoPage = null;
|
| 358 |
+
|
| 359 |
+
if ($emulationInfo === null)
|
| 360 |
+
$emulationInfoPage = $this->startEmulation($storeId);
|
| 361 |
+
|
| 362 |
$collection = clone $collectionDefault;
|
| 363 |
$collection->setCurPage($page)->setPageSize($pageSize);
|
| 364 |
$collection->load();
|
| 367 |
|
| 368 |
$index_name = $this->product_helper->getIndexName($storeId);
|
| 369 |
|
|
|
|
| 370 |
/**
|
| 371 |
* Normal Indexing
|
| 372 |
*/
|
| 381 |
$collection->clear();
|
| 382 |
|
| 383 |
unset($collection);
|
| 384 |
+
|
| 385 |
+
if ($emulationInfo === null)
|
| 386 |
+
$this->stopEmulation($emulationInfoPage);
|
| 387 |
}
|
| 388 |
|
| 389 |
public function startEmulation($storeId)
|
| 390 |
{
|
| 391 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
| 392 |
+
|
| 393 |
+
$info = $appEmulation->startEnvironmentEmulation($storeId);
|
| 394 |
+
|
| 395 |
$info->setInitialStoreId(Mage::app()->getStore()->getId());
|
| 396 |
$info->setEmulatedStoreId($storeId);
|
| 397 |
$info->setUseProductFlat(Mage::getStoreConfigFlag(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, $storeId));
|
| 399 |
Mage::app()->setCurrentStore($storeId);
|
| 400 |
Mage::app()->getStore($storeId)->setConfig(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, FALSE);
|
| 401 |
Mage::app()->getStore($storeId)->setConfig(Mage_Catalog_Helper_Category_Flat::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY, FALSE);
|
| 402 |
+
|
| 403 |
return $info;
|
| 404 |
}
|
| 405 |
|
| 406 |
public function stopEmulation($info)
|
| 407 |
{
|
| 408 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
| 409 |
+
|
| 410 |
Mage::app()->setCurrentStore($info->getInitialStoreId());
|
| 411 |
Mage::app()->getStore($info->getEmulatedStoreId())->setConfig(Mage_Catalog_Helper_Product_Flat::XML_PATH_USE_PRODUCT_FLAT, $info->getUseProductFlat());
|
| 412 |
Mage::app()->getStore($info->getEmulatedStoreId())->setConfig(Mage_Catalog_Helper_Category_Flat::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY, $info->getUseCategoryFlat());
|
| 413 |
+
|
| 414 |
+
$appEmulation->stopEnvironmentEmulation($info);
|
| 415 |
}
|
| 416 |
}
|
app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php
CHANGED
|
@@ -185,7 +185,8 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 185 |
|
| 186 |
$suffix_index_name = '_group_' . $group_id;
|
| 187 |
|
| 188 |
-
$
|
|
|
|
| 189 |
|
| 190 |
$this->algolia_helper->setSettings($this->getIndexName($storeId).$suffix_index_name.'_'.$values['attribute'].'_'.$values['sort'], $mergeSettings);
|
| 191 |
}
|
|
@@ -193,7 +194,9 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 193 |
}
|
| 194 |
else
|
| 195 |
{
|
| 196 |
-
$
|
|
|
|
|
|
|
| 197 |
|
| 198 |
$this->algolia_helper->setSettings($this->getIndexName($storeId) . '_' . 'default' . '_' .$values['attribute'].'_'.$values['sort'], $mergeSettings);
|
| 199 |
}
|
|
@@ -263,10 +266,15 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 263 |
$customData = array(
|
| 264 |
'objectID' => $product->getId(),
|
| 265 |
'name' => $product->getName(),
|
| 266 |
-
'url' => $product->getProductUrl()
|
| 267 |
-
'description' => $product->getDescription()
|
| 268 |
);
|
| 269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
foreach (array('price', 'price_with_tax', 'special_price_from_date', 'special_price_to_date', 'special_price'
|
| 271 |
,'special_price_with_tax', 'special_price_formated', 'special_price_with_tax_formated'
|
| 272 |
,'price_formated', 'price_with_tax_formated') as $price)
|
|
@@ -364,9 +372,14 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 364 |
$customData['image_url'] = str_replace(array('https://', 'http://'), '//', $customData['image_url']);
|
| 365 |
}
|
| 366 |
catch (\Exception $e) {}
|
| 367 |
-
}
|
| 368 |
|
| 369 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
|
| 371 |
$sub_products = null;
|
| 372 |
$ids = null;
|
|
@@ -409,7 +422,12 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 409 |
}, $sub_products);
|
| 410 |
}
|
| 411 |
|
| 412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
| 414 |
if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'configurable')
|
| 415 |
{
|
|
@@ -505,14 +523,17 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 505 |
}
|
| 506 |
|
| 507 |
|
| 508 |
-
if (
|
| 509 |
{
|
| 510 |
-
$
|
| 511 |
-
|
| 512 |
-
|
|
|
|
|
|
|
| 513 |
|
| 514 |
-
|
| 515 |
-
|
|
|
|
| 516 |
}
|
| 517 |
|
| 518 |
foreach ($additionalAttributes as $attribute)
|
|
@@ -537,6 +558,11 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 537 |
|
| 538 |
foreach ($sub_products as $sub_product)
|
| 539 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
$value = $sub_product->getData($attribute['attribute']);
|
| 541 |
|
| 542 |
if ($value)
|
|
@@ -552,7 +578,7 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 552 |
|
| 553 |
if (count($values) > 0)
|
| 554 |
{
|
| 555 |
-
$customData[$attribute['attribute']] = $values;
|
| 556 |
}
|
| 557 |
}
|
| 558 |
}
|
|
@@ -576,6 +602,10 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 576 |
}
|
| 577 |
}
|
| 578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
$customData = array_merge($customData, $defaultData);
|
| 580 |
|
| 581 |
$customData['type_id'] = $product->getTypeId();
|
|
@@ -584,4 +614,4 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 584 |
|
| 585 |
return $customData;
|
| 586 |
}
|
| 587 |
-
}
|
| 185 |
|
| 186 |
$suffix_index_name = '_group_' . $group_id;
|
| 187 |
|
| 188 |
+
$sort_attribute = strpos($values['attribute'], 'price') !== false ? $values['attribute'].'.'.$group_id : $values['attribute'];
|
| 189 |
+
$mergeSettings['ranking'] = array($values['sort'].'('.$sort_attribute.')', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom');
|
| 190 |
|
| 191 |
$this->algolia_helper->setSettings($this->getIndexName($storeId).$suffix_index_name.'_'.$values['attribute'].'_'.$values['sort'], $mergeSettings);
|
| 192 |
}
|
| 194 |
}
|
| 195 |
else
|
| 196 |
{
|
| 197 |
+
$sort_attribute = strpos($values['attribute'], 'price') !== false ? $values['attribute'].'.'.'default' : $values['attribute'];
|
| 198 |
+
|
| 199 |
+
$mergeSettings['ranking'] = array($values['sort'].'('.$sort_attribute.')', 'typo', 'geo', 'words', 'proximity', 'attribute', 'exact', 'custom');
|
| 200 |
|
| 201 |
$this->algolia_helper->setSettings($this->getIndexName($storeId) . '_' . 'default' . '_' .$values['attribute'].'_'.$values['sort'], $mergeSettings);
|
| 202 |
}
|
| 266 |
$customData = array(
|
| 267 |
'objectID' => $product->getId(),
|
| 268 |
'name' => $product->getName(),
|
| 269 |
+
'url' => $product->getProductUrl()
|
|
|
|
| 270 |
);
|
| 271 |
|
| 272 |
+
$additionalAttributes = $this->config->getProductAdditionalAttributes($product->getStoreId());
|
| 273 |
+
|
| 274 |
+
if ($this->isAttributeEnabled($additionalAttributes, 'description'))
|
| 275 |
+
$customData['description'] = $product->getDescription();
|
| 276 |
+
|
| 277 |
+
|
| 278 |
foreach (array('price', 'price_with_tax', 'special_price_from_date', 'special_price_to_date', 'special_price'
|
| 279 |
,'special_price_with_tax', 'special_price_formated', 'special_price_with_tax_formated'
|
| 280 |
,'price_formated', 'price_with_tax_formated') as $price)
|
| 372 |
$customData['image_url'] = str_replace(array('https://', 'http://'), '//', $customData['image_url']);
|
| 373 |
}
|
| 374 |
catch (\Exception $e) {}
|
|
|
|
| 375 |
|
| 376 |
+
$product->load('media_gallery');
|
| 377 |
+
|
| 378 |
+
$customData['images'] = array();
|
| 379 |
+
|
| 380 |
+
foreach ($product->getMediaGalleryImages() as $image)
|
| 381 |
+
$customData['images'][] = str_replace(array('https://', 'http://'), '//', $image->getUrl());
|
| 382 |
+
}
|
| 383 |
|
| 384 |
$sub_products = null;
|
| 385 |
$ids = null;
|
| 422 |
}, $sub_products);
|
| 423 |
}
|
| 424 |
|
| 425 |
+
if (count($ids)) {
|
| 426 |
+
$sub_products = $this->getProductCollectionQuery($product->getStoreId(), $ids, false)->load();
|
| 427 |
+
}
|
| 428 |
+
else {
|
| 429 |
+
$sub_products = array();
|
| 430 |
+
}
|
| 431 |
|
| 432 |
if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'configurable')
|
| 433 |
{
|
| 523 |
}
|
| 524 |
|
| 525 |
|
| 526 |
+
if (Mage::helper('core')->isModuleEnabled('Mage_Review'))
|
| 527 |
{
|
| 528 |
+
if ($this->isAttributeEnabled($additionalAttributes, 'rating_summary'))
|
| 529 |
+
{
|
| 530 |
+
$summaryData = Mage::getModel('review/review_summary')
|
| 531 |
+
->setStoreId($product->getStoreId())
|
| 532 |
+
->load($product->getId());
|
| 533 |
|
| 534 |
+
if ($summaryData['rating_summary'])
|
| 535 |
+
$customData['rating_summary'] = $summaryData['rating_summary'];
|
| 536 |
+
}
|
| 537 |
}
|
| 538 |
|
| 539 |
foreach ($additionalAttributes as $attribute)
|
| 558 |
|
| 559 |
foreach ($sub_products as $sub_product)
|
| 560 |
{
|
| 561 |
+
$stock = (int) $sub_product->getStockItem()->getIsInStock();
|
| 562 |
+
|
| 563 |
+
if ($stock == false)
|
| 564 |
+
continue;
|
| 565 |
+
|
| 566 |
$value = $sub_product->getData($attribute['attribute']);
|
| 567 |
|
| 568 |
if ($value)
|
| 578 |
|
| 579 |
if (count($values) > 0)
|
| 580 |
{
|
| 581 |
+
$customData[$attribute['attribute']] = array_values(array_unique($values));
|
| 582 |
}
|
| 583 |
}
|
| 584 |
}
|
| 602 |
}
|
| 603 |
}
|
| 604 |
|
| 605 |
+
$transport = new Varien_Object($customData);
|
| 606 |
+
Mage::dispatchEvent('algolia_subproducts_index', array('custom_data' => $transport, 'sub_products' => $sub_products));
|
| 607 |
+
$customData = $transport->getData();
|
| 608 |
+
|
| 609 |
$customData = array_merge($customData, $defaultData);
|
| 610 |
|
| 611 |
$customData['type_id'] = $product->getTypeId();
|
| 614 |
|
| 615 |
return $customData;
|
| 616 |
}
|
| 617 |
+
}
|
app/code/community/Algolia/Algoliasearch/Model/Indexer/Algolia.php
CHANGED
|
@@ -9,6 +9,7 @@ class Algolia_Algoliasearch_Model_Indexer_Algolia extends Mage_Index_Model_Index
|
|
| 9 |
private $config;
|
| 10 |
|
| 11 |
public static $product_categories = array();
|
|
|
|
| 12 |
|
| 13 |
public function __construct()
|
| 14 |
{
|
|
@@ -231,7 +232,12 @@ class Algolia_Algoliasearch_Model_Indexer_Algolia extends Mage_Index_Model_Index
|
|
| 231 |
{
|
| 232 |
if (! $this->config->getApplicationID() || ! $this->config->getAPIKey() || ! $this->config->getSearchOnlyAPIKey())
|
| 233 |
{
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
return;
|
| 236 |
}
|
| 237 |
|
| 9 |
private $config;
|
| 10 |
|
| 11 |
public static $product_categories = array();
|
| 12 |
+
private static $credential_error = false;
|
| 13 |
|
| 14 |
public function __construct()
|
| 15 |
{
|
| 232 |
{
|
| 233 |
if (! $this->config->getApplicationID() || ! $this->config->getAPIKey() || ! $this->config->getSearchOnlyAPIKey())
|
| 234 |
{
|
| 235 |
+
if (self::$credential_error === false)
|
| 236 |
+
{
|
| 237 |
+
Mage::getSingleton('adminhtml/session')->addError('Algolia indexing failed: You need to configure your Algolia credentials in System > Configuration > Algolia Search.');
|
| 238 |
+
self::$credential_error = true;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
return;
|
| 242 |
}
|
| 243 |
|
app/code/community/Algolia/Algoliasearch/Model/Resource/Fulltext.php
CHANGED
|
@@ -6,11 +6,13 @@ class Algolia_Algoliasearch_Model_Resource_Fulltext extends Mage_CatalogSearch_M
|
|
| 6 |
/** Empty because we need it to do nothing (no mysql stuff), Indexing is handled by Model/Indexer/Algolia */
|
| 7 |
|
| 8 |
private $engine;
|
|
|
|
| 9 |
|
| 10 |
public function __construct()
|
| 11 |
{
|
| 12 |
parent::__construct();
|
| 13 |
$this->engine = new Algolia_Algoliasearch_Model_Resource_Engine();
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
public function prepareResult($object, $queryText, $query)
|
|
@@ -38,6 +40,12 @@ class Algolia_Algoliasearch_Model_Resource_Fulltext extends Mage_CatalogSearch_M
|
|
| 38 |
*/
|
| 39 |
public function rebuildIndex($storeId = null, $productIds = null)
|
| 40 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
/** Avoid Indexing twice */
|
| 42 |
if (is_array($productIds) && $productIds > 0)
|
| 43 |
return $this;
|
| 6 |
/** Empty because we need it to do nothing (no mysql stuff), Indexing is handled by Model/Indexer/Algolia */
|
| 7 |
|
| 8 |
private $engine;
|
| 9 |
+
private $config;
|
| 10 |
|
| 11 |
public function __construct()
|
| 12 |
{
|
| 13 |
parent::__construct();
|
| 14 |
$this->engine = new Algolia_Algoliasearch_Model_Resource_Engine();
|
| 15 |
+
$this->config = Mage::helper('algoliasearch/config');
|
| 16 |
}
|
| 17 |
|
| 18 |
public function prepareResult($object, $queryText, $query)
|
| 40 |
*/
|
| 41 |
public function rebuildIndex($storeId = null, $productIds = null)
|
| 42 |
{
|
| 43 |
+
if (! $this->config->getApplicationID() || ! $this->config->getAPIKey() || ! $this->config->getSearchOnlyAPIKey())
|
| 44 |
+
{
|
| 45 |
+
Mage::getSingleton('adminhtml/session')->addError('Algolia reindexing failed: You need to configure your Algolia credentials in System > Configuration > Algolia Search.');
|
| 46 |
+
return;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
/** Avoid Indexing twice */
|
| 50 |
if (is_array($productIds) && $productIds > 0)
|
| 51 |
return $this;
|
app/code/community/Algolia/Algoliasearch/etc/system.xml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<algoliasearch translate="label" module="algoliasearch">
|
| 5 |
<label>
|
| 6 |
<