/** * Add wishlist filter to collection * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return Mage_Wishlist_Model_Resource_Product_Collection */ public function addWishlistFilter(Mage_Wishlist_Model_Wishlist $wishlist) { $this->joinTable(array($this->_wishlistItemTableAlias => 'wishlist/item'), 'product_id=entity_id', array('product_id' => 'product_id', 'wishlist_item_description' => 'description', 'item_store_id' => 'store_id', 'added_at' => 'added_at', 'wishlist_id' => 'wishlist_id', 'wishlist_item_id' => 'wishlist_item_id'), array('wishlist_id' => $wishlist->getId(), 'store_id' => array('in' => $wishlist->getSharedStoreIds()))); $this->_productLimitationFilters['store_table'] = $this->_wishlistItemTableAlias; $this->setFlag('url_data_object', true); $this->setFlag('do_not_use_category_id', true); return $this; }
/** * Fetch items count * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return int */ public function fetchItemsCount(Mage_Wishlist_Model_Wishlist $wishlist) { if (is_null($this->_itemsCount)) { $collection = $wishlist->getItemCollection()->addStoreFilter()->setVisibilityFilter(); $this->_itemsCount = $collection->getSize(); } return $this->_itemsCount; }
public function getWishlist() { if (!$this->_wishlist) { $this->_wishlist = AO::getModel('wishlist/wishlist')->loadByCustomer(AO::getSingleton('customer/session')->getCustomer()); $this->_wishlist->getItemCollection()->addAttributeToSelect('name')->addAttributeToSelect('price')->addAttributeToSelect('small_image')->addAttributeToFilter('store_id', array('in' => $this->_wishlist->getSharedStoreIds()))->addAttributeToSort('added_at', 'desc')->setCurPage(1)->setPageSize(3)->load(); } return $this->_wishlist->getItemCollection(); }
/** * @magentoConfigFixture current_store rss/wishlist/active 1 * @magentoDataFixture Mage/Wishlist/_files/wishlist.php * @magentoAppIsolation enabled */ public function testWishlistAction() { $wishlist = new Mage_Wishlist_Model_Wishlist(); $wishlist->load('fixture_unique_code', 'sharing_code'); $this->getRequest()->setParam('wishlist_id', $wishlist->getId())->setParam('data', base64_encode('1')); Mage::getSingleton('Mage_Customer_Model_Session')->login('*****@*****.**', 'password'); $this->dispatch('rss/index/wishlist'); $this->assertContains('<![CDATA[Simple Product]]>', $this->getResponse()->getBody()); }
public function fetchItemsCount(Mage_Wishlist_Model_Wishlist $wishlist) { if (is_null($this->_itemsCount)) { $collection = $wishlist->getProductCollection()->addStoreFilter(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($collection); $this->_itemsCount = $collection->getSize(); } return $this->_itemsCount; }
/** * Retrieve wishlist items count * * @deprecated after 1.6.0.0-rc2 * @see Mage_Wishlist_Model_Wishlist::getItemsCount() * * @param Mage_Wishlist_Model_Wishlist $wishlist * * @return int */ public function fetchItemsCount(Mage_Wishlist_Model_Wishlist $wishlist) { if (is_null($this->_itemsCount)) { $this->_itemsCount = $wishlist->getItemsCount(); } return $this->_itemsCount; }
/** * Retrieve Wishlist model * * @return Mage_Wishlist_Model_Wishlist */ protected function _getWishlist() { if (is_null($this->_wishlist)) { if (Mage::registry('shared_wishlist')) { $this->_wishlist = Mage::registry('shared_wishlist'); } elseif (Mage::registry('wishlist')) { $this->_wishlist = Mage::registry('wishlist'); } else { $this->_wishlist = Mage::getModel('wishlist/wishlist'); if ($this->_getCustomerSession()->isLoggedIn()) { $this->_wishlist->loadByCustomer($this->_getCustomerSession()->getCustomer()); } } } return $this->_wishlist; }
public function getSharingCode() { $code = parent::getSharingCode(); if (Mage::helper('multiplewishlist')->isEnabled()) { $code .= '/tab-id/' . Mage::getModel('core/session')->getWishlistActiveTabId(); } return $code; }
/** * Retrieve customer wishlist model object * * @params bool $cacheReload pass cached wishlist object and get new one * @return Mage_Wishlist_Model_Wishlist */ public function getCustomerWishlist($cacheReload = false) { if (!is_null($this->_wishlist) && !$cacheReload) { return $this->_wishlist; } if ($this->getSession()->getCustomer()->getId()) { $this->_wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($this->getSession()->getCustomer(), true); $this->_wishlist->setStore($this->getSession()->getStore())->setSharedStoreIds($this->getSession()->getStore()->getWebsite()->getStoreIds()); } else { $this->_wishlist = false; } return $this->_wishlist; }
/** * Retrieve customer wishlist model object * * @return Mage_Wishlist_Model_Wishlist */ public function getCustomerWishlist() { if (!is_null($this->_wishlist)) { return $this->_wishlist; } if ($this->getSession()->getCustomer()->getId()) { $this->_wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($this->getSession()->getCustomer(), true); $this->_wishlist->setStore($this->getSession()->getStore()); } else { $this->_wishlist = false; } return $this->_wishlist; }
/** * Retrieve Wishlist model * * @return Mage_Wishlist_Model_Wishlist */ protected function _getWishlist() { if (is_null($this->_wishlist)) { $this->_wishlist = Mage::getModel('wishlist/wishlist'); $wishlistId = $this->getRequest()->getParam('wishlist_id'); if ($wishlistId) { $this->_wishlist->load($wishlistId); } else { if ($this->_getCustomer()->getId()) { $this->_wishlist->loadByCustomer($this->_getCustomer()); } } } return $this->_wishlist; }
/** * Retrieve wishlist by logged in customer * * @return Mage_Wishlist_Model_Wishlist */ public function getWishlist() { if (is_null($this->_wishlist)) { if (Mage::registry('shared_wishlist')) { $this->_wishlist = Mage::registry('shared_wishlist'); } elseif (Mage::registry('wishlist')) { $this->_wishlist = Mage::registry('wishlist'); } else { $this->_wishlist = Mage::getModel('wishlist/wishlist'); if ($this->getCustomer()) { $this->_wishlist->loadByCustomer($this->getCustomer()); } } } return $this->_wishlist; }
/** * IFrame handler for submitted configuration for wishlist item * * @return false */ public function updateAction() { // Update wishlist item $updateResult = new Varien_Object(); try { $this->_initData(); $buyRequest = new Varien_Object($this->getRequest()->getParams()); $this->_wishlist->updateItem($this->_wishlistItem->getId(), $buyRequest)->save(); $updateResult->setOk(true); } catch (Exception $e) { $updateResult->setError(true); $updateResult->setMessage($e->getMessage()); } $updateResult->setJsVarName($this->getRequest()->getParam('as_js_varname')); Mage::getSingleton('adminhtml/session')->setCompositeProductResult($updateResult); $this->_redirect('*/catalog_product/showUpdateResult'); return false; }
/** * Build wishlist management page url * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return string */ public function getWishlistManagementUrl(Mage_Wishlist_Model_Wishlist $wishlist) { return $this->getUrl('wishlist/*/*', array('wishlist_id' => $wishlist->getId())); }
/** * 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(); } }
/** * Add filter by wishlist object * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return Mage_Wishlist_Model_Resource_Item_Collection */ public function addWishlistFilter(Mage_Wishlist_Model_Wishlist $wishlist) { $this->addFieldToFilter('wishlist_id', $wishlist->getId()); return $this; }
/** * @param Mage_Wishlist_Model_Wishlist $wishlist * * @return Bronto_Common_Model_Email_Template_Filter */ protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist) { if (!in_array('wishlist', $this->_filteredObjects)) { $index = 1; foreach ($wishlist->getItemCollection() as $item) { if (!$item->getParentItem()) { $this->_filterWishlistItem($item, $index); $index++; } } // Add Related Content $this->_items = $wishlist->getItemCollection(); $queryParams = $this->getQueryParams(); $queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId()))); if ($store = $this->getStore()) { $this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams)); } else { $this->setField('wishlistURL', Mage::getUrl('reminder/load/index', $queryParams)); } // Setup wishlist items as a template if (class_exists('Bronto_Reminder_Block_Wishlist_Items', false)) { $layout = Mage::getSingleton('core/layout'); /* @var $items Mage_Sales_Block_Items_Abstract */ $items = $layout->createBlock('bronto/bronto_reminder_wishlist_items', 'items'); $items->setTemplate('bronto/reminder/items.phtml'); $items->setWishlist($item->getWishlist()); $this->_respectDesignTheme(); $this->setField("wishlistItems", $items->toHtml()); } $this->_filteredObjects[] = 'wishlist'; } return $this; }
public function addWishlistFilter(Mage_Wishlist_Model_Wishlist $wishlist) { $this->_joinFields['e_id'] = array('table' => 'e', 'field' => 'entity_id'); $this->joinTable('wishlist/item', 'product_id=e_id', array('product_id' => 'product_id', 'wishlist_item_description' => 'description', 'store_id' => 'store_id', 'added_at' => 'added_at', 'wishlist_id' => 'wishlist_id', 'wishlist_item_id' => 'wishlist_item_id'), array('wishlist_id' => $wishlist->getId())); return $this; }
/** * Get Customer ID from Quote/Wishlist * * @param int $ruleId * @param Mage_Sales_Model_Quote $quote * @param Mage_Wishlist_Model_Wishlist $wishlist * * @return int */ protected function _getCustomerId($ruleId, $quote, $wishlist) { if (!$ruleId || !$quote && !$wishlist) { return 0; } if ($quote) { return $quote->getCustomerId() ? $quote->getCustomerId() : 0; } if ($wishlist) { return $wishlist->getCustomerId() ? $wishlist->getCustomerId() : 0; } return 0; }
/** * Return frontend registry link * * @param Mage_Wishlist_Model_Wishlist $item * @return string */ public function getWishlistLink(Mage_Wishlist_Model_Wishlist $item) { return $this->getUrl('*/search/view', array('wishlist_id' => $item->getId())); }
/** * Retrieve number of wishlist items in given wishlist * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return int */ public function getWishlistItemCount(Mage_Wishlist_Model_Wishlist $wishlist) { $collection = $wishlist->getItemCollection(); if (Mage::getStoreConfig(self::XML_PATH_WISHLIST_LINK_USE_QTY)) { $count = $collection->getItemsQty(); } else { $count = $collection->getSize(); } return $count; }
public function fetchItemsCount(Mage_Wishlist_Model_Wishlist $wishlist) { $read = $this->_getReadAdapter(); $select = $read->select()->from($this->getTable('wishlist/item'), 'count(*)')->where('wishlist_id=?', $wishlist->getId())->where('store_id in (?)', $wishlist->getSharedStoreIds()); return $read->fetchOne($select); }
/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Wishlist * @subpackage integration_tests * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require __DIR__ . '/../../Customer/_files/customer.php'; require __DIR__ . '/../../Catalog/_files/product_simple.php'; $wishlist = new Mage_Wishlist_Model_Wishlist(); $wishlist->loadByCustomer($customer->getId(), true); $item = $wishlist->addNewItem($product, new Varien_Object(array())); $wishlist->setSharingCode('fixture_unique_code')->save();