Skip to content

Commit 6521648

Browse files
committed
MAGETWO-64959: Grouped product is missing in category
1 parent a2cf937 commit 6521648

File tree

4 files changed

+142
-24
lines changed

4 files changed

+142
-24
lines changed

dev/tests/integration/testsuite/Magento/Framework/Search/Adapter/Mysql/AdapterTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -548,28 +548,6 @@ public function priceDataProvider()
548548
];
549549
}
550550

551-
/**
552-
* Search grouped product.
553-
*
554-
* @magentoDataFixture Magento/Framework/Search/_files/grouped_product.php
555-
* @magentoConfigFixture current_store catalog/search/engine mysql
556-
*
557-
* @return void
558-
*/
559-
public function testSearchGroupedProduct()
560-
{
561-
$this->requestBuilder->bind('search_term', 'Grouped Product');
562-
$this->requestBuilder->setRequestName('quick_search_container');
563-
564-
$queryResponse = $this->executeQuery();
565-
$result = $this->getProductIds($queryResponse);
566-
567-
self::assertCount(3, $result);
568-
569-
$groupedProduct = $this->productRepository->get('grouped-product');
570-
self::assertContains($groupedProduct->getId(), $result, 'Grouped product not found by name.');
571-
}
572-
573551
/**
574552
* Filter by tax class.
575553
*

dev/tests/integration/testsuite/Magento/Framework/Search/_files/custom_product_tax_class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
use Magento\Catalog\Api\ProductRepositoryInterface;
87
use Magento\Tax\Api\Data\TaxClassInterface;
98
use Magento\Tax\Api\Data\TaxClassInterfaceFactory;
109
use Magento\Tax\Api\TaxClassManagementInterface;

dev/tests/integration/testsuite/Magento/Framework/Search/_files/custom_product_tax_class_rollback.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@
2828
$productTaxClasses = $taxClassRepository->getList($searchCriteria);
2929
$taxClasses = $productTaxClasses->getItems();
3030

31+
/** @var \Psr\Log\LoggerInterface $logger */
32+
$logger = $objectManager->get(\Psr\Log\LoggerInterface::class);
33+
3134
if (!empty($taxClasses)) {
3235
foreach ($taxClasses as $taxClass) {
3336
try {
3437
$taxClassRepository->deleteById($taxClass->getClassId());
3538
} catch (Exception $e) {
36-
// Something went wrong.
39+
$logger->critical($e->getMessage(), ['exception' => $e]);
3740
}
3841
}
3942
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Search\Model;
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\CatalogSearch\Model\ResourceModel\EngineInterface;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
12+
/**
13+
* Search test.
14+
*
15+
* @magentoDbIsolation disabled
16+
* @magentoAppIsolation enabled
17+
*/
18+
class SearchTest extends \PHPUnit_Framework_TestCase
19+
{
20+
/**
21+
* @var \Magento\Framework\Search\AdapterInterface
22+
*/
23+
private $adapter;
24+
25+
/**
26+
* @var \Magento\Framework\ObjectManagerInterface
27+
*/
28+
protected $objectManager;
29+
30+
/**
31+
* @var string
32+
*/
33+
protected $searchEngine = EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE;
34+
35+
/**
36+
* @var ProductRepositoryInterface
37+
*/
38+
protected $productRepository;
39+
40+
/**
41+
* @var \Magento\Framework\Search\Request\Builder
42+
*/
43+
private $requestBuilder;
44+
45+
/**
46+
* @inheritdoc
47+
*/
48+
protected function setUp()
49+
{
50+
$this->objectManager = Bootstrap::getObjectManager();
51+
52+
/** @var \Magento\Framework\Search\Request\Config $config */
53+
$config = $this->objectManager->create(\Magento\Framework\Search\Request\Config::class);
54+
55+
$this->requestBuilder = $this->objectManager->create(
56+
\Magento\Framework\Search\Request\Builder::class,
57+
['config' => $config]
58+
);
59+
60+
$this->adapter = $this->createAdapter();
61+
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
62+
}
63+
64+
/**
65+
* Returns search adapter instance.
66+
*
67+
* @return \Magento\Framework\Search\AdapterInterface
68+
*/
69+
protected function createAdapter()
70+
{
71+
return $this->objectManager->create(\Magento\Framework\Search\Adapter\Mysql\Adapter::class);
72+
}
73+
74+
/**
75+
* Make sure that correct engine is set.
76+
*
77+
* @return void
78+
*/
79+
protected function assertPreConditions()
80+
{
81+
$currentEngine = $this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
82+
->getValue(EngineInterface::CONFIG_ENGINE_PATH, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
83+
$this->assertEquals($this->searchEngine, $currentEngine);
84+
}
85+
86+
/**
87+
* Execute search query.
88+
*
89+
* @return \Magento\Framework\Search\Response\QueryResponse
90+
*/
91+
private function executeQuery()
92+
{
93+
/** @var \Magento\Framework\Search\RequestInterface $queryRequest */
94+
$queryRequest = $this->requestBuilder->create();
95+
$queryResponse = $this->adapter->query($queryRequest);
96+
97+
return $queryResponse;
98+
}
99+
100+
/**
101+
* Returns document ids from query response.
102+
*
103+
* @param \Magento\Framework\Search\Response\QueryResponse $queryResponse
104+
* @return array
105+
*/
106+
protected function getProductIds(\Magento\Framework\Search\Response\QueryResponse $queryResponse)
107+
{
108+
$actualIds = [];
109+
foreach ($queryResponse as $document) {
110+
/** @var \Magento\Framework\Api\Search\Document $document */
111+
$actualIds[] = $document->getId();
112+
}
113+
114+
return $actualIds;
115+
}
116+
117+
/**
118+
* Search grouped product.
119+
*
120+
* @magentoDataFixture Magento/Framework/Search/_files/grouped_product.php
121+
* @magentoConfigFixture current_store catalog/search/engine mysql
122+
*
123+
* @return void
124+
*/
125+
public function testSearchGroupedProduct()
126+
{
127+
$this->requestBuilder->bind('search_term', 'Grouped Product');
128+
$this->requestBuilder->setRequestName('quick_search_container');
129+
130+
$queryResponse = $this->executeQuery();
131+
$result = $this->getProductIds($queryResponse);
132+
133+
self::assertCount(3, $result);
134+
135+
$groupedProduct = $this->productRepository->get('grouped-product');
136+
self::assertContains($groupedProduct->getId(), $result, 'Grouped product not found by name.');
137+
}
138+
}

0 commit comments

Comments
 (0)