Skip to content

Commit

Permalink
Merge pull request #1127 from algolia/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jan Petr committed Apr 15, 2019
2 parents 9357b9e + b12c38f commit 443f861
Show file tree
Hide file tree
Showing 46 changed files with 586 additions and 2,961 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# CHANGE LOG

## 1.16.0

### Updates
- Update max PHP dependency (#1090)
- Update Reindex SKU for improved messaging (#1098)
- Added ProxyHelper to assist with plan upsell (#1109)
- Update autocomplete version in algoliaBundle.js (#1121)
- Improvements to Indexing and Indexing Queue
- Skip inactive stores (#1101)
- Add distinct to category collection fetch (#1104)
- Fail "Remove Algolia products" silently on non-existent index (#1111)
- Fetch max_record_size and add retry on stuck PIDs for indexing queue (#1117)

### Fixes
- Fix directory casing 404s (#1095)
- Add table prefixes when calling core/resource instances (#1097)
- Fix price_with_tax for customer groups (#1100)
- Fix autocomplete frontend hook (#1102)
- Fix jobs locking (#1118)
- Fix Dockerfile (#1120)
- Fix sticky autocomplete input value after clear toggle (#1122)

## 1.15.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Algolia Search for Magento 1.6+
==================

![Latest version](https://img.shields.io/badge/latest-1.15.0-green.svg)
![Latest version](https://img.shields.io/badge/latest-1.16.0-green.svg)

[![Build Status](https://travis-ci.org/algolia/algoliasearch-magento.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-magento)
![PHP >= 5.3](https://img.shields.io/badge/php-%3E=5.3-green.svg)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue extends Mage_Adminhtml_Block_Widget_Grid_Container
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue extends Mage_Adminhtml_Block_Widget_Grid_Container
{
/**
* Initialize Grid Container
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
/**
* Internal constructor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
/**
* @return Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit_Form
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Grid extends Mage_Adminhtml_Block_Widget_Grid
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
/**
* Initialize Grid Properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Grid_Renderer_Json extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue_Grid_Renderer_Json extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
/**
* @param Varien_Object $row
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Status extends Mage_Adminhtml_Block_Template
class Algolia_Algoliasearch_Block_Adminhtml_Indexingqueue_Status extends Mage_Adminhtml_Block_Template
{
const CRON_QUEUE_FREQUENCY = 330;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_ReindexSku_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
class Algolia_Algoliasearch_Block_Adminhtml_Reindexsku_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
{
/**
* Internal constructor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class Algolia_Algoliasearch_Block_Adminhtml_ReindexSku_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
class Algolia_Algoliasearch_Block_Adminhtml_Reindexsku_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
{
/**
* @return Algolia_AlgoliaSearch_Block_Adminhtml_ReindexSku_Edit_Form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ protected function getRenderer($columnId, array $columnSettings)
$selectField->setOptions($options);
$selectField->setExtraParams('style="width:'.$width.'px;"');

if (isset($columnSettings['disabled']) && $columnSettings['disabled'] != 0) {
$extra = $selectField->getExtraParams();
$extra .= ' disabled';
$selectField->setExtraParams($extra);
}

$this->selectFields[$columnId] = $selectField;

return $this->selectFields[$columnId];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

class Algolia_Algoliasearch_Block_System_Config_Form_Field_ClickAnalytics extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected $_showUpsell = false;

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
if (!$this->isClickAnalyticsEnabled($element)) {
$element->setDisabled(true);
$this->_showUpsell = true;
}

return parent::_getElementHtml($element);
}

/**
* @return bool
*/
public function isClickAnalyticsEnabled()
{
$proxyHelper = Mage::helper('algoliasearch/proxyHelper');
$info = $proxyHelper->getClientConfigurationData();

return isset($info['click_analytics']) && $info['click_analytics'] == 1;
}

protected function _decorateRowHtml($element, $html)
{
if (!$this->_showUpsell) {
return parent::_decorateRowHtml($element, $html);
}

$additionalRow = '<tr class="algoliasearch-messages"><td colspan="3"><div class="algoliasearch-config-info icon-stars">';
$additionalRow .= $this->__('To get access to this Algolia feature, please consider <a href="%s" target="_blank">upgrading to a higher plan.</a>',
'https://www.algolia.com/pricing/');
$additionalRow .= '</div></td></tr>';

return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>' . $additionalRow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
class Algolia_Algoliasearch_Block_System_Config_Form_Field_Facets extends Algolia_Algoliasearch_Block_System_Config_Form_Field_AbstractField
{
protected $_isQueryRulesDisabled;

public function __construct()
{
$this->settings = array(
Expand Down Expand Up @@ -52,10 +54,11 @@ public function __construct()
'create_rule' => array(
'label' => 'Create Query rule?',
'options' => array(
'1' => 'Yes',
'2' => 'No'
'2' => 'No',
'1' => 'Yes'
),
'rowMethod' => 'getCreateRule',
'disabled' => $this->isQueryRulesDisabled()
),
),
'buttonLabel' => 'Add Facet',
Expand All @@ -64,4 +67,41 @@ public function __construct()

parent::__construct();
}

/**
* @return bool
*/
public function isQueryRulesDisabled()
{
if (is_null($this->_isQueryRulesDisabled)) {
$this->_isQueryRulesDisabled = $this->_disableQueryRules();
}

return $this->_isQueryRulesDisabled;
}

/**
* @return bool
*/
protected function _disableQueryRules()
{
$proxyHelper = Mage::helper('algoliasearch/proxyHelper');
$info = $proxyHelper->getClientConfigurationData();

return !isset($info['query_rules']) || $info['query_rules'] == 0;
}

protected function _decorateRowHtml($element, $html)
{
if (!$this->isQueryRulesDisabled()) {
return parent::_decorateRowHtml($element, $html);
}

$additionalRow = '<tr class="algoliasearch-messages"><td></td><td><div class="algoliasearch-config-info icon-stars">';
$additionalRow .= $this->__('To get access to this Algolia feature, please consider <a href="%s" target="_blank">upgrading to a higher plan.</a>',
'https://www.algolia.com/pricing/');
$additionalRow .= '</div></td></tr>';

return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>' . $additionalRow;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

class Algolia_Algoliasearch_Block_System_Config_Form_Field_Logo extends Mage_Adminhtml_Block_System_Config_Form_Field
{
protected $_showUpsell = false;

protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
if ($this->showLogo($element)) {
$element->setDisabled(true);
$element->setValue(0);
$this->_showUpsell = true;
}

return parent::_getElementHtml($element);
}

/**
* @return bool
*/
public function showLogo()
{
$proxyHelper = Mage::helper('algoliasearch/proxyHelper');
$info = $proxyHelper->getClientConfigurationData();

return isset($info['require_logo']) && $info['require_logo'] == 1;
}

protected function _decorateRowHtml($element, $html)
{
if (!$this->_showUpsell) {
return parent::_decorateRowHtml($element, $html);
}

$additionalRow = '<tr class="algoliasearch-messages"><td></td><td colspan="3"><div class="algoliasearch-config-info icon-stars">';
$additionalRow .= $this->__('To be able to remove the Algolia logo, please consider <a href="%s" target="_blank">upgrading to a higher plan.</a>',
'https://www.algolia.com/pricing/');
$additionalRow .= '</div></td></tr>';

return '<tr id="row_' . $element->getHtmlId() . '">' . $html . '</tr>' . $additionalRow;
}
}
18 changes: 14 additions & 4 deletions app/code/community/Algolia/Algoliasearch/Helper/Algoliahelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Algolia_Algoliasearch_Helper_Algoliahelper extends Mage_Core_Helper_Abstra
protected $config;

/** @var int */
protected $maxRecordSize = 20000;
protected $maxRecordSize;

/** @var array */
protected $potentiallyLongAttributes = array('description', 'short_description', 'meta_description', 'content');
Expand Down Expand Up @@ -236,7 +236,7 @@ public function copySynonyms($fromIndexName, $toIndexName)
$this->lastUsedIndexName = $toIndex;
$this->lastTaskId = $res['taskID'];
}

/**
* @param $fromIndexName
* @param $toIndexName
Expand Down Expand Up @@ -332,11 +332,21 @@ private function prepareRecords(&$objects, $indexName)
}
}

private function getMaxRecordSize()
{
if (!$this->maxRecordSize) {
$this->maxRecordSize = $this->config->getMaxRecordSizeLimit()
? $this->config->getMaxRecordSizeLimit() : $this->config->getDefaultMaxRecordSize();
}

return $this->maxRecordSize;
}

public function handleTooBigRecord($object)
{
$size = mb_strlen(json_encode($object));

if ($size > $this->maxRecordSize) {
if ($size > $this->getMaxRecordSize()) {
foreach ($this->potentiallyLongAttributes as $attribute) {
if (isset($object[$attribute])) {
unset($object[$attribute]);
Expand All @@ -345,7 +355,7 @@ public function handleTooBigRecord($object)

$size = mb_strlen(json_encode($object));

if ($size > $this->maxRecordSize) {
if ($size > $this->getMaxRecordSize()) {
$object = false;
}
}
Expand Down
Loading

0 comments on commit 443f861

Please sign in to comment.