Skip to content

Commit e1f1247

Browse files
author
dnyomo
committed
Code style fixes and added a message around converting _id to entity_id
1 parent 2f1b09c commit e1f1247

File tree

1 file changed

+3
-3
lines changed
  • app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider

1 file changed

+3
-3
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ProductSearch.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
use Magento\Framework\Api\Search\SearchResultInterface;
1919
use Magento\Framework\Api\SearchCriteriaInterface;
2020
use Magento\Framework\Api\SearchResultsInterface;
21-
use Magento\Framework\Exception\InputException;
2221
use Magento\GraphQl\Model\Query\ContextInterface;
2322

2423
/**
2524
* Product field data provider for product search, used for GraphQL resolver processing.
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2626
*/
2727
class ProductSearch
2828
{
@@ -88,7 +88,6 @@ public function __construct(
8888
* @param array $attributes
8989
* @param ContextInterface|null $context
9090
* @return SearchResultsInterface
91-
* @throws InputException
9291
*/
9392
public function getList(
9493
SearchCriteriaInterface $searchCriteria,
@@ -148,14 +147,15 @@ private function getSearchResultsApplier(
148147
*
149148
* @param SearchCriteriaInterface $searchCriteria
150149
* @return array
151-
* @throws InputException
152150
*/
153151
private function getSortOrderArray(SearchCriteriaInterface $searchCriteria)
154152
{
155153
$ordersArray = [];
156154
$sortOrders = $searchCriteria->getSortOrders();
157155
if (is_array($sortOrders)) {
158156
foreach ($sortOrders as $sortOrder) {
157+
// I am replacing _id with entity_id because in ElasticSearch _id is required for sorting by ID.
158+
// Where as entity_id is required when using ID as the sort in $collection->load();.
159159
if ($sortOrder->getField() === '_id') {
160160
$sortOrder->setField('entity_id');
161161
}

0 commit comments

Comments
 (0)