Skip to content

Commit

Permalink
Merge branch 'develop' into MAGETWO-54677
Browse files Browse the repository at this point in the history
  • Loading branch information
Olexandr Lysenko committed Aug 22, 2016
2 parents 65abe1d + ea342f1 commit 6e305b4
Show file tree
Hide file tree
Showing 274 changed files with 9,524 additions and 2,613 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Backend/Model/View/Result/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Backend\Model\UrlInterface;
use Magento\Framework\App;
use Magento\Framework\App\ActionFlag;
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;

class Redirect extends \Magento\Framework\Controller\Result\Redirect
{
Expand Down Expand Up @@ -56,7 +57,7 @@ public function setRefererOrBaseUrl()
/**
* {@inheritdoc}
*/
protected function render(App\ResponseInterface $response)
protected function render(HttpResponseInterface $response)
{
$this->session->setIsUrlNotice($this->actionFlag->get('', AbstractAction::FLAG_IS_URLS_CHECKED));
return parent::render($response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<item name="fit" xsi:type="boolean">false</item>
<item name="label" xsi:type="string">Search String</item>
<item name="showFallbackReset" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
Expand All @@ -82,6 +85,9 @@
<item name="fit" xsi:type="boolean">false</item>
<item name="label" xsi:type="string">Theme Name</item>
<item name="showFallbackReset" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
title: $parent.deleteButtonLabel
}
">
<span data-bind="text: $parent.deleteButtonLabel"></span>
<span translate="$parent.deleteButtonLabel"></span>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="action-secondary"
type="button"
click="processingAddChild.bind($data, false, false, false)">
<span text="addButtonLabel"/>
<span translate="addButtonLabel"/>
</button>
</div>

Expand All @@ -30,7 +30,7 @@
css="element.setClasses(element)"
attr="'data-index': index">
<label if="element.label" class="admin__field-label" attr="for: element.uid">
<span text="element.label"/>
<span translate="element.label"/>
</label>

<div class="admin__field-control" data-role="grid-wrapper">
Expand All @@ -51,7 +51,7 @@

<th repeat="foreach: labels, item: '$label'"
class="data-grid-th"
text="$label().label"
translate="$label().label"
visible="$label().visible"
disable="$label().disabled"
css="setClasses($label())">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,25 @@ private function isExpiredAuthorization(OrderPaymentInterface $payment)
*/
private function isExistsCaptureTransaction(OrderPaymentInterface $payment)
{
$filters[] = $this->filterBuilder->setField('payment_id')
->setValue($payment->getId())
->create();
$this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder
->setField('payment_id')
->setValue($payment->getId())
->create(),
]
);

$filters[] = $this->filterBuilder->setField('txn_type')
->setValue(TransactionInterface::TYPE_CAPTURE)
->create();
$this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder
->setField('txn_type')
->setValue(TransactionInterface::TYPE_CAPTURE)
->create(),
]
);

$searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)
->create();
$searchCriteria = $this->searchCriteriaBuilder->create();

$count = $this->transactionRepository->getList($searchCriteria)->getTotalCount();
return (boolean) $count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private function buildSearchCriteria()
->willReturnSelf();

$searchCriteria = new SearchCriteria();
$this->searchCriteriaBuilder->expects(static::once())
$this->searchCriteriaBuilder->expects(static::exactly(2))
->method('addFilters')
->willReturnSelf();
$this->searchCriteriaBuilder->expects(static::once())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testBuild()
$paymentExtension = $this->getMockBuilder(OrderPaymentExtension::class)
->setMethods(['getVaultPaymentToken'])
->disableOriginalConstructor()
->getMock();
->getMockForAbstractClass();

$paymentToken = $this->getMockBuilder(PaymentToken::class)
->disableOriginalConstructor()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model\Api\SearchCriteria\CollectionProcessor\FilterProcessor;

use Magento\Catalog\Model\ResourceModel\Product\Collection;
use Magento\Framework\Api\Filter;
use Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor\CustomFilterInterface;
use Magento\Framework\Data\Collection\AbstractDb;

class ProductCategoryFilter implements CustomFilterInterface
{
/**
* Apply category_id Filter to Product Collection
*
* @param Filter $filter
* @param AbstractDb $collection
* @return bool Whether the filter is applied
*/
public function apply(Filter $filter, AbstractDb $collection)
{
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
$categoryFilter = [$conditionType => [$filter->getValue()]];

/** @var Collection $collection */
$collection->addCategoriesFilter($categoryFilter);

return true;
}
}
54 changes: 20 additions & 34 deletions app/code/Magento/Catalog/Model/CategoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
use Magento\Framework\Api\Search\FilterGroup;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;

class CategoryList implements CategoryListInterface
{
Expand All @@ -39,22 +37,30 @@ class CategoryList implements CategoryListInterface
*/
private $categoryRepository;

/**
* @var CollectionProcessorInterface
*/
private $collectionProcessor;

/**
* @param CollectionFactory $categoryCollectionFactory
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
* @param CategorySearchResultsInterfaceFactory $categorySearchResultsFactory
* @param CategoryRepositoryInterface $categoryRepository
* @param CollectionProcessorInterface $collectionProcessor
*/
public function __construct(
CollectionFactory $categoryCollectionFactory,
JoinProcessorInterface $extensionAttributesJoinProcessor,
CategorySearchResultsInterfaceFactory $categorySearchResultsFactory,
CategoryRepositoryInterface $categoryRepository
CategoryRepositoryInterface $categoryRepository,
CollectionProcessorInterface $collectionProcessor = null
) {
$this->categoryCollectionFactory = $categoryCollectionFactory;
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
$this->categorySearchResultsFactory = $categorySearchResultsFactory;
$this->categoryRepository = $categoryRepository;
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
}

/**
Expand All @@ -66,23 +72,7 @@ public function getList(SearchCriteriaInterface $searchCriteria)
$collection = $this->categoryCollectionFactory->create();
$this->extensionAttributesJoinProcessor->process($collection);

foreach ($searchCriteria->getFilterGroups() as $group) {
$this->addFilterGroupToCollection($group, $collection);
}

/** @var SortOrder $sortOrder */
$sortOrders = $searchCriteria->getSortOrders();
if ($sortOrders) {
foreach ($sortOrders as $sortOrder) {
$collection->addOrder(
$sortOrder->getField(),
($sortOrder->getDirection() === SortOrder::SORT_ASC) ? SortOrder::SORT_ASC : SortOrder::SORT_DESC
);
}
}

$collection->setCurPage($searchCriteria->getCurrentPage());
$collection->setPageSize($searchCriteria->getPageSize());
$this->collectionProcessor->process($searchCriteria, $collection);

$items = [];
foreach ($collection->getAllIds() as $id) {
Expand All @@ -98,22 +88,18 @@ public function getList(SearchCriteriaInterface $searchCriteria)
}

/**
* Add filter group to collection
* Retrieve collection processor
*
* @param FilterGroup $filterGroup
* @param Collection $collection
* @return void
* @deprecated
* @return CollectionProcessorInterface
*/
private function addFilterGroupToCollection(FilterGroup $filterGroup, Collection $collection)
private function getCollectionProcessor()
{
$filters = $filterGroup->getFilters();
if ($filters) {
$fields = [];
foreach ($filters as $filter) {
$conditionType = $filter->getConditionType() ? $filter->getConditionType() : 'eq';
$fields[] = ['attribute' => $filter->getField(), $conditionType => $filter->getValue()];
}
$collection->addFieldToFilter($fields);
if (!$this->collectionProcessor) {
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
'Magento\Eav\Model\Api\SearchCriteria\CollectionProcessor'
);
}
return $this->collectionProcessor;
}
}
45 changes: 29 additions & 16 deletions app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Magento\Framework\Api\Data\ImageContentInterfaceFactory;
use Magento\Framework\Api\ImageContentValidatorInterface;
use Magento\Framework\Api\ImageProcessorInterface;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\DB\Adapter\ConnectionException;
use Magento\Framework\DB\Adapter\DeadlockException;
use Magento\Framework\DB\Adapter\LockWaitException;
Expand Down Expand Up @@ -135,6 +135,11 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
*/
protected $mediaGalleryProcessor;

/**
* @var CollectionProcessorInterface
*/
private $collectionProcessor;

/**
* ProductRepository constructor.
* @param ProductFactory $productFactory
Expand All @@ -157,6 +162,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
* @param MimeTypeExtensionMap $mimeTypeExtensionMap
* @param ImageProcessorInterface $imageProcessor
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
* @param CollectionProcessorInterface $collectionProcessor
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
Expand All @@ -180,7 +186,8 @@ public function __construct(
ImageContentInterfaceFactory $contentFactory,
MimeTypeExtensionMap $mimeTypeExtensionMap,
ImageProcessorInterface $imageProcessor,
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
\Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor,
CollectionProcessorInterface $collectionProcessor = null
) {
$this->productFactory = $productFactory;
$this->collectionFactory = $collectionFactory;
Expand All @@ -199,6 +206,7 @@ public function __construct(
$this->contentFactory = $contentFactory;
$this->imageProcessor = $imageProcessor;
$this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
}

/**
Expand Down Expand Up @@ -621,20 +629,8 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
$collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');

//Add filters from root filter group to the collection
foreach ($searchCriteria->getFilterGroups() as $group) {
$this->addFilterGroupToCollection($group, $collection);
}
/** @var SortOrder $sortOrder */
foreach ((array)$searchCriteria->getSortOrders() as $sortOrder) {
$field = $sortOrder->getField();
$collection->addOrder(
$field,
($sortOrder->getDirection() == SortOrder::SORT_ASC) ? 'ASC' : 'DESC'
);
}
$collection->setCurPage($searchCriteria->getCurrentPage());
$collection->setPageSize($searchCriteria->getPageSize());
$this->collectionProcessor->process($searchCriteria, $collection);

$collection->load();

$searchResult = $this->searchResultsFactory->create();
Expand All @@ -647,6 +643,7 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
/**
* Helper function that adds a FilterGroup to the collection.
*
* @deprecated
* @param \Magento\Framework\Api\Search\FilterGroup $filterGroup
* @param Collection $collection
* @return void
Expand Down Expand Up @@ -698,4 +695,20 @@ private function getMediaGalleryProcessor()
}
return $this->mediaGalleryProcessor;
}

/**
* Retrieve collection processor
*
* @deprecated
* @return CollectionProcessorInterface
*/
private function getCollectionProcessor()
{
if (!$this->collectionProcessor) {
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
'Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor'
);
}
return $this->collectionProcessor;
}
}
Loading

0 comments on commit 6e305b4

Please sign in to comment.