Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mazhalai committed Mar 6, 2015
2 parents d883ef5 + cdc3d60 commit 1606d94
Show file tree
Hide file tree
Showing 67 changed files with 1,875 additions and 898 deletions.
9 changes: 5 additions & 4 deletions app/code/Magento/Catalog/Model/Layer/Filter/Price/Range.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Range
private $scopeConfig;

/**
* @var \Magento\Catalog\Model\Layer
* @var Resolver
*/
private $layer;
private $layerResolver;

/**
* @param Registry $registry
Expand All @@ -39,15 +39,16 @@ public function __construct(Registry $registry, ScopeConfigInterface $scopeConfi
{
$this->registry = $registry;
$this->scopeConfig = $scopeConfig;
$this->layer = $layerResolver->get();
$this->layerResolver = $layerResolver;
}

/**
* @return array
*/
public function getPriceRange()
{
$currentCategory = $this->registry->registry('current_category_filter') ?: $this->layer->getCurrentCategory();
$currentCategory = $this->registry->registry('current_category_filter')
?: $this->layerResolver->get()->getCurrentCategory();

return $currentCategory->getFilterPriceRange();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,19 @@

use Magento\Catalog\Model\Layer\Filter\Price\Range;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Resource;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface as MysqlDataProviderInterface;
use Magento\Framework\Search\Dynamic\DataProviderInterface;
use Magento\Framework\Search\Dynamic\IntervalFactory;
use Magento\Framework\Search\Request\BucketInterface;
use Magento\Store\Model\ScopeInterface;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class DataProvider implements DataProviderInterface
{
const XML_PATH_INTERVAL_DIVISION_LIMIT = 'catalog/layered_navigation/interval_division_limit';
const XML_PATH_RANGE_STEP = 'catalog/layered_navigation/price_range_step';
const XML_PATH_RANGE_MAX_INTERVALS = 'catalog/layered_navigation/price_range_max_intervals';

/**
* @var Resource
*/
Expand All @@ -36,11 +30,6 @@ class DataProvider implements DataProviderInterface
*/
private $range;

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var Session
*/
Expand All @@ -58,23 +47,20 @@ class DataProvider implements DataProviderInterface

/**
* @param Resource $resource
* @param ScopeConfigInterface $scopeConfig
* @param Range $range
* @param Session $customerSession
* @param MysqlDataProviderInterface $dataProvider
* @param IntervalFactory $intervalFactory
*/
public function __construct(
Resource $resource,
ScopeConfigInterface $scopeConfig,
Range $range,
Session $customerSession,
MysqlDataProviderInterface $dataProvider,
IntervalFactory $intervalFactory
) {
$this->resource = $resource;
$this->range = $range;
$this->scopeConfig = $scopeConfig;
$this->customerSession = $customerSession;
$this->dataProvider = $dataProvider;
$this->intervalFactory = $intervalFactory;
Expand All @@ -97,7 +83,7 @@ public function getAggregations(array $entityIds)
'count' => 'count(DISTINCT entity_id)',
'max' => 'MAX(min_price)',
'min' => 'MIN(min_price)',
'std' => 'STDDEV_SAMP(min_price)',
'std' => 'STDDEV_SAMP(min_price)'
];

$select = $this->getSelect();
Expand All @@ -115,28 +101,6 @@ public function getAggregations(array $entityIds)
return $result;
}

/**
* {@inheritdoc}
*/
public function getOptions()
{
return [
'interval_division_limit' => (int)$this->scopeConfig->getValue(
self::XML_PATH_INTERVAL_DIVISION_LIMIT,
ScopeInterface::SCOPE_STORE
),
'range_step' => (double)$this->scopeConfig->getValue(
self::XML_PATH_RANGE_STEP,
ScopeInterface::SCOPE_STORE
),
'min_range_power' => 10,
'max_intervals_number' => (int)$this->scopeConfig->getValue(
self::XML_PATH_RANGE_MAX_INTERVALS,
ScopeInterface::SCOPE_STORE
)
];
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -190,7 +154,7 @@ public function prepareData($range, array $dbRanges)
$data[] = [
'from' => $fromPrice,
'to' => $toPrice,
'count' => $count,
'count' => $count
];
}
}
Expand Down
52 changes: 52 additions & 0 deletions app/code/Magento/CatalogSearch/Model/Adapter/Options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CatalogSearch\Model\Adapter;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Search\Adapter\OptionsInterface;
use Magento\Store\Model\ScopeInterface;

class Options implements OptionsInterface
{
const XML_PATH_INTERVAL_DIVISION_LIMIT = 'catalog/layered_navigation/interval_division_limit';
const XML_PATH_RANGE_STEP = 'catalog/layered_navigation/price_range_step';
const XML_PATH_RANGE_MAX_INTERVALS = 'catalog/layered_navigation/price_range_max_intervals';

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}

/**
* {@inheritdoc}
*/
public function get()
{
return [
'interval_division_limit' => (int)$this->scopeConfig->getValue(
self::XML_PATH_INTERVAL_DIVISION_LIMIT,
ScopeInterface::SCOPE_STORE
),
'range_step' => (double)$this->scopeConfig->getValue(
self::XML_PATH_RANGE_STEP,
ScopeInterface::SCOPE_STORE
),
'min_range_power' => 10,
'max_intervals_number' => (int)$this->scopeConfig->getValue(
self::XML_PATH_RANGE_MAX_INTERVALS,
ScopeInterface::SCOPE_STORE
)
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CatalogSearch\Model\Adminhtml\System\Config\Backend;

/**
* @author Magento Core Team <core@magentocommerce.com>
*/
class Engine extends \Magento\Framework\App\Config\Value
{
/** @var \Magento\Indexer\Model\IndexerRegistry */
protected $indexerRegistry;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Indexer\Model\IndexerRegistry $indexerRegistry
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
* @param array $data
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Indexer\Model\IndexerRegistry $indexerRegistry,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\Db $resourceCollection = null,
array $data = []
) {
$this->indexerRegistry = $indexerRegistry;
parent::__construct($context, $registry, $config, $resource, $resourceCollection, $data);
}

/**
* After save call
* Invalidate catalog search index if engine was changed
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();

if ($this->isValueChanged()) {
$this->indexerRegistry->get(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)->invalidate();
}
return $this;
}
}
Loading

0 comments on commit 1606d94

Please sign in to comment.