public function loadByProductWishlist(Mage_Wishlist_Model_Item $item, $wishlistId, $productId, array $sharedStores) { $select = $this->_getReadAdapter()->select()->from(array('main_table' => $this->getTable('item')))->where('main_table.wishlist_id = ?', $wishlistId)->where('main_table.product_id = ?', $productId)->where('main_table.store_id in (?)', $sharedStores); if ($_data = $this->_getReadAdapter()->fetchRow($select)) { $item->setData($_data); } return $item; }
/** * Load item by wishlist, product and shared stores * * @param Mage_Wishlist_Model_Item $object * @param int $wishlistId * @param int $productId * @param array $sharedStores * @return Mage_Wishlist_Model_Mysql4_Item */ public function loadByProductWishlist($object, $wishlistId, $productId, $sharedStores) { $adapter = $this->_getReadAdapter(); $select = $adapter->select()->from($this->getMainTable())->where('wishlist_id=?', $wishlistId)->where('product_id=?', $productId)->where('store_id IN(?)', $sharedStores); $data = $adapter->fetchRow($select); if ($data) { $object->setData($data); } $this->_afterLoad($object); return $this; }
/** * Load item by wishlist, product and shared stores * * @param Mage_Wishlist_Model_Item $object * @param int $wishlistId * @param int $productId * @param array $sharedStores * @return Mage_Wishlist_Model_Resource_Item */ public function loadByProductWishlist($object, $wishlistId, $productId, $sharedStores) { $adapter = $this->_getReadAdapter(); $storeWhere = $adapter->quoteInto('store_id IN (?)', $sharedStores); $select = $adapter->select()->from($this->getMainTable())->where('wishlist_id=:wishlist_id AND ' . 'product_id=:product_id AND ' . $storeWhere); $bind = array('wishlist_id' => $wishlistId, 'product_id' => $productId); $data = $adapter->fetchRow($select, $bind); if ($data) { $object->setData($data); } $this->_afterLoad($object); return $this; }
/** * Set quote item * * @param Mage_Wishlist_Model_Item $item * @return Mage_Wishlist_Model_Item_Option */ public function setItem($item) { $this->setWishlistItemId($item->getId()); $this->_item = $item; return $this; }
/** * Retrieve product identifier linked with item * * @param Mage_Wishlist_Model_Item $item * @return int */ public function getProductId($item) { return $item->getProduct()->getId(); }
/** * Adding item to wishlist * * @param Mage_Wishlist_Model_Item $item * @return Mage_Wishlist_Model_Wishlist */ public function addItem(Mage_Wishlist_Model_Item $item) { $item->setWishlist($this); if (!$item->getId()) { $this->getItemCollection()->addItem($item); Mage::dispatchEvent('wishlist_add_item', array('item' => $item)); } return $this; }
/** * Returns qty to show visually to user * * @param Mage_Wishlist_Model_Item $item * @return float */ public function getAddToCartQty(Mage_Wishlist_Model_Item $item) { $qty = $item->getQty(); return $qty ? $qty : 1; }
/** * Returns html for showing item options * * @deprecated after 1.6.2.0 * @param Mage_Wishlist_Model_Item $item * @return string */ public function getDetailsHtml(Mage_Wishlist_Model_Item $item) { $cfg = $this->getOptionsRenderCfg($item->getProduct()->getTypeId()); if (!$cfg) { return ''; } $helper = Mage::helper($cfg['helper']); if (!$helper instanceof Mage_Catalog_Helper_Product_Configuration_Interface) { Mage::throwException($this->__("Helper for wishlist options rendering doesn't implement required interface.")); } $block = $this->getChild('item_options'); if (!$block) { return ''; } if ($cfg['template']) { $template = $cfg['template']; } else { $cfgDefault = $this->getOptionsRenderCfg('default'); if (!$cfgDefault) { return ''; } $template = $cfgDefault['template']; } return $block->setTemplate($template)->setOptionList($helper->getOptions($item))->toHtml(); }
/** * @param Mage_Wishlist_Model_Item $item * * @return string */ protected function _getWishlistItemUrl(Mage_Wishlist_Model_Item $item) { if ($item->getRedirectUrl()) { return $item->getRedirectUrl(); } return $this->_getProductUrl($item->getProduct()); }
/** * Retrieve url for adding item to shoping cart with b64 referer * * @param Mage_Wishlist_Model_Item $item * @return string */ public function getAddToCartUrlBase64($item) { return $this->_getUrl('wishlist/index/cart', array('item' => $item->getWishlistItemId(), Mage_Core_Controller_Front_Action::PARAM_NAME_BASE64_URL => AO::helper('core')->urlEncode($this->_getUrl('*/*/*', array('_current' => true))))); }
public function representProduct($product) { return $product->getWebtoprintTemplate() ? false : parent::representProduct($product); }
/** * Retrieve url for adding product to wishlist with params * * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item * @param array $params * * @return string|bool */ public function getAddUrlWithParams($item, array $params = array()) { $productId = null; if ($item instanceof Mage_Catalog_Model_Product) { $productId = $item->getEntityId(); } if ($item instanceof Mage_Wishlist_Model_Item) { $productId = $item->getProductId(); } if ($productId) { $params['product'] = $productId; return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params); } return false; }
/** * Retrieve URL for removing item from wishlist * * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item * @return string */ public function getConfigureUrl($item) { return $this->_getUrl('wishlist/index/configure', array('item' => $item->getWishlistItemId())); }
/** * Retrieve URL for removing item from wishlist * * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item * @return string */ public function getRemoveUrl($item) { return $this->_getUrl('wishlist/index/remove', array('item' => $item->getWishlistItemId())); }
/** * Retrieve url for adding item to shoping cart * * @param Mage_Wishlist_Model_Item $item * @return string */ public function getAddToCartUrl($item) { return $this->_getUrl('wishlist/index/cart', array('item' => $item->getWishlistItemId())); }
/** * 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 for adding product to wishlist with params * * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item * @param array $params * * @return string|bool */ public function getAddUrlWithParams($item, array $params = array()) { $productId = null; if ($item instanceof Mage_Catalog_Model_Product) { $productId = $item->getEntityId(); } if ($item instanceof Mage_Wishlist_Model_Item) { $productId = $item->getProductId(); } if ($productId) { $params['product'] = $productId; $params[Mage_Core_Model_Url::FORM_KEY] = $this->_getSingletonModel('core/session')->getFormKey(); return $this->_getUrlStore($item)->getUrl('wishlist/index/add', $params); } return false; }
/** * 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); }