コード例 #1
0
ファイル: FulltextTest.php プロジェクト: aiesh/magento2
 /**
  * Search the text and return result collection
  *
  * @param string $text
  * @return \Magento\Catalog\Model\Product[]
  */
 protected function search($text)
 {
     $this->resourceFulltext->resetSearchResults();
     $query = $this->queryFactory->create();
     $query->setQueryText($text)->prepare();
     $this->resourceFulltext->prepareResult($this->fulltext, $text, $query);
     $query->getResultCollection();
     $products = [];
     foreach ($query->getResultCollection() as $product) {
         $products[] = $product;
     }
     return $products;
 }