/** * Move item to given wishlist. * Check whether item belongs to one of customer's wishlists * * @param Mage_Wishlist_Model_Item $item * @param Mage_Wishlist_Model_Wishlist $wishlist * @param Mage_Wishlist_Model_Resource_Wishlist_Collection $customerWishlists * @param int $qty * @throws InvalidArgumentException|DomainException */ protected function _moveItem(Mage_Wishlist_Model_Item $item, Mage_Wishlist_Model_Wishlist $wishlist, Mage_Wishlist_Model_Resource_Wishlist_Collection $customerWishlists, $qty = null) { if (!$item->getId()) { throw new InvalidArgumentException(); } if ($item->getWishlistId() == $wishlist->getId()) { throw new DomainException(null, 1); } if (!$customerWishlists->getItemById($item->getWishlistId())) { throw new DomainException(null, 2); } $buyRequest = $item->getBuyRequest(); if ($qty) { $buyRequest->setQty($qty); } $wishlist->addNewItem($item->getProduct(), $buyRequest); $qtyDiff = $item->getQty() - $qty; if ($qty && $qtyDiff > 0) { $item->setQty($qtyDiff); $item->save(); } else { $item->delete(); } }
/** * Retrieve URL to item Product * * @param Mage_Wishlist_Model_Item|Mage_Catalog_Model_Product $item * @param array $additional * @return string */ public function getProductUrl($item, $additional = array()) { if ($item instanceof Mage_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 = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getStoreId())->load($config['product_id']); } } return parent::getProductUrl($product, $additional); }