_adminhtmlData = $adminhtmlData; $this->string = $string; $this->queryFactory = $queryFactory; } /** * Load search results * * @return $this */ public function load() { $result = []; if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) { $this->setResults($result); return $this; } $collection = $this->queryFactory->get() ->getSearchCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('description') ->addBackendSearchFilter($this->getQuery()) ->setCurPage($this->getStart()) ->setPageSize($this->getLimit()) ->load(); foreach ($collection as $product) { $description = strip_tags($product->getDescription()); $result[] = [ 'id' => 'product/1/' . $product->getId(), 'type' => __('Product'), 'name' => $product->getName(), 'description' => $this->string->substr($description, 0, 30), 'url' => $this->_adminhtmlData->getUrl('catalog/product/edit', ['id' => $product->getId()]), ]; } $this->setResults($result); return $this; } }