Does anyone know how to run a search using FullText and a string?

I'm trying to inject

use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection as Fulltext;

and do

$products = $this->_fulltext->getItems();

but the result is always empty.

Any idea?

  • did you find any solution ? – Camit1dk Sep 7 '17 at 13:21
  • Not, nothing... – Miguel Sep 7 '17 at 15:22
  • I am also facing same issue , please reply here if you people got the solution. – user53836 Feb 6 '18 at 5:23

Try below code its work for me:

$searchCriteria = $this->searchCriteriaBuilder->create();
$this->searchResult = $this->searchInterface->search($searchCriteria);

//Create Temp table for store result 
$temporaryStorage = $this->temporaryStorageFactory->create();
$table = $temporaryStorage->storeApiDocuments($this->searchResult->getItems());        
$productCollection = $this->_productCollectionFactory->create();
       ['search_result' => $table->getName()],
       'e.entity_id = search_result.' . TemporaryStorage::FIELD_ENTITY_ID,

// Classes need to load

use Magento\Search\Api\SearchInterface;  //$this->searchInterface
use Magento\Framework\Search\Adapter\Mysql\TemporaryStorageFactory; // $this->temporaryStorageFactory
use Magento\Framework\Api\Search\SearchCriteriaBuilder; // $this->searchCriteriaBuilder
use Magento\Framework\Search\Adapter\Mysql\TemporaryStorage; //TemporaryStorage

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.