1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Wishlist
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Wishlist sidebar block
30: *
31: * @category Mage
32: * @package Mage_Wishlist
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Wishlist_Block_Customer_Sidebar extends Mage_Wishlist_Block_Abstract
36: {
37: /**
38: * Retrieve block title
39: *
40: * @return string
41: */
42: public function getTitle()
43: {
44: return $this->__('My Wishlist <small>(%d)</small>', $this->getItemCount());
45: }
46:
47: /**
48: * Add sidebar conditions to collection
49: *
50: * @param Mage_Wishlist_Model_Resource_Item_Collection $collection
51: * @return Mage_Wishlist_Block_Customer_Wishlist
52: */
53: protected function _prepareCollection($collection)
54: {
55: $collection->setCurPage(1)
56: ->setPageSize(3)
57: ->setInStockFilter(true)
58: ->setOrder('added_at');
59:
60: return $this;
61: }
62:
63: /**
64: * Prepare before to html
65: *
66: * @return string
67: */
68: protected function _toHtml()
69: {
70: if ($this->getItemCount()) {
71: return parent::_toHtml();
72: }
73:
74: return '';
75: }
76:
77: /**
78: * Can Display wishlist
79: *
80: * @deprecated after 1.6.2.0
81: * @return bool
82: */
83: public function getCanDisplayWishlist()
84: {
85: return $this->_getCustomerSession()->isLoggedIn();
86: }
87:
88: /**
89: * Retrieve URL for removing item from wishlist
90: *
91: * @deprecated back compatibility alias for getItemRemoveUrl
92: * @param Mage_Wishlist_Model_Item $item
93: * @return string
94: */
95: public function getRemoveItemUrl($item)
96: {
97: return $this->getItemRemoveUrl($item);
98: }
99:
100: /**
101: * Retrieve URL for adding product to shopping cart and remove item from wishlist
102: *
103: * @deprecated
104: * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $product
105: * @return string
106: */
107: public function getAddToCartItemUrl($product)
108: {
109: return $this->getItemAddToCartUrl($product);
110: }
111:
112: /**
113: * Retrieve Wishlist Product Items collection
114: *
115: * @return Mage_Wishlist_Model_Resource_Item_Collection
116: */
117: public function getWishlistItems()
118: {
119: if (is_null($this->_collection)) {
120: $this->_collection = clone $this->_createWishlistItemCollection();
121: $this->_collection->clear();
122: $this->_prepareCollection($this->_collection);
123: }
124:
125: return $this->_collection;
126: }
127:
128: /**
129: * Return wishlist items count
130: *
131: * @return int
132: */
133: public function getItemCount()
134: {
135: return $this->_getHelper()->getItemCount();
136: }
137:
138: /**
139: * Check whether user has items in his wishlist
140: *
141: * @return bool
142: */
143: public function hasWishlistItems()
144: {
145: return $this->getItemCount() > 0;
146: }
147: }
148: