Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

magento/magento2#12193 Catalog not filtered by admin search bar #12735

Merged
merged 3 commits into from
Apr 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\CatalogSearch\Ui\DataProvider\Product;

use Magento\Framework\Data\Collection;
use Magento\CatalogSearch\Model\ResourceModel\Search\Collection as SearchCollection;
use Magento\Ui\DataProvider\AddFilterToCollectionInterface;

/**
* Class AddFulltextFilterToCollection
*/
class AddFulltextFilterToCollection implements AddFilterToCollectionInterface
{
/**
* Search Collection
*
* @var SearchCollection
*/
private $searchCollection;

/**
* @param SearchCollection $searchCollection
*/
public function __construct(SearchCollection $searchCollection)
{
$this->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);
}
}
}
1 change: 1 addition & 0 deletions app/code/Magento/CatalogSearch/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"magento/module-eav": "101.0.*",
"magento/module-backend": "100.2.*",
"magento/module-theme": "100.2.*",
"magento/module-ui": "101.0.*",
"magento/module-catalog-inventory": "100.2.*",
"magento/framework": "101.0.*"
},
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/CatalogSearch/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@
<type name="Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Front">
<plugin name="search_weigh" type="Magento\CatalogSearch\Block\Plugin\FrontTabPlugin" />
</type>
<type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
<arguments>
<argument name="addFilterStrategies" xsi:type="array">
<item name="fulltext" xsi:type="object">Magento\CatalogSearch\Ui\DataProvider\Product\AddFulltextFilterToCollection</item>
</argument>
</arguments>
</type>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<filterSearch name="fulltext"/>
</listingToolbar>
</listing>