Esempio n. 1
0
 public function testGetProductPriceHtmlCreateBlock()
 {
     $priceType = 'wishlist_configured_price';
     $expected = 'block content';
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $renderMock = $this->getMockBuilder('\\Magento\\Framework\\Pricing\\Render')->disableOriginalConstructor()->getMock();
     $renderMock->expects($this->once())->method('render')->with($priceType, $productMock, ['zone' => Render::ZONE_ITEM_LIST])->willReturn($expected);
     $this->layout->expects($this->once())->method('getBlock')->with('product.price.render.default')->willReturn(false);
     $this->layout->expects($this->once())->method('createBlock')->with('Magento\\Framework\\Pricing\\Render', 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']])->willReturn($renderMock);
     $result = $this->block->getProductPriceHtml($productMock, $priceType, Render::ZONE_ITEM_LIST);
     $this->assertEquals($expected, $result);
 }
Esempio n. 2
0
 /**
  * Get wishlist items
  *
  * @return array
  */
 protected function getItems()
 {
     $this->view->loadLayout();
     $collection = $this->wishlistHelper->getWishlistItemCollection();
     $collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
     $items = [];
     foreach ($collection as $wishlistItem) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $wishlistItem->getProduct();
         $this->productImageView->init($product, 'wishlist_sidebar_block', 'Magento_Catalog');
         $items[] = ['image' => ['src' => $this->productImageView->getUrl(), 'alt' => $this->productImageView->getLabel(), 'width' => $this->productImageView->getWidth(), 'height' => $this->productImageView->getHeight()], 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem)];
     }
     return $items;
 }
Esempio n. 3
0
 /**
  * Retrieve wishlist item data
  *
  * @param \Magento\Wishlist\Model\Item $wishlistItem
  * @return array
  */
 protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
 {
     $product = $wishlistItem->getProduct();
     return ['image' => $this->getImageData($product), 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem, true), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem, true)];
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function getProductPriceHtml(\Magento\Catalog\Model\Product $product, $priceType, $renderZone = 'item_list', array $arguments = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getProductPriceHtml');
     if (!$pluginInfo) {
         return parent::getProductPriceHtml($product, $priceType, $renderZone, $arguments);
     } else {
         return $this->___callPlugins('getProductPriceHtml', func_get_args(), $pluginInfo);
     }
 }