Skip to content

Commit f884e7c

Browse files
author
Stanislav Idolov
authored
MAGETWO-85786: #12193 Catalog not filtered by admin search bar #12735
2 parents 9e0b9ec + 8d49caf commit f884e7c

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogSearch\Ui\DataProvider\Product;
8+
9+
use Magento\Framework\Data\Collection;
10+
use Magento\CatalogSearch\Model\ResourceModel\Search\Collection as SearchCollection;
11+
use Magento\Ui\DataProvider\AddFilterToCollectionInterface;
12+
13+
/**
14+
* Class AddFulltextFilterToCollection
15+
*/
16+
class AddFulltextFilterToCollection implements AddFilterToCollectionInterface
17+
{
18+
/**
19+
* Search Collection
20+
*
21+
* @var SearchCollection
22+
*/
23+
private $searchCollection;
24+
25+
/**
26+
* @param SearchCollection $searchCollection
27+
*/
28+
public function __construct(SearchCollection $searchCollection)
29+
{
30+
$this->searchCollection = $searchCollection;
31+
}
32+
33+
/**
34+
* {@inheritdoc}
35+
*
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
37+
*/
38+
public function addFilter(Collection $collection, $field, $condition = null)
39+
{
40+
/** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
41+
if (isset($condition['fulltext']) && !empty($condition['fulltext'])) {
42+
$this->searchCollection->addBackendSearchFilter($condition['fulltext']);
43+
$productIds = $this->searchCollection->load()->getAllIds();
44+
$collection->addIdFilter($productIds);
45+
}
46+
}
47+
}

app/code/Magento/CatalogSearch/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"magento/module-eav": "101.0.*",
1313
"magento/module-backend": "100.2.*",
1414
"magento/module-theme": "100.2.*",
15+
"magento/module-ui": "101.0.*",
1516
"magento/module-catalog-inventory": "100.2.*",
1617
"magento/framework": "101.0.*"
1718
},

app/code/Magento/CatalogSearch/etc/adminhtml/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@
1919
<type name="Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front">
2020
<plugin name="search_weigh" type="Magento\CatalogSearch\Block\Plugin\FrontTabPlugin" />
2121
</type>
22+
<type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
23+
<arguments>
24+
<argument name="addFilterStrategies" xsi:type="array">
25+
<item name="fulltext" xsi:type="object">Magento\CatalogSearch\Ui\DataProvider\Product\AddFulltextFilterToCollection</item>
26+
</argument>
27+
</arguments>
28+
</type>
2229
</config>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
9+
<listingToolbar name="listing_top">
10+
<filterSearch name="fulltext"/>
11+
</listingToolbar>
12+
</listing>

0 commit comments

Comments
 (0)