00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class Mage_Wishlist_Helper_Data extends Mage_Core_Helper_Abstract
00033 {
00034 protected $_wishlist = null;
00035 protected $_itemCount = null;
00036 protected $_itemCollection = null;
00037 protected $_productCollection = null;
00038
00039
00040
00041
00042
00043
00044 protected function _isCustomerLogIn()
00045 {
00046 return Mage::getSingleton('customer/session')->isLoggedIn();
00047 }
00048
00049
00050
00051
00052
00053
00054 protected function _getCurrentCustomer()
00055 {
00056 return Mage::getSingleton('customer/session')->getCustomer();
00057 }
00058
00059
00060
00061
00062
00063
00064 public function getWishlist()
00065 {
00066 if (is_null($this->_wishlist)) {
00067 $this->_wishlist = Mage::getModel('wishlist/wishlist')
00068 ->loadByCustomer($this->_getCurrentCustomer());
00069 }
00070 return $this->_wishlist;
00071 }
00072
00073
00074
00075
00076
00077
00078 public function hasItems()
00079 {
00080 return $this->getItemCount();
00081 }
00082
00083
00084
00085
00086
00087
00088 public function getItemCount()
00089 {
00090 if ($this->_isCustomerLogIn() && is_null($this->_itemCount)) {
00091 $this->_itemCount = $this->getWishlist()->getItemsCount();
00092 }
00093 elseif(is_null($this->_itemCount)) {
00094 $this->_itemCount = 0;
00095 }
00096 return $this->_itemCount;
00097 }
00098
00099
00100
00101
00102
00103
00104 public function getItemCollection()
00105 {
00106 if (is_null($this->_itemCollection)) {
00107 $this->_itemCollection = $this->getWishlist()->getProductCollection();
00108 }
00109 return $this->_itemCollection;
00110 }
00111
00112 public function getProductCollection()
00113 {
00114 if (is_null($this->_productCollection)) {
00115 $this->_productCollection = $this->getWishlist()->getProductCollection();
00116 }
00117 return $this->_productCollection;
00118 }
00119
00120
00121 public function getSharingUrl()
00122 {
00123
00124 }
00125
00126
00127
00128
00129
00130
00131
00132 public function getRemoveUrl($item)
00133 {
00134 return $this->_getUrl('wishlist/index/remove', array('item'=>$item->getWishlistItemId()));
00135 }
00136
00137
00138
00139
00140
00141
00142
00143 public function getAddUrl($item)
00144 {
00145 if ($item instanceof Mage_Catalog_Model_Product) {
00146 return $this->_getUrl('wishlist/index/add', array('product'=>$item->getId()));
00147 }
00148 if ($item instanceof Mage_Wishlist_Model_Item) {
00149 return $this->_getUrl('wishlist/index/add', array('product'=>$item->getProductId()));
00150 }
00151 return false;
00152 }
00153
00154
00155
00156
00157
00158
00159
00160 public function getAddToCartUrl($item)
00161 {
00162 return $this->_getUrl('wishlist/index/cart', array('item'=>$item->getWishlistItemId()));
00163 }
00164
00165
00166
00167
00168
00169
00170
00171 public function getAddToCartUrlBase64($item)
00172 {
00173 return $this->_getUrl('wishlist/index/cart', array(
00174 'item'=>$item->getWishlistItemId(),
00175 Mage_Core_Controller_Front_Action::PARAM_NAME_BASE64_URL => Mage::helper('core')->urlEncode(
00176 $this->_getUrl('*/*/*', array('_current'=>true))
00177 )
00178 ));
00179 }
00180
00181
00182
00183
00184
00185
00186
00187 public function getListUrl()
00188 {
00189 return $this->_getUrl('wishlist');
00190 }
00191
00192 public function isAllow()
00193 {
00194 if (Mage::getStoreConfig('wishlist/general/active')) {
00195 return true;
00196 }
00197 return false;
00198 }
00199
00200 public function isAllowInCart()
00201 {
00202 return $this->isAllow() && $this->_isCustomerLogIn();
00203 }
00204
00205 public function getCustomerName()
00206 {
00207 return $this->_getCurrentCustomer()->getName();
00208 }
00209
00210 public function getRssUrl()
00211 {
00212 $customer = $this->_getCurrentCustomer();
00213 $key = $customer->getId().','.$customer->getEmail();
00214 return $this->_getUrl('rss/index/wishlist',array('data' => Mage::helper('core')->urlEncode($key), '_secure' => false));
00215 }
00216
00217 public function isRssAllow()
00218 {
00219 if (Mage::getStoreConfig('rss/wishlist/active')) {
00220 return true;
00221 }
00222 return false;
00223 }
00224
00225 public function defaultCommentString()
00226 {
00227 return $this->__('Please, enter your comments...');
00228 }
00229 }