/** * {@inheritdoc} * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getItems() { Profiler::start(__METHOD__); $items = []; /** @var \Magento\Catalog\Model\Product $product */ foreach ($this->collection as $product) { $item = ['sku' => $product->getSku(), 'name' => $product->getName(), 'url' => $product->getProductUrl(), 'description' => null, 'image' => null, 'price' => null, 'rating' => null]; if ($this->config->isShowShortDescription()) { $item['description'] = html_entity_decode(strip_tags($product->getDataUsingMethod('description'))); } $image = false; if ($product->getImage() && $product->getImage() != 'no_selection') { $image = $product->getImage(); } elseif ($product->getSmallImage() && $product->getSmallImage() != 'no_selection') { $image = $product->getSmallImage(); } if ($this->config->isShowImage() && $image) { $item['image'] = $this->imageHelper->init($product, false)->setImageFile($image)->resize(65 * 2, 80 * 2)->getUrl(); } if ($this->config->isShowPrice()) { $item['price'] = $this->catalogHelper->getTaxPrice($product, $product->getFinalPrice()); $item['price'] = $this->pricingHelper->currency($item['price'], false, false); } if ($this->config->isShowRating()) { $item['rating'] = $this->reviewRenderer->getReviewsSummaryHtml($product, ReviewRendererInterface::SHORT_VIEW); } $items[] = $item; } Profiler::stop(__METHOD__); return $items; }
/** * List of enabled indexes for autocomplete * * @return array */ public function getEnabledIndexes() { $configuration = $this->config->getIndexConfiguration(); $indexes = []; foreach ($this->getAvailableIndexes() as $index) { if (isset($configuration[$index->getData('code')])) { $data = $configuration[$index->getData('code')]; if (isset($data['is_active']) && $data['is_active']) { $index->setData('order', $data['order']); $index->setData('limit', $data['limit']); $indexes[] = $index; } } } usort($indexes, function ($a, $b) { return $a->getData('order') - $b->getData('order'); }); return $indexes; }
/** * Search collection for index * * @param \Mirasvit\Search\Model\Index $index * @return array */ public function getCollection($index) { $index->getSearchCollection()->setPageSize((int) $this->config->getIndexOptionValue($index->getData('code'), 'limit')); return $index->getSearchCollection(); }
/** * @return string */ public function getCssStyles() { return $this->config->getCssStyles(); }