
Public Member Functions | |
| loadByCustomer ($customer, $create=false) | |
| loadByCode ($code) | |
| getItemCollection () | |
| getProductCollection () | |
| addNewItem ($productId) | |
| setCustomerId ($customerId) | |
| getCustomerId () | |
| getDataForSave () | |
| getSharedStoreIds () | |
| setSharedStoreIds ($storeIds) | |
| getStore () | |
| setStore ($store) | |
| getItemsCount () | |
| isSalable () | |
Protected Member Functions | |
| _construct () | |
| _getSharingRandomCode () | |
Protected Attributes | |
| $_itemCollection = null | |
| $_store = null | |
| $_storeIds = null | |
Definition at line 35 of file Wishlist.php.
| _construct | ( | ) | [protected] |
Initialize resource model
Reimplemented from Varien_Object.
Definition at line 62 of file Wishlist.php.
00063 { 00064 $this->_init('wishlist/wishlist'); 00065 }
| _getSharingRandomCode | ( | ) | [protected] |
| addNewItem | ( | $ | productId | ) |
Add new item to wishlist
| int | $productId |
Definition at line 156 of file Wishlist.php.
00157 { 00158 $item = Mage::getModel('wishlist/item'); 00159 $item->loadByProductWishlist($this->getId(), $productId, $this->getSharedStoreIds()); 00160 00161 if (!$item->getId()) { 00162 $item->setProductId($productId) 00163 ->setWishlistId($this->getId()) 00164 ->setAddedAt(now()) 00165 ->setStoreId($this->getStore()->getId()) 00166 ->save(); 00167 } 00168 00169 return $item; 00170 }
| getCustomerId | ( | ) |
Retrieve customer id
Definition at line 188 of file Wishlist.php.
00189 { 00190 return $this->getData($this->_getResource()->getCustomerIdFieldName()); 00191 }
| getDataForSave | ( | ) |
Retrieve data for save
Definition at line 198 of file Wishlist.php.
00199 { 00200 $data = array(); 00201 $data[$this->_getResource()->getCustomerIdFieldName()] = $this->getCustomerId(); 00202 $data['shared'] = (int) $this->getShared(); 00203 $data['sharing_code']= $this->getSharingCode(); 00204 return $data; 00205 }
| getItemCollection | ( | ) |
Retrieve wishlist item collection
Definition at line 121 of file Wishlist.php.
00122 { 00123 if(is_null($this->_itemCollection)) { 00124 $this->_itemCollection = Mage::getResourceModel('wishlist/item_collection') 00125 ->setStoreId($this->getStore()->getId()) 00126 ->addWishlistFilter($this); 00127 } 00128 00129 return $this->_itemCollection; 00130 }
| getItemsCount | ( | ) |
Retrieve wishlist items count
Definition at line 262 of file Wishlist.php.
00263 { 00264 return $this->_getResource()->fetchItemsCount($this); 00265 }
| getProductCollection | ( | ) |
Retrieve Product collection
Definition at line 137 of file Wishlist.php.
00138 { 00139 $collection = $this->getData('product_collection'); 00140 if (is_null($collection)) { 00141 $collection = Mage::getResourceModel('wishlist/product_collection') 00142 ->setStoreId($this->getStore()->getId()) 00143 ->addWishlistFilter($this) 00144 ->addWishListSortOrder(); 00145 $this->setData('product_collection', $collection); 00146 } 00147 return $collection; 00148 }
| getSharedStoreIds | ( | ) |
Retrieve shared store ids
Definition at line 212 of file Wishlist.php.
00213 { 00214 if (is_null($this->_storeIds)) { 00215 $this->_storeIds = $this->getStore()->getWebsite()->getStoreIds(); 00216 } 00217 return $this->_storeIds; 00218 }
| getStore | ( | ) |
Retrieve wishlist store object
Definition at line 237 of file Wishlist.php.
00238 { 00239 if (is_null($this->_store)) { 00240 $this->setStore(Mage::app()->getStore()); 00241 } 00242 return $this->_store; 00243 }
| isSalable | ( | ) |
Retrieve wishlist has salable item(s)
Definition at line 272 of file Wishlist.php.
00273 { 00274 foreach ($this->getProductCollection() as $product) { 00275 if ($product->getIsSalable()) { 00276 return true; 00277 } 00278 } 00279 return false; 00280 }
| loadByCode | ( | $ | code | ) |
Load by sharing code
| string | $code |
Definition at line 97 of file Wishlist.php.
00098 { 00099 $this->_getResource()->load($this, $code, 'sharing_code'); 00100 if(!$this->getShared()) { 00101 $this->setId(null); 00102 } 00103 return $this; 00104 }
| loadByCustomer | ( | $ | customer, | |
| $ | create = false | |||
| ) |
Load wishlist by customer
| mixed | $customer | |
| bool | $create Create wishlist if don't exists |
Definition at line 74 of file Wishlist.php.
00075 { 00076 if ($customer instanceof Mage_Customer_Model_Customer) { 00077 $customer = $customer->getId(); 00078 } 00079 00080 $customerIdFieldName = $this->_getResource()->getCustomerIdFieldName(); 00081 $this->_getResource()->load($this, $customer, $customerIdFieldName); 00082 if (!$this->getId() && $create) { 00083 $this->setCustomerId($customer); 00084 $this->setSharingCode($this->_getSharingRandomCode()); 00085 $this->save(); 00086 } 00087 00088 return $this; 00089 }
| setCustomerId | ( | $ | customerId | ) |
Set customer id
| int | $customerId |
Definition at line 178 of file Wishlist.php.
00179 { 00180 return $this->setData($this->_getResource()->getCustomerIdFieldName(), $customerId); 00181 }
| setSharedStoreIds | ( | $ | storeIds | ) |
Set shared store ids
| array | $storeIds |
Definition at line 226 of file Wishlist.php.
00227 { 00228 $this->_storeIds = $storeIds; 00229 return $this; 00230 }
| setStore | ( | $ | store | ) |
Set wishlist store
| Mage_Core_Model_Store | $store |
Definition at line 251 of file Wishlist.php.
$_itemCollection = null [protected] |
Definition at line 42 of file Wishlist.php.
$_store = null [protected] |
Definition at line 49 of file Wishlist.php.
$_storeIds = null [protected] |
Definition at line 56 of file Wishlist.php.
1.5.8