Skip to content

Commit

Permalink
Merge pull request #49 from algolia/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jan Petr authored Aug 12, 2016
2 parents cc4edf0 + b3b4303 commit 69fb66b
Show file tree
Hide file tree
Showing 37 changed files with 216 additions and 200 deletions.
35 changes: 26 additions & 9 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,29 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
->in($directories);

return Symfony\CS\Config\Config::create()
->setUsingCache(true)
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
->fixers([
'align_double_arrow',
'short_array_syntax',
'-multiline_array_trailing_comma',
'-pre_increment',
'-phpdoc_short_description',
])->finder($finder);
->finder($finder)
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers([
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'extra_empty_lines',
'include',
'join_function',
'multiline_array_trailing_comma',
'namespace_no_leading_whitespace',
'new_with_braces',
'object_operator',
'operators_spaces',
'remove_leading_slash_use',
'remove_lines_between_uses',
'single_array_no_trailing_comma',
'spaces_before_semicolon',
'standardize_not_equal',
'ternary_spaces',
'unused_use',
'whitespacy_lines',
'concat_with_spaces',
'multiline_spaces_before_semicolon',
'ordered_use',
'short_array_syntax',
]);
8 changes: 4 additions & 4 deletions Adapter/Algolia.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
namespace Algolia\AlgoliaSearch\Adapter;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Magento\Framework\Search\Adapter\Mysql\DocumentFactory;
use Algolia\AlgoliaSearch\Helper\Data as AlgoliaHelper;
use Magento\CatalogSearch\Helper\Data;
use Magento\Framework\App\Request\Http;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Search\Adapter\Mysql\Aggregation\Builder as AggregationBuilder;
use Magento\Framework\Search\Adapter\Mysql\DocumentFactory;
use Magento\Framework\Search\Adapter\Mysql\Mapper;
use Magento\Framework\Search\Adapter\Mysql\ResponseFactory;
use Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory;
use Magento\Framework\Search\AdapterInterface;
use Magento\Framework\Search\RequestInterface;
use Magento\CatalogSearch\Helper\Data;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Request\Http;
use Algolia\AlgoliaSearch\Helper\Data as AlgoliaHelper;

/**
* MySQL Search Adapter
Expand Down
2 changes: 1 addition & 1 deletion Block/Algolia.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getPriceKey()
if ($this->priceKey === null) {
$groupId = $this->customerSession->getCustomer()->getGroupId();
$currencyCode = $this->getCurrencyCode();
$this->priceKey = $this->config->isCustomerGroupsEnabled($this->_storeManager->getStore()->getStoreId()) ? '.'.$currencyCode.'.group_'.$groupId : '.'.$currencyCode.'.default';
$this->priceKey = $this->config->isCustomerGroupsEnabled($this->_storeManager->getStore()->getStoreId()) ? '.' . $currencyCode . '.group_' . $groupId : '.' . $currencyCode . '.default';
}

return $this->priceKey;
Expand Down
4 changes: 2 additions & 2 deletions Block/Instant/Hit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Algolia\AlgoliaSearch\Block\Instant;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Magento\Customer\Model\Session;
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\View\Element\Template;
use Magento\Customer\Model\Session;

class Hit extends Template
{
Expand All @@ -32,7 +32,7 @@ public function getPriceKey()
if ($this->priceKey === null) {
$groupId = $this->customerSession->getCustomer()->getGroupId();
$currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode();
$this->priceKey = $this->config->isCustomerGroupsEnabled($this->_storeManager->getStore()->getStoreId()) ? '.'.$currencyCode.'.group_'.$groupId : '.'.$currencyCode.'.default';
$this->priceKey = $this->config->isCustomerGroupsEnabled($this->_storeManager->getStore()->getStoreId()) ? '.' . $currencyCode . '.group_' . $groupId : '.' . $currencyCode . '.default';
}

return $this->priceKey;
Expand Down
2 changes: 1 addition & 1 deletion Block/TopSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Algolia\AlgoliaSearch\Block;

use Algolia\AlgoliaSearch\Helper\ConfigHelper;
use Magento\Search\Helper\Data as CatalogSearchHelper;
use Magento\Framework\Data\CollectionDataSourceInterface;
use Magento\Framework\View\Element\Template;
use Magento\Search\Helper\Data as CatalogSearchHelper;

class TopSearch extends Template implements CollectionDataSourceInterface
{
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 0.8.4

- Always index categories' attribute `include_in_menu`
- Follow Magento 2 coding styles

## 0.8.3

- Add license information to `composer.json`
Expand Down
13 changes: 5 additions & 8 deletions Helper/AlgoliaHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function handleTooBigRecords(&$objects, $index_name)
foreach ($long_attributes as $attribute) {
if (isset($object[$attribute])) {
unset($object[$attribute]);
$ids[$index_name.' objectID('.$object['objectID'].')'] = true;
$ids[$index_name . ' objectID(' . $object['objectID'] . ')'] = true;
$good_size = false;
}
}
Expand All @@ -139,7 +139,7 @@ public function handleTooBigRecords(&$objects, $index_name)
}

if ($good_size === false) {
$this->messageManager->addError('Algolia reindexing : You have some records ('.implode(',', array_keys($ids)).') that are too big. They have either been truncated or skipped');
$this->messageManager->addError('Algolia reindexing : You have some records (' . implode(',', array_keys($ids)) . ') that are too big. They have either been truncated or skipped');
}
}

Expand Down Expand Up @@ -187,17 +187,14 @@ public function setSynonyms($indexName, $synonyms)

private function checkClient($methodName)
{
if (isset($this->client))
{
if (isset($this->client)) {
return;
}

$this->resetCredentialsFromConfig();


if (!isset($this->client))
{
throw new AlgoliaException('Operation "'.$methodName.' could not be performed because Algolia credetials were not provided.');
if (!isset($this->client)) {
throw new AlgoliaException('Operation "' . $methodName . ' could not be performed because Algolia credetials were not provided.');
}
}
}
26 changes: 13 additions & 13 deletions Helper/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Algolia\AlgoliaSearch\Helper;

use Magento;
use Magento\Directory\Model\Currency as DirCurrency;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Locale\Currency;
use Magento\Directory\Model\Currency as DirCurrency;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;

Expand Down Expand Up @@ -348,17 +348,17 @@ public function getSortingIndices($storeId = null)
foreach ($attrs as &$attr) {
if ($this->isCustomerGroupsEnabled($storeId)) {
if (strpos($attr['attribute'], 'price') !== false) {
$suffix_index_name = 'group_'.$group_id;
$suffix_index_name = 'group_' . $group_id;

$attr['name'] = $productHelper->getIndexName($storeId).'_'.$attr['attribute'].'_'.$suffix_index_name.'_'.$attr['sort'];
$attr['name'] = $productHelper->getIndexName($storeId) . '_' . $attr['attribute'] . '_' . $suffix_index_name . '_' . $attr['sort'];
} else {
$attr['name'] = $productHelper->getIndexName($storeId).'_'.$attr['attribute'].'_'.$attr['sort'];
$attr['name'] = $productHelper->getIndexName($storeId) . '_' . $attr['attribute'] . '_' . $attr['sort'];
}
} else {
if (strpos($attr['attribute'], 'price') !== false) {
$attr['name'] = $productHelper->getIndexName($storeId).'_'.$attr['attribute'].'_'.'default'.'_'.$attr['sort'];
$attr['name'] = $productHelper->getIndexName($storeId) . '_' . $attr['attribute'] . '_' . 'default' . '_' . $attr['sort'];
} else {
$attr['name'] = $productHelper->getIndexName($storeId).'_'.$attr['attribute'].'_'.$attr['sort'];
$attr['name'] = $productHelper->getIndexName($storeId) . '_' . $attr['attribute'] . '_' . $attr['sort'];
}
}
}
Expand Down Expand Up @@ -501,12 +501,12 @@ public function getAttributesToRetrieve($group_id)
$currencies = $this->dirCurrency->getConfigAllowCurrencies();

foreach ($currencies as $currency) {
$attributes[] = 'price.'.$currency.'.default';
$attributes[] = 'price.'.$currency.'.default_formated';
$attributes[] = 'price.'.$currency.'.group_'.$group_id;
$attributes[] = 'price.'.$currency.'.group_'.$group_id.'_formated';
$attributes[] = 'price.'.$currency.'.special_from_date';
$attributes[] = 'price.'.$currency.'.special_to_date';
$attributes[] = 'price.' . $currency . '.default';
$attributes[] = 'price.' . $currency . '.default_formated';
$attributes[] = 'price.' . $currency . '.group_' . $group_id;
$attributes[] = 'price.' . $currency . '.group_' . $group_id . '_formated';
$attributes[] = 'price.' . $currency . '.special_from_date';
$attributes[] = 'price.' . $currency . '.special_to_date';
}

return ['attributesToRetrieve' => $attributes];
Expand Down Expand Up @@ -544,6 +544,6 @@ public function getSynonymsFile($storeId = null)

$baseDirectory = $this->directoryList->getPath(DirectoryList::MEDIA);

return $baseDirectory.'/algoliasearch_admin_config_uploads/'.$filename;
return $baseDirectory . '/algoliasearch_admin_config_uploads/' . $filename;
}
}
Loading

0 comments on commit 69fb66b

Please sign in to comment.