Пример #1
0
 /**
  * Get all option for item
  *
  * @param Item|int|string $item
  * @return array
  */
 public function getOptionsByItem($item)
 {
     if ($item instanceof Item) {
         $itemId = $item->getId();
     } else {
         $itemId = $item;
     }
     $this->load();
     $options = [];
     if (isset($this->_optionsByItem[$itemId])) {
         foreach ($this->_optionsByItem[$itemId] as $optionId) {
             $options[] = $this->_items[$optionId];
         }
     }
     return $options;
 }
Пример #2
0
 /**
  * Adding item to wishlist
  *
  * @param   Item $item
  * @return  $this
  */
 public function addItem(Item $item)
 {
     $item->setWishlist($this);
     if (!$item->getId()) {
         $this->getItemCollection()->addItem($item);
         $this->_eventManager->dispatch('wishlist_add_item', array('item' => $item));
     }
     return $this;
 }
Пример #3
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;
 }
Пример #4
0
 /**
  * Set quote item
  *
  * @param   Item $item
  * @return  $this
  */
 public function setItem($item)
 {
     $this->setWishlistItemId($item->getId());
     $this->_item = $item;
     return $this;
 }