Skip to content

Commit

Permalink
Merge pull request #3842 from magento-arcticfoxes/pr
Browse files Browse the repository at this point in the history
[arcticfoxes] MC-15072: Error at the end of a long list of Tax Rates
  • Loading branch information
joanhe authored Mar 5, 2019
2 parents 5ec2b23 + 7ca44ef commit 605ec6f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 51 deletions.
5 changes: 2 additions & 3 deletions app/code/Magento/Catalog/Model/CategoryList.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public function getList(SearchCriteriaInterface $searchCriteria)
$this->extensionAttributesJoinProcessor->process($collection);

$this->collectionProcessor->process($searchCriteria, $collection);
$collection->load();

$items = [];
foreach ($collection->getItems() as $category) {
$items[] = $this->categoryRepository->get($category->getId());
foreach ($collection->getAllIds() as $id) {
$items[] = $this->categoryRepository->get($id);
}

/** @var CategorySearchResultsInterface $searchResult */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function testGetList()

$collection = $this->getMockBuilder(Collection::class)->disableOriginalConstructor()->getMock();
$collection->expects($this->once())->method('getSize')->willReturn($totalCount);
$collection->expects($this->once())->method('getItems')->willReturn([$categoryFirst, $categorySecond]);
$collection->expects($this->once())->method('getAllIds')->willReturn([$categoryIdFirst, $categoryIdSecond]);

$this->collectionProcessorMock->expects($this->once())
->method('process')
Expand Down
27 changes: 2 additions & 25 deletions app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Magento\CatalogGraphQl\Model\Resolver;

use Magento\Framework\Exception\InputException;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\CatalogGraphQl\Model\Resolver\Products\Query\Filter;
use Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search;
Expand All @@ -17,7 +16,6 @@
use Magento\Framework\GraphQl\Query\Resolver\Argument\SearchCriteria\SearchFilter;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Catalog\Model\Layer\Resolver;
use Magento\Framework\Api\Search\SearchCriteriaInterface;

/**
* Products field resolver, used for GraphQL request processing.
Expand Down Expand Up @@ -82,10 +80,10 @@ public function resolve(
} elseif (isset($args['search'])) {
$layerType = Resolver::CATALOG_LAYER_SEARCH;
$this->searchFilter->add($args['search'], $searchCriteria);
$searchResult = $this->getSearchResult($this->searchQuery, $searchCriteria, $info);
$searchResult = $this->searchQuery->getResult($searchCriteria, $info);
} else {
$layerType = Resolver::CATALOG_LAYER_CATEGORY;
$searchResult = $this->getSearchResult($this->filterQuery, $searchCriteria, $info);
$searchResult = $this->filterQuery->getResult($searchCriteria, $info);
}
//possible division by 0
if ($searchCriteria->getPageSize()) {
Expand Down Expand Up @@ -117,25 +115,4 @@ public function resolve(

return $data;
}

/**
* Get search result.
*
* @param Filter|Search $query
* @param SearchCriteriaInterface $searchCriteria
* @param ResolveInfo $info
*
* @return \Magento\CatalogGraphQl\Model\Resolver\Products\SearchResult
* @throws GraphQlInputException
*/
private function getSearchResult($query, SearchCriteriaInterface $searchCriteria, ResolveInfo $info)
{
try {
$searchResult = $query->getResult($searchCriteria, $info);
} catch (InputException $e) {
throw new GraphQlInputException(__($e->getMessage()));
}

return $searchResult;
}
}
9 changes: 0 additions & 9 deletions lib/internal/Magento/Framework/Data/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Magento\Framework\Data\Collection\EntityFactoryInterface;
use Magento\Framework\Option\ArrayInterface;
use Magento\Framework\Exception\InputException;

/**
* Data collection
Expand Down Expand Up @@ -235,20 +234,12 @@ protected function _setIsLoaded($flag = true)
* Get current collection page
*
* @param int $displacement
* @throws \Magento\Framework\Exception\InputException
* @return int
*/
public function getCurPage($displacement = 0)
{
if ($this->_curPage + $displacement < 1) {
return 1;
} elseif ($this->_curPage > $this->getLastPageNumber() && $displacement === 0) {
throw new InputException(
__(
'currentPage value %1 specified is greater than the %2 page(s) available.',
[$this->_curPage, $this->getLastPageNumber()]
)
);
} elseif ($this->_curPage + $displacement > $this->getLastPageNumber()) {
return $this->getLastPageNumber();
} else {
Expand Down
13 changes: 0 additions & 13 deletions lib/internal/Magento/Framework/Data/Test/Unit/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,6 @@ public function testGetCurPage()
$this->assertEquals(1, $this->_model->getCurPage());
}

/**
* Test for getCurPage with exception.
*
* @expectedException \Magento\Framework\Exception\StateException
* @return void
*/
public function testGetCurPageWithException()
{
$this->_model->setCurPage(10);
$this->expectException(\Magento\Framework\Exception\InputException::class);
$this->_model->getCurPage();
}

/**
* Test for method possibleFlowWithItem.
*
Expand Down

0 comments on commit 605ec6f

Please sign in to comment.