コード例 #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;
 }
コード例 #2
0
ファイル: Data.php プロジェクト: aiesh/magento2
 /**
  * Retrieve query model object
  *
  * @return Query
  */
 public function getQuery()
 {
     if (!$this->_query) {
         $this->_query = $this->_queryFactory->create()->loadByQuery($this->getQueryText());
         if (!$this->_query->getId()) {
             $this->_query->setQueryText($this->getQueryText());
         }
     }
     return $this->_query;
 }