Example #1
0
 /**
  * Additional function to process forming description for wishlist item
  *
  * @param \Magento\Wishlist\Model\Wishlist $wishlistModelMock
  * @param array $staticArgs
  * @return string
  */
 protected function processWishlistItemDescription($wishlistModelMock, $staticArgs)
 {
     $imgThumbSrc = 'http://source-for-thumbnail';
     $priceHtmlForTest = '<div class="price">Price is 10 for example</div>';
     $productDescription = 'Product description';
     $productShortDescription = 'Product short description';
     $wishlistItem = $this->getMock('Magento\\Wishlist\\Model\\Item', [], [], '', false);
     $wishlistItemsCollection = [$wishlistItem];
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['getAllowedInRss', 'getAllowedPriceInRss', 'getDescription', 'getShortDescription', 'getName', '__wakeup'], [], '', false);
     $wishlistModelMock->expects($this->once())->method('getItemCollection')->will($this->returnValue($wishlistItemsCollection));
     $wishlistItem->expects($this->once())->method('getProduct')->will($this->returnValue($productMock));
     $productMock->expects($this->once())->method('getAllowedPriceInRss')->will($this->returnValue(true));
     $productMock->expects($this->once())->method('getName')->will($this->returnValue($staticArgs['productName']));
     $productMock->expects($this->once())->method('getAllowedInRss')->will($this->returnValue(true));
     $this->imageHelperMock->expects($this->once())->method('init')->will($this->returnSelf());
     $this->imageHelperMock->expects($this->once())->method('resize')->will($this->returnValue($imgThumbSrc));
     $priceRendererMock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['render'], [], '', false);
     $this->layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($priceRendererMock));
     $priceRendererMock->expects($this->once())->method('render')->will($this->returnValue($priceHtmlForTest));
     $productMock->expects($this->any())->method('getDescription')->will($this->returnValue($productDescription));
     $productMock->expects($this->any())->method('getShortDescription')->will($this->returnValue($productShortDescription));
     $this->catalogOutputMock->expects($this->any())->method('productAttribute')->will($this->returnArgument(1));
     $this->wishlistBlock->expects($this->any())->method('getProductUrl')->with($productMock, ['_rss' => true])->will($this->returnValue($staticArgs['productUrl']));
     $description = '<table><tr><td><a href="' . $staticArgs['productUrl'] . '"><img src="' . $imgThumbSrc . '" border="0" align="left" height="75" width="75"></a></td><td style="text-decoration:none;">' . $productShortDescription . '<p>' . $priceHtmlForTest . '</p><p>Comment: ' . $productDescription . '<p>' . '</td></tr></table>';
     return $description;
 }
Example #2
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;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function getImage($product, $imageId, $attributes = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getImage');
     if (!$pluginInfo) {
         return parent::getImage($product, $imageId, $attributes);
     } else {
         return $this->___callPlugins('getImage', func_get_args(), $pluginInfo);
     }
 }