File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
app/code/Magento/CatalogSearch/Ui/DataProvider/Product Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Magento \CatalogSearch \Ui \DataProvider \Product ;
4+
5+ use Magento \Framework \Data \Collection ;
6+ use Magento \Ui \DataProvider \AddFilterToCollectionInterface ;
7+
8+ /**
9+ * Class AddFulltextFilterToCollection
10+ */
11+ class AddFulltextFilterToCollection implements AddFilterToCollectionInterface
12+ {
13+ protected $ collection ;
14+
15+ public function __construct (\Magento \CatalogSearch \Model \ResourceModel \Search \Collection $ searchCollection )
16+ {
17+ $ this ->searchCollection = $ searchCollection ;
18+ }
19+
20+ /**
21+ * @param Collection $collection
22+ * @param string $field
23+ * @param null $condition
24+ */
25+ public function addFilter (Collection $ collection , $ field , $ condition = null )
26+ {
27+ /** @var $collection \Magento\Catalog\Model\ResourceModel\Product\Collection */
28+ if (isset ($ condition ['fulltext ' ]) && !empty ($ condition ['fulltext ' ])) {
29+ $ this ->searchCollection ->addBackendSearchFilter ($ condition ['fulltext ' ]);
30+ $ productIds = $ this ->searchCollection ->load ()->getAllIds ();
31+ $ collection ->addIdFilter ($ productIds );
32+ }
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments