From 0666b27c6f3aed663992beb166ef97f5523c2355 Mon Sep 17 00:00:00 2001 From: Pavel Potapenko Date: Fri, 15 Dec 2017 12:46:18 +0200 Subject: [PATCH 1/2] magento/magento2#12193 Catalog not filtered by admin search bar - Add fulltext/keyword search field for product admin grid --- .../Product/AddFulltextFilterToCollection.php | 47 +++++++++++++++++++ app/code/Magento/CatalogSearch/composer.json | 1 + .../CatalogSearch/etc/adminhtml/di.xml | 7 +++ .../ui_component/product_listing.xml | 12 +++++ 4 files changed, 67 insertions(+) create mode 100644 app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php create mode 100644 app/code/Magento/CatalogSearch/view/adminhtml/ui_component/product_listing.xml diff --git a/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php new file mode 100644 index 0000000000000..d1be68436b675 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php @@ -0,0 +1,47 @@ +searchCollection = $searchCollection; + } + + /** + * {@inheritdoc} + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function addFilter(Collection $collection, $field, $condition = null) + { + /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */ + if (isset($condition['fulltext']) && !empty($condition['fulltext'])) { + $this->searchCollection->addBackendSearchFilter($condition['fulltext']); + $productIds = $this->searchCollection->load()->getAllIds(); + $collection->addIdFilter($productIds); + } + } +} diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index 13be21e3248f2..fe88d675b1113 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -11,6 +11,7 @@ "magento/module-eav": "101.0.*", "magento/module-backend": "100.2.*", "magento/module-theme": "100.2.*", + "magento/module-ui": "100.2.*", "magento/module-catalog-inventory": "100.2.*", "magento/framework": "101.0.*" }, diff --git a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml index d323f0e95d9de..7877ff04b24fd 100644 --- a/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogSearch/etc/adminhtml/di.xml @@ -19,4 +19,11 @@ + + + + Magento\CatalogSearch\Ui\DataProvider\Product\AddFulltextFilterToCollection + + + diff --git a/app/code/Magento/CatalogSearch/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/CatalogSearch/view/adminhtml/ui_component/product_listing.xml new file mode 100644 index 0000000000000..24aa4a8919db8 --- /dev/null +++ b/app/code/Magento/CatalogSearch/view/adminhtml/ui_component/product_listing.xml @@ -0,0 +1,12 @@ + + ++ + + + From f5d93c3e04ebf7ee8fd2537c7415ae3b11ba07a9 Mon Sep 17 00:00:00 2001 From: Pavel Potapenko Date: Fri, 15 Dec 2017 17:02:42 +0200 Subject: [PATCH 2/2] magento/magento2#12193 Catalog not filtered by admin search bar --- app/code/Magento/CatalogSearch/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogSearch/composer.json b/app/code/Magento/CatalogSearch/composer.json index fe88d675b1113..b81213df007bd 100644 --- a/app/code/Magento/CatalogSearch/composer.json +++ b/app/code/Magento/CatalogSearch/composer.json @@ -11,7 +11,7 @@ "magento/module-eav": "101.0.*", "magento/module-backend": "100.2.*", "magento/module-theme": "100.2.*", - "magento/module-ui": "100.2.*", + "magento/module-ui": "101.0.*", "magento/module-catalog-inventory": "100.2.*", "magento/framework": "101.0.*" },