Example #1
0
 /**
  * {@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;
 }