/** * 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; }
/** * @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()); }
/** * 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; }
/** * 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; }
/** * Check whether given wishlist is default for it's customer * * @param Mage_Wishlist_Model_Wishlist $wishlist * @return bool */ public function isWishlistDefault(Mage_Wishlist_Model_Wishlist $wishlist) { return $this->getDefaultWishlist($wishlist->getCustomerId())->getId() == $wishlist->getId(); }
/** * 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())); }
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); }
/** * 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())); }
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; }
/** * @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; }