Skip to content

Commit 462ec75

Browse files
author
Oleksandr Iegorov
committed
ACP2E-132: GraphQL Feature Request - "Did you mean ..", auto-corrected term to be given in Graphql
1 parent bec2a15 commit 462ec75

File tree

3 files changed

+39
-14
lines changed

3 files changed

+39
-14
lines changed

app/code/Magento/CatalogGraphQl/Model/QueryProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class QueryProcessor
3030

3131
/**
3232
* @param QueryFactory $queryFactory
33-
* @param StdlibString $string
33+
* @param StdlibString $string
3434
*/
3535
public function __construct(
3636
QueryFactory $queryFactory,

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/Search.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
use Magento\GraphQl\Model\Query\ContextInterface;
2020
use Magento\Search\Api\SearchInterface;
2121
use Magento\Search\Model\Search\PageSizeProvider;
22-
use Magento\Framework\Exception\NoSuchEntityException;
2322

2423
/**
2524
* Full text search for catalog using given search criteria.
25+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2626
*/
2727
class Search implements ProductQueryInterface
2828
{
@@ -66,16 +66,6 @@ class Search implements ProductQueryInterface
6666
*/
6767
private $suggestions;
6868

69-
/**
70-
* @var StdlibString
71-
*/
72-
private $string;
73-
74-
/**
75-
* @var SuggestedQueries
76-
*/
77-
private $suggestedQueries;
78-
7969
/**
8070
* @param SearchInterface $search
8171
* @param SearchResultFactory $searchResultFactory
@@ -95,8 +85,7 @@ public function __construct(
9585
SearchCriteriaBuilder $searchCriteriaBuilder,
9686
ArgumentsProcessorInterface $argsSelection = null,
9787
Suggestions $suggestions = null
98-
)
99-
{
88+
) {
10089
$this->search = $search;
10190
$this->searchResultFactory = $searchResultFactory;
10291
$this->pageSizeProvider = $pageSize;

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogGraphQl/ProductSearchTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,42 @@ private function getProductSearchQuery(string $productName, string $productSku):
7979
}
8080
}
8181
}
82+
QUERY;
83+
}
84+
85+
/**
86+
* @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php
87+
*/
88+
public function testSearchSuggestions() : void
89+
{
90+
$query = $this->getSearchQueryWithSuggestions();
91+
$response = $this->graphQlQuery($query);
92+
$this->assertNotEmpty($response['products']);
93+
$this->assertEmpty($response['products']['items']);
94+
$this->assertNotEmpty($response['products']['suggestions']);
95+
}
96+
97+
/**
98+
* Prepare search query with suggestions
99+
*
100+
* @return string
101+
*/
102+
private function getSearchQueryWithSuggestions() : string
103+
{
104+
return <<<QUERY
105+
{
106+
products(
107+
search: "smiple"
108+
) {
109+
items {
110+
name
111+
sku
112+
}
113+
suggestions {
114+
search
115+
}
116+
}
117+
}
82118
QUERY;
83119
}
84120
}

0 commit comments

Comments
 (0)