Skip to content

Commit

Permalink
Merge pull request #535 from magento-dragons/S73
Browse files Browse the repository at this point in the history
[DRAGONS] S73
  • Loading branch information
vpelipenko committed Aug 25, 2015
2 parents f5330fb + ef7986c commit 411f78d
Show file tree
Hide file tree
Showing 33 changed files with 1,070 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
*/
namespace Magento\Bundle\Api;

/**
* Option manager for bundle products
*
* @api
*/
interface ProductOptionManagementInterface
{
/**
Expand Down
13 changes: 1 addition & 12 deletions app/code/Magento/CatalogSearch/Controller/Advanced/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

class Result extends \Magento\Framework\App\Action\Action
{
/**
* Catalog Layer Resolver
*
* @var Resolver
*/
private $layerResolver;

/**
* Url factory
*
Expand All @@ -40,18 +33,15 @@ class Result extends \Magento\Framework\App\Action\Action
* @param Context $context
* @param ModelAdvanced $catalogSearchAdvanced
* @param UrlFactory $urlFactory
* @param Resolver $layerResolver
*/
public function __construct(
Context $context,
ModelAdvanced $catalogSearchAdvanced,
UrlFactory $urlFactory,
Resolver $layerResolver
UrlFactory $urlFactory
) {
parent::__construct($context);
$this->_catalogSearchAdvanced = $catalogSearchAdvanced;
$this->_urlFactory = $urlFactory;
$this->layerResolver = $layerResolver;
}

/**
Expand All @@ -60,7 +50,6 @@ public function __construct(
public function execute()
{
try {
$this->layerResolver->create('advanced');
$this->_catalogSearchAdvanced->addFilters($this->getRequest()->getQueryValue());
$this->_view->loadLayout();
$this->_view->renderLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\CatalogSearch\Model\Adapter\Mysql\Filter;

use Magento\CatalogSearch\Model\Search\TableMapper;
use Magento\Eav\Model\Config;
use Magento\Framework\App\Resource;
use Magento\Framework\App\ScopeResolverInterface;
Expand All @@ -14,6 +15,9 @@
use Magento\Framework\Search\Adapter\Mysql\Query\QueryContainer;
use Magento\Framework\Search\Request\FilterInterface;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Preprocessor implements PreprocessorInterface
{
/**
Expand Down Expand Up @@ -46,18 +50,25 @@ class Preprocessor implements PreprocessorInterface
*/
private $connection;

/**
* @var TableMapper
*/
private $tableMapper;

/**
* @param ConditionManager $conditionManager
* @param ScopeResolverInterface $scopeResolver
* @param Config $config
* @param Resource $resource
* @param Resource|Resource $resource
* @param TableMapper $tableMapper
* @param string $attributePrefix
*/
public function __construct(
ConditionManager $conditionManager,
ScopeResolverInterface $scopeResolver,
Config $config,
Resource $resource,
TableMapper $tableMapper,
$attributePrefix
) {
$this->conditionManager = $conditionManager;
Expand All @@ -66,6 +77,7 @@ public function __construct(
$this->resource = $resource;
$this->connection = $resource->getConnection();
$this->attributePrefix = $attributePrefix;
$this->tableMapper = $tableMapper;
}

/**
Expand All @@ -86,57 +98,63 @@ public function process(FilterInterface $filter, $isNegation, $query, QueryConta
private function processQueryWithField(FilterInterface $filter, $isNegation, $query, QueryContainer $queryContainer)
{
$currentStoreId = $this->scopeResolver->getScope()->getId();

$select = null;
/** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
$attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField());
$select = $this->connection->select();
$table = $attribute->getBackendTable();
if ($filter->getField() == 'price') {
$query = str_replace('price', 'min_price', $query);
$select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')
->where($query);
} elseif ($filter->getField() == 'category_ids') {
return 'category_index.category_id = ' . $filter->getValue();
} else {
if ($attribute->isStatic()) {
$select->from(['main_table' => $table], 'entity_id')
->where($query);
if ($filter->getField() === 'price') {
$filterQuery = str_replace(
$this->connection->quoteIdentifier('price'),
$this->connection->quoteIdentifier('price_index.min_price'),
$query
);
return $filterQuery;
} elseif ($filter->getField() === 'category_ids') {
return 'category_ids_index.category_id = ' . $filter->getValue();
} elseif ($attribute->isStatic()) {
$alias = $this->tableMapper->getMappingAlias($filter);
$filterQuery = str_replace(
$this->connection->quoteIdentifier($attribute->getAttributeCode()),
$this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()),
$query
);
return $filterQuery;
} elseif ($filter->getType() === FilterInterface::TYPE_TERM) {
if (is_array($filter->getValue())) {
$value = sprintf(
'%s IN (%s)',
($isNegation ? 'NOT' : ''),
implode(',', $filter->getValue())
);
} else {
if ($filter->getType() == FilterInterface::TYPE_TERM) {
if (is_array($filter->getValue())) {
$value = sprintf(
'%s IN (%s)',
($isNegation ? 'NOT' : ''),
implode(',', $filter->getValue())
);
} else {
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
}
$filterQuery = sprintf(
'cpie.store_id = %d AND cpie.attribute_id = %d AND cpie.value %s',
$this->scopeResolver->getScope()->getId(),
$attribute->getId(),
$value
);
$queryContainer->addFilter($filterQuery);
return '';
}
$ifNullCondition = $this->connection->getIfNullSql('current_store.value', 'main_table.value');

$select->from(['main_table' => $table], 'entity_id')
->joinLeft(
['current_store' => $table],
'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = '
. $currentStoreId,
null
)
->columns([$filter->getField() => $ifNullCondition])
->where(
'main_table.attribute_id = ?',
$attribute->getAttributeId()
)
->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
->having($query);
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
}
$filterQuery = sprintf(
'cpie.store_id = %d AND cpie.attribute_id = %d AND cpie.value %s',
$this->scopeResolver->getScope()->getId(),
$attribute->getId(),
$value
);
$queryContainer->addFilter($filterQuery);
return '';
} else {
$select = $this->connection->select();
$ifNullCondition = $this->connection->getIfNullSql('current_store.value', 'main_table.value');

$select->from(['main_table' => $table], 'entity_id')
->joinLeft(
['current_store' => $table],
'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = '
. $currentStoreId,
null
)
->columns([$filter->getField() => $ifNullCondition])
->where(
'main_table.attribute_id = ?',
$attribute->getAttributeId()
)
->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
->having($query);
}

return 'search_index.entity_id IN (
Expand Down
47 changes: 0 additions & 47 deletions app/code/Magento/CatalogSearch/Model/Layer/Advanced.php

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions app/code/Magento/CatalogSearch/Model/Layer/Advanced/Context.php

This file was deleted.

This file was deleted.

Loading

0 comments on commit 411f78d

Please sign in to comment.