Example #1
0
 public function testGetProduct()
 {
     $productId = 1;
     $storeId = 0;
     $this->model->setData('product_id', $productId);
     $this->model->setData('store_id', $storeId);
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('setFinalPrice')->with(null);
     $productMock->expects($this->any())->method('setCustomOprtions')->with([]);
     $this->productRepository->expects($this->once())->method('getById')->willReturn($productMock);
     $this->assertEquals($productMock, $this->model->getProduct());
 }
Example #2
0
 /**
  * Retrieve params for updating product in wishlist
  *
  * @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
  *
  * @return  string|false
  */
 public function getUpdateParams($item)
 {
     $itemId = null;
     if ($item instanceof \Magento\Catalog\Model\Product) {
         $itemId = $item->getWishlistItemId();
         $productId = $item->getId();
     }
     if ($item instanceof \Magento\Wishlist\Model\Item) {
         $itemId = $item->getId();
         $productId = $item->getProduct()->getId();
     }
     $url = $this->_getUrl('wishlist/index/updateItemOptions');
     if ($itemId) {
         $params = array('id' => $itemId, 'product' => $productId);
         return $this->_postDataHelper->getPostData($url, $params);
     }
     return false;
 }
Example #3
0
 /**
  * Returns html for showing item options
  *
  * @param \Magento\Wishlist\Model\Item $item
  * @return string
  *
  * @deprecated after 1.6.2.0
  */
 public function getDetailsHtml(\Magento\Wishlist\Model\Item $item)
 {
     $cfg = $this->getOptionsRenderCfg($item->getProduct()->getTypeId());
     if (!$cfg) {
         return '';
     }
     $block = $this->getChildBlock('item_options');
     if (!$block) {
         return '';
     }
     if ($cfg['template']) {
         $template = $cfg['template'];
     } else {
         $cfgDefault = $this->getOptionsRenderCfg('default');
         if (!$cfgDefault) {
             return '';
         }
         $template = $cfgDefault['template'];
     }
     $block->setTemplate($template);
     $block->setOptionList($this->_helperPool->get($cfg['helper'])->getOptions($item));
     return $block->toHtml();
 }
Example #4
0
 /**
  * Retrieve URL to item Product
  *
  * @param  \Magento\Wishlist\Model\Item|\Magento\Catalog\Model\Product $item
  * @param  array $additional
  * @return string
  */
 public function getProductUrl($item, $additional = [])
 {
     if ($item instanceof \Magento\Catalog\Model\Product) {
         $product = $item;
     } else {
         $product = $item->getProduct();
     }
     $buyRequest = $item->getBuyRequest();
     if (is_object($buyRequest)) {
         $config = $buyRequest->getSuperProductConfig();
         if ($config && !empty($config['product_id'])) {
             $product = $this->productRepository->getById($config['product_id'], false, $this->_storeManager->getStore()->getStoreId());
         }
     }
     return $product->getUrlModel()->getUrl($product, $additional);
 }
Example #5
0
 /**
  * Retrieve product identifier linked with item
  *
  * @param \Magento\Wishlist\Model\Item $item
  * @return int
  */
 public function getProductId($item)
 {
     return $item->getProduct()->getId();
 }
Example #6
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)];
 }
Example #7
0
 /**
  * Retrieve URL to item Product
  *
  * @param  \Magento\Wishlist\Model\Item|\Magento\Catalog\Model\Product $item
  * @param  array $additional
  * @return string
  */
 public function getProductUrl($item, $additional = array())
 {
     if ($item instanceof \Magento\Catalog\Model\Product) {
         $product = $item;
     } else {
         $product = $item->getProduct();
     }
     $buyRequest = $item->getBuyRequest();
     if (is_object($buyRequest)) {
         $config = $buyRequest->getSuperProductConfig();
         if ($config && !empty($config['product_id'])) {
             $product = $this->_productFactory->create()->setStoreId($this->_storeManager->getStore()->getStoreId())->load($config['product_id']);
         }
     }
     return parent::getProductUrl($product, $additional);
 }