Skip to content

Commit 0e17a7a

Browse files
author
maxiloc
committed
Merge pull request #367 from algolia/develop
1.5.5 release
2 parents a91de23 + afdffd9 commit 0e17a7a

28 files changed

+2343
-910
lines changed

Algolia_Algoliasearch.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Algolia_Algoliasearch>
55
<active>true</active>
66
<codePool>community</codePool>
7-
<version>1.5.4</version>
7+
<version>1.5.5</version>
88
</Algolia_Algoliasearch>
99
</modules>
1010
</config>

CHANGELOG.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
## Change Log
22

3+
### 1.5.5
4+
5+
- NEW: Add an option to include data from out-of-stock sub products
6+
- NEW: Use secured api keys to only retrieve one group price in the frontend
7+
- NEW: Better update strategy to simplify the indexer code and to avoid missing deleted products event
8+
- UPDATE: Better handling of include in navigation config
9+
- UPDATE: underlying php client
10+
- UPDATE: Conditionally render template directives
11+
- UPDATE: Make sub product skus searchable
12+
- FIX: slaves creation issue
13+
- FIX: small price issue
14+
- FIX: fallback to default search in case there is a error from the api
15+
16+
317
### 1.5.4
418

519
- UPDATED: instantsearch.js update
@@ -58,7 +72,7 @@
5872

5973
### 1.4.8
6074
- NEW: allow to have custom product types
61-
- NEW: make image generation size parameter customizable to be able to save ressources when already in cache
75+
- NEW: make image generation size parameter customizable to be able to save resources when already in cache
6276
- UPDATED: remove root category when fetching product categories
6377
- UPDATED: rewrite image class to be able to log the error when not being able to generate it
6478
- UPDATED: Handle display price with AND without tax
@@ -198,6 +212,6 @@
198212
- Upgrade the underlying Algolia PHP API client to 1.5.5 (high available DNS)
199213

200214
### 1.0.3
201-
- Upgrade the underlying PHP API client to 1.5.4
215+
- Upgrade the underlying PHP API client to 1.5.5
202216
- Fix deadlock that may occur with order processing
203217
- Fix results saved every search (remove flag probably added for debugging).

code/Helper/Algoliahelper.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/ClientContext.php';
88
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Client.php';
99
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Index.php';
10+
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/PlacesIndex.php';
11+
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/IndexBrowser.php';
1012
}
1113

1214
class Algolia_Algoliasearch_Helper_Algoliahelper extends Mage_Core_Helper_Abstract
1315
{
16+
/** @var \AlgoliaSearch\Client */
1417
protected $client;
1518
protected $config;
1619

@@ -26,6 +29,11 @@ public function resetCredentialsFromConfig()
2629
$this->client = new \AlgoliaSearch\Client($this->config->getApplicationID(), $this->config->getAPIKey());
2730
}
2831

32+
public function generateSearchSecuredApiKey($key, $params = array())
33+
{
34+
return $this->client->generateSecuredApiKey($key, $params);
35+
}
36+
2937
public function getIndex($name)
3038
{
3139
return $this->client->initIndex($name);

code/Helper/Config.php

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
2828
const EXCLUDED_PAGES = 'algoliasearch/autocomplete/excluded_pages';
2929
const MIN_POPULARITY = 'algoliasearch/autocomplete/min_popularity';
3030
const MIN_NUMBER_OF_RESULTS = 'algoliasearch/autocomplete/min_number_of_results';
31+
const RENDER_TEMPLATE_DIRECTIVES = 'algoliasearch/autocomplete/render_template_directives';
3132

3233
const NUMBER_OF_PRODUCT_RESULTS = 'algoliasearch/products/number_product_results';
3334
const PRODUCT_ATTRIBUTES = 'algoliasearch/products/product_additional_attributes';
3435
const PRODUCT_CUSTOM_RANKING = 'algoliasearch/products/custom_ranking_product_attributes';
3536
const RESULTS_LIMIT = 'algoliasearch/products/results_limit';
3637
const SHOW_SUGGESTIONS_NO_RESULTS = 'algoliasearch/products/show_suggestions_on_no_result_page';
38+
const INDEX_OUT_OF_STOCK_OPTIONS = 'algoliasearch/products/index_out_of_stock_options';
3739

3840
const CATEGORY_ATTRIBUTES = 'algoliasearch/categories/category_additional_attributes2';
3941
const INDEX_PRODUCT_COUNT = 'algoliasearch/categories/index_product_count';
4042
const CATEGORY_CUSTOM_RANKING = 'algoliasearch/categories/custom_ranking_category_attributes';
43+
const SHOW_CATS_NOT_INCLUDED_IN_NAVIGATION = 'algoliasearch/categories/show_cats_not_included_in_navigation';
4144

4245

4346
const IS_ACTIVE = 'algoliasearch/queue/active';
@@ -60,6 +63,16 @@ class Algolia_Algoliasearch_Helper_Config extends Mage_Core_Helper_Abstract
6063

6164
protected $_productTypeMap = array();
6265

66+
public function indexOutOfStockOptions($storeId = null)
67+
{
68+
return Mage::getStoreConfigFlag(self::INDEX_OUT_OF_STOCK_OPTIONS, $storeId);
69+
}
70+
71+
public function showCatsNotIncludedInNavigation($storeId = null)
72+
{
73+
return Mage::getStoreConfigFlag(self::SHOW_CATS_NOT_INCLUDED_IN_NAVIGATION, $storeId);
74+
}
75+
6376
public function isDefaultSelector($storeId = null)
6477
{
6578
return '.algolia-search-input' === $this->getAutocompleteSelector($storeId);
@@ -259,6 +272,11 @@ public function getExcludedPages($storeId = NULL)
259272
return array();
260273
}
261274

275+
public function getRenderTemplateDirectives($storeId = NULL)
276+
{
277+
return Mage::getStoreConfigFlag(self::RENDER_TEMPLATE_DIRECTIVES, $storeId);
278+
}
279+
262280
public function getSortingIndices($storeId = NULL)
263281
{
264282
$product_helper = Mage::helper('algoliasearch/entity_producthelper');
@@ -297,22 +315,52 @@ public function getSortingIndices($storeId = NULL)
297315

298316
public function getApplicationID($storeId = NULL)
299317
{
300-
return Mage::getStoreConfig(self::APPLICATION_ID, $storeId);
318+
return trim(Mage::getStoreConfig(self::APPLICATION_ID, $storeId));
301319
}
302320

303321
public function getAPIKey($storeId = NULL)
304322
{
305-
return Mage::getStoreConfig(self::API_KEY, $storeId);
323+
return trim(Mage::getStoreConfig(self::API_KEY, $storeId));
306324
}
307325

308326
public function getSearchOnlyAPIKey($storeId = NULL)
309327
{
310-
return Mage::getStoreConfig(self::SEARCH_ONLY_API_KEY, $storeId);
328+
return trim(Mage::getStoreConfig(self::SEARCH_ONLY_API_KEY, $storeId));
311329
}
312330

313331
public function getIndexPrefix($storeId = NULL)
314332
{
315-
return Mage::getStoreConfig(self::INDEX_PREFIX, $storeId);
333+
return trim(Mage::getStoreConfig(self::INDEX_PREFIX, $storeId));
334+
}
335+
336+
public function getAttributesToRetrieve($group_id)
337+
{
338+
if (false === $this->isCustomerGroupsEnabled()) {
339+
return [];
340+
}
341+
342+
$attributes = array();
343+
foreach ($this->getProductAdditionalAttributes() as $attribute) {
344+
if ($attribute['attribute'] !== 'price') {
345+
$attributes[] = $attribute['attribute'];
346+
}
347+
}
348+
349+
$attributes = array_merge($attributes, ['objectID', 'name', 'url', 'visibility_search', 'visibility_catalog', 'categories', 'categories_without_path', 'thumbnail_url', 'image_url', 'in_stock', 'type_id']);
350+
351+
$currencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
352+
353+
foreach ($currencies as $currency) {
354+
$attributes[] = 'price.'.$currency.'.default';
355+
$attributes[] = 'price.'.$currency.'.default_formated';
356+
$attributes[] = 'price.'.$currency.'.group_'.$group_id;
357+
$attributes[] = 'price.'.$currency.'.group_'.$group_id.'_formated';
358+
$attributes[] = 'price.'.$currency.'.special_from_date';
359+
$attributes[] = 'price.'.$currency.'.special_to_date';
360+
}
361+
362+
363+
return ['attributesToRetrieve' => $attributes];
316364
}
317365

318366
public function getCategoryAdditionalAttributes($storeId = NULL)

code/Helper/Data.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/ClientContext.php';
88
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Client.php';
99
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/Index.php';
10+
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/PlacesIndex.php';
11+
require_once Mage::getBaseDir('lib').'/AlgoliaSearch/IndexBrowser.php';
1012
}
1113

1214
class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
@@ -25,7 +27,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
2527

2628
public function __construct()
2729
{
28-
\AlgoliaSearch\Version::$custom_value = " Magento (1.5.4)";
30+
\AlgoliaSearch\Version::$custom_value = " Magento (1.5.5)";
2931

3032
$this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
3133

code/Helper/Entity/Additionalsectionshelper.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ public function getAttributeValues($storeId, $section)
2121
$products = Mage::getResourceModel('catalog/product_collection')
2222
->addStoreFilter($storeId)
2323
->addAttributeToFilter('visibility', array('in' => Mage::getSingleton('catalog/product_visibility')->getVisibleInSearchIds()))
24+
->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED))
2425
->addAttributeToFilter($attributeCode, array('notnull' => true))
2526
->addAttributeToFilter($attributeCode, array('neq' => ''))
2627
->addAttributeToSelect($attributeCode);
2728

28-
$usedAttributeValues = array_unique($products->getColumnValues($attributeCode));
29+
$usedAttributeValues = array_keys(array_flip( // array unique
30+
explode(',', implode(',', $products->getColumnValues($attributeCode)))));
2931

3032
$attributeModel = Mage::getSingleton('eav/config')
3133
->getAttribute('catalog_product', $attributeCode)
@@ -45,7 +47,7 @@ public function getAttributeValues($storeId, $section)
4547
$values = array($values);
4648
}
4749

48-
$values = array_map(function ($value) use ($section) {
50+
$values = array_map(function ($value) use ($section, $storeId) {
4951

5052
$record = array(
5153
'objectID' => $value,
@@ -54,7 +56,8 @@ public function getAttributeValues($storeId, $section)
5456

5557
$transport = new Varien_Object($record);
5658

57-
Mage::dispatchEvent('algolia_additional_section_item_index_before', array('section' => $section, 'record' => $transport));
59+
Mage::dispatchEvent('algolia_additional_section_item_index_before',
60+
array('section' => $section, 'record' => $transport, 'store_id' => $storeId));
5861

5962
$record = $transport->getData();
6063

@@ -63,4 +66,4 @@ public function getAttributeValues($storeId, $section)
6366

6467
return $values;
6568
}
66-
}
69+
}

code/Helper/Entity/Categoryhelper.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ public function getCategoryCollectionQuery($storeId, $categoryIds = null)
6666
foreach ($unserializedCategorysAttrs as $attr)
6767
$additionalAttr[] = $attr['attribute'];
6868

69+
$additionalAttr[] = 'include_in_menu';
70+
6971
$categories
7072
->addPathFilter($storeRootCategoryPath)
7173
->addNameToResult()
7274
->addUrlRewriteToResult()
7375
->addIsActiveFilter()
7476
->setStoreId($storeId)
75-
->addAttributeToFilter('include_in_menu', '1')
7677
->addAttributeToSelect(array_merge(array('name'), $additionalAttr))
7778
->addFieldToFilter('level', array('gt' => 1));
7879

@@ -140,14 +141,15 @@ public function getObject(Mage_Catalog_Model_Category $category)
140141
} catch (Exception $e) { /* no image, no default: not fatal */
141142
}
142143
$data = array(
143-
'objectID' => $category->getId(),
144-
'name' => $category->getName(),
145-
'path' => $path,
146-
'level' => $category->getLevel(),
147-
'url' => $category->getUrl(),
148-
'_tags' => array('category'),
149-
'popularity' => 1,
150-
'product_count' => $category->getProductCount()
144+
'objectID' => $category->getId(),
145+
'name' => $category->getName(),
146+
'path' => $path,
147+
'level' => $category->getLevel(),
148+
'url' => $category->getUrl(),
149+
'include_in_menu' => $category->getIncludeInMenu(),
150+
'_tags' => array('category'),
151+
'popularity' => 1,
152+
'product_count' => $category->getProductCount()
151153
);
152154

153155
if ( ! empty($image_url)) {
@@ -158,11 +160,11 @@ public function getObject(Mage_Catalog_Model_Category $category)
158160
{
159161
$value = $category->getData($attribute['attribute']);
160162

161-
$attribute_ressource = $category->getResource()->getAttribute($attribute['attribute']);
163+
$attribute_resource = $category->getResource()->getAttribute($attribute['attribute']);
162164

163-
if ($attribute_ressource)
165+
if ($attribute_resource)
164166
{
165-
$value = $attribute_ressource->getFrontend()->getValue($category);
167+
$value = $attribute_resource->getFrontend()->getValue($category);
166168
}
167169

168170
if (isset($data[$attribute['attribute']]))

code/Helper/Entity/Helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ protected function strip($s)
7070
$s = trim(preg_replace('/\s+/', ' ', $s));
7171
$s = preg_replace('/&nbsp;/', ' ', $s);
7272
$s = preg_replace('!\s+!', ' ', $s);
73+
$s = preg_replace('/\{\{[^}]+\}\}/', ' ', $s);
7374

7475
return trim(strip_tags($s));
7576
}
@@ -231,4 +232,4 @@ public static function getStores($store_id)
231232
return $store_ids;
232233
}
233234

234-
}
235+
}

code/Helper/Entity/Pagehelper.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@ public function getPages($storeId)
4545
if (! $page->getId())
4646
continue;
4747

48-
$page_obj['objectID'] = $page->getId();
48+
$content = $page->getContent();
49+
if ($this->config->getRenderTemplateDirectives()) {
50+
$tmplProc = Mage::helper('cms')->getPageTemplateProcessor();
51+
$content = $tmplProc->filter($content);
52+
}
4953

54+
$page_obj['objectID'] = $page->getId();
5055
$page_obj['url'] = Mage::helper('cms/page')->getPageUrl($page->getId());
51-
$page_obj['content'] = $this->strip($page->getContent());
56+
$page_obj['content'] = $this->strip($content);
5257

5358
$pages[] = $page_obj;
5459
}
5560

5661
return $pages;
5762
}
58-
}
63+
}

0 commit comments

Comments
 (0)