Example #1
0
 /**
  * Get RSS feed items
  *
  * @return array
  */
 public function getRssData()
 {
     $wishlist = $this->getWishlist();
     if ($wishlist->getId()) {
         $data = $this->getHeader();
         /** @var $wishlistItem \Magento\Wishlist\Model\Item */
         foreach ($wishlist->getItemCollection() as $wishlistItem) {
             /* @var $product \Magento\Catalog\Model\Product */
             $product = $wishlistItem->getProduct();
             $productUrl = $this->wishlistBlock->getProductUrl($product, ['_rss' => true]);
             $product->setAllowedInRss(true);
             $product->setAllowedPriceInRss(true);
             $product->setProductUrl($productUrl);
             $args = ['product' => $product];
             $this->eventManager->dispatch('rss_wishlist_xml_callback', $args);
             if (!$product->getAllowedInRss()) {
                 continue;
             }
             $description = '<table><tr><td><a href="' . $productUrl . '"><img src="' . $this->imageHelper->init($product, 'rss_thumbnail')->getUrl() . '" border="0" align="left" height="75" width="75"></a></td>' . '<td style="text-decoration:none;">' . $this->outputHelper->productAttribute($product, $product->getShortDescription(), 'short_description') . '<p>';
             if ($product->getAllowedPriceInRss()) {
                 $description .= $this->getProductPriceHtml($product);
             }
             $description .= '</p>';
             if (trim($product->getDescription()) != '') {
                 $description .= '<p>' . __('Comment:') . ' ' . $this->outputHelper->productAttribute($product, $product->getDescription(), 'description') . '<p>';
             }
             $description .= '</td></tr></table>';
             $data['entries'][] = ['title' => $product->getName(), 'link' => $productUrl, 'description' => $description];
         }
     } else {
         $data = ['title' => __('We cannot retrieve the Wish List.'), 'description' => __('We cannot retrieve the Wish List.'), 'link' => $this->urlBuilder->getUrl(), 'charset' => 'UTF-8'];
     }
     return $data;
 }