Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Wishlist_Block_Abstract
  • Mage_Wishlist_Block_Customer_Sharing
  • Mage_Wishlist_Block_Customer_Sidebar
  • Mage_Wishlist_Block_Customer_Wishlist
  • Mage_Wishlist_Block_Customer_Wishlist_Button
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Column
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Cart
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Comment
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Image
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Remove
  • Mage_Wishlist_Block_Customer_Wishlist_Item_Options
  • Mage_Wishlist_Block_Customer_Wishlist_Items
  • Mage_Wishlist_Block_Item_Configure
  • Mage_Wishlist_Block_Links
  • Mage_Wishlist_Block_Render_Item_Price
  • Mage_Wishlist_Block_Share_Email_Items
  • Mage_Wishlist_Block_Share_Email_Rss
  • Mage_Wishlist_Block_Share_Wishlist
  • Mage_Wishlist_Controller_Abstract
  • Mage_Wishlist_Helper_Data
  • Mage_Wishlist_IndexController
  • Mage_Wishlist_Model_Config
  • Mage_Wishlist_Model_Config_Source_Summary
  • Mage_Wishlist_Model_Item
  • Mage_Wishlist_Model_Item_Option
  • Mage_Wishlist_Model_Mysql4_Item
  • Mage_Wishlist_Model_Mysql4_Item_Collection
  • Mage_Wishlist_Model_Mysql4_Item_Option
  • Mage_Wishlist_Model_Mysql4_Item_Option_Collection
  • Mage_Wishlist_Model_Mysql4_Product_Collection
  • Mage_Wishlist_Model_Mysql4_Wishlist
  • Mage_Wishlist_Model_Mysql4_Wishlist_Collection
  • Mage_Wishlist_Model_Observer
  • Mage_Wishlist_Model_Resource_Item
  • Mage_Wishlist_Model_Resource_Item_Collection
  • Mage_Wishlist_Model_Resource_Item_Option
  • Mage_Wishlist_Model_Resource_Item_Option_Collection
  • Mage_Wishlist_Model_Resource_Wishlist
  • Mage_Wishlist_Model_Resource_Wishlist_Collection
  • Mage_Wishlist_Model_Session
  • Mage_Wishlist_Model_Wishlist
  • Mage_Wishlist_SharedController
  • Overview
  • Package
  • Class
  • Tree
  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 Product Items abstract Block
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Wishlist
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34:  */
 35: abstract class Mage_Wishlist_Block_Abstract extends Mage_Catalog_Block_Product_Abstract
 36: {
 37:     /**
 38:      * Wishlist Product Items Collection
 39:      *
 40:      * @var Mage_Wishlist_Model_Resource_Item_Collection
 41:      */
 42:     protected $_collection;
 43: 
 44:     /**
 45:      * Store wishlist Model
 46:      *
 47:      * @var Mage_Wishlist_Model_Wishlist
 48:      */
 49:     protected $_wishlist;
 50: 
 51:     /**
 52:      * List of block settings to render prices for different product types
 53:      *
 54:      * @var array
 55:      */
 56:     protected $_itemPriceBlockTypes = array();
 57: 
 58:     /**
 59:      * List of block instances to render prices for different product types
 60:      *
 61:      * @var array
 62:      */
 63:     protected $_cachedItemPriceBlocks = array();
 64: 
 65:     /**
 66:      * Internal constructor, that is called from real constructor
 67:      *
 68:      */
 69:     protected function _construct()
 70:     {
 71:         parent::_construct();
 72:         $this->addItemPriceBlockType('default', 'wishlist/render_item_price', 'wishlist/render/item/price.phtml');
 73:     }
 74: 
 75:     /**
 76:      * Retrieve Wishlist Data Helper
 77:      *
 78:      * @return Mage_Wishlist_Helper_Data
 79:      */
 80:     protected function _getHelper()
 81:     {
 82:         return Mage::helper('wishlist');
 83:     }
 84: 
 85:     /**
 86:      * Retrieve Customer Session instance
 87:      *
 88:      * @return Mage_Customer_Model_Session
 89:      */
 90:     protected function _getCustomerSession()
 91:     {
 92:         return Mage::getSingleton('customer/session');
 93:     }
 94: 
 95:     /**
 96:      * Retrieve Wishlist model
 97:      *
 98:      * @return Mage_Wishlist_Model_Wishlist
 99:      */
100:     protected function _getWishlist()
101:     {
102:         return $this->_getHelper()->getWishlist();
103:     }
104: 
105:     /**
106:      * Prepare additional conditions to collection
107:      *
108:      * @param Mage_Wishlist_Model_Resource_Item_Collection $collection
109:      * @return Mage_Wishlist_Block_Customer_Wishlist
110:      */
111:     protected function _prepareCollection($collection)
112:     {
113:         return $this;
114:     }
115: 
116:     /**
117:      * Create wishlist item collection
118:      *
119:      * @return Mage_Wishlist_Model_Resource_Item_Collection
120:      */
121:     protected function _createWishlistItemCollection()
122:     {
123:         return $this->_getWishlist()->getItemCollection();
124:     }
125: 
126:     /**
127:      * Retrieve Wishlist Product Items collection
128:      *
129:      * @return Mage_Wishlist_Model_Resource_Item_Collection
130:      */
131:     public function getWishlistItems()
132:     {
133:         if (is_null($this->_collection)) {
134:             $this->_collection = $this->_createWishlistItemCollection();
135:             $this->_prepareCollection($this->_collection);
136:         }
137: 
138:         return $this->_collection;
139:     }
140: 
141:     /**
142:      * Retrieve wishlist instance
143:      *
144:      * @return Mage_Wishlist_Model_Wishlist
145:      */
146:     public function getWishlistInstance()
147:     {
148:         return $this->_getWishlist();
149:     }
150: 
151:     /**
152:      * Back compatibility retrieve wishlist product items
153:      *
154:      * @deprecated after 1.4.2.0
155:      * @return Mage_Wishlist_Model_Mysql4_Item_Collection
156:      */
157:     public function getWishlist()
158:     {
159:         return $this->getWishlistItems();
160:     }
161: 
162:     /**
163:      * Retrieve URL for Removing item from wishlist
164:      *
165:      * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item
166:      *
167:      * @return string
168:      */
169:     public function getItemRemoveUrl($item)
170:     {
171:         return $this->_getHelper()->getRemoveUrl($item);
172:     }
173: 
174:     /**
175:      * Retrieve Add Item to shopping cart URL
176:      *
177:      * @param string|Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item
178:      * @return string
179:      */
180:     public function getItemAddToCartUrl($item)
181:     {
182:         return $this->_getHelper()->getAddToCartUrl($item);
183:     }
184: 
185:     /**
186:      * Retrieve Add Item to shopping cart URL from shared wishlist
187:      *
188:      * @param string|Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $item
189:      * @return string
190:      */
191:     public function getSharedItemAddToCartUrl($item)
192:     {
193:         return $this->_getHelper()->getSharedAddToCartUrl($item);
194:     }
195: 
196:     /**
197:      * Retrieve URL for adding Product to wishlist
198:      *
199:      * @param Mage_Catalog_Model_Product $product
200:      * @return string
201:      */
202:     public function getAddToWishlistUrl($product)
203:     {
204:         return $this->_getHelper()->getAddUrl($product);
205:     }
206: 
207:      /**
208:      * Returns item configure url in wishlist
209:      *
210:      * @param Mage_Catalog_Model_Product|Mage_Wishlist_Model_Item $product
211:      *
212:      * @return string
213:      */
214:     public function getItemConfigureUrl($product)
215:     {
216:         if ($product instanceof Mage_Catalog_Model_Product) {
217:             $id = $product->getWishlistItemId();
218:         } else {
219:             $id = $product->getId();
220:         }
221:         $params = array('id' => $id);
222: 
223:         return $this->getUrl('wishlist/index/configure/', $params);
224:     }
225: 
226: 
227:     /**
228:      * Retrieve Escaped Description for Wishlist Item
229:      *
230:      * @param Mage_Catalog_Model_Product $item
231:      * @return string
232:      */
233:     public function getEscapedDescription($item)
234:     {
235:         if ($item->getDescription()) {
236:             return $this->escapeHtml($item->getDescription());
237:         }
238:         return '&nbsp;';
239:     }
240: 
241:     /**
242:      * Check Wishlist item has description
243:      *
244:      * @param Mage_Catalog_Model_Product $item
245:      * @return bool
246:      */
247:     public function hasDescription($item)
248:     {
249:         return trim($item->getDescription()) != '';
250:     }
251: 
252:     /**
253:      * Retrieve formated Date
254:      *
255:      * @param string $date
256:      * @return string
257:      */
258:     public function getFormatedDate($date)
259:     {
260:         return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
261:     }
262: 
263:     /**
264:      * Check is the wishlist has a salable product(s)
265:      *
266:      * @return bool
267:      */
268:     public function isSaleable()
269:     {
270:         foreach ($this->getWishlistItems() as $item) {
271:             if ($item->getProduct()->isSaleable()) {
272:                 return true;
273:             }
274:         }
275: 
276:         return false;
277:     }
278: 
279:     /**
280:      * Retrieve wishlist loaded items count
281:      *
282:      * @return int
283:      */
284:     public function getWishlistItemsCount()
285:     {
286:         return $this->_getWishlist()->getItemsCount();
287:     }
288: 
289:     /**
290:      * Retrieve Qty from item
291:      *
292:      * @param Mage_Wishlist_Model_Item|Mage_Catalog_Model_Product $item
293:      * @return float
294:      */
295:     public function getQty($item)
296:     {
297:         $qty = $item->getQty() * 1;
298:         if (!$qty) {
299:             $qty = 1;
300:         }
301:         return $qty;
302:     }
303: 
304:     /**
305:      * Check is the wishlist has items
306:      *
307:      * @return bool
308:      */
309:     public function hasWishlistItems()
310:     {
311:         return $this->getWishlistItemsCount() > 0;
312:     }
313: 
314:     /**
315:      * Adds special block to render price for item with specific product type
316:      *
317:      * @param string $type
318:      * @param string $block
319:      * @param string $template
320:      */
321:     public function addItemPriceBlockType($type, $block = '', $template = '')
322:     {
323:         if ($type) {
324:             $this->_itemPriceBlockTypes[$type] = array(
325:                 'block' => $block,
326:                 'template' => $template
327:             );
328:         }
329:     }
330: 
331:     /**
332:      * Returns block to render item with some product type
333:      *
334:      * @param string $productType
335:      * @return Mage_Core_Block_Template
336:      */
337:     protected function _getItemPriceBlock($productType)
338:     {
339:         if (!isset($this->_itemPriceBlockTypes[$productType])) {
340:             $productType = 'default';
341:         }
342: 
343:         if (!isset($this->_cachedItemPriceBlocks[$productType])) {
344:             $blockType = $this->_itemPriceBlockTypes[$productType]['block'];
345:             $template = $this->_itemPriceBlockTypes[$productType]['template'];
346:             $block = $this->getLayout()->createBlock($blockType)
347:                 ->setTemplate($template);
348:             $this->_cachedItemPriceBlocks[$productType] = $block;
349:         }
350:         return $this->_cachedItemPriceBlocks[$productType];
351:     }
352: 
353:     /**
354:      * Returns product price block html
355:      * Overwrites parent price html return to be ready to show configured, partially configured and
356:      * non-configured products
357:      *
358:      * @param Mage_Catalog_Model_Product $product
359:      * @param bool $displayMinimalPrice
360:      * @param string $idSuffix
361:      *
362:      * @return string
363:      */
364:     public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
365:     {
366:         $type_id = $product->getTypeId();
367:         if (Mage::helper('catalog')->canApplyMsrp($product)) {
368:             $realPriceHtml = $this->_preparePriceRenderer($type_id)
369:                 ->setProduct($product)
370:                 ->setDisplayMinimalPrice($displayMinimalPrice)
371:                 ->setIdSuffix($idSuffix)
372:                 ->setIsEmulateMode(true)
373:                 ->toHtml();
374:             $product->setAddToCartUrl($this->getAddToCartUrl($product));
375:             $product->setRealPriceHtml($realPriceHtml);
376:             $type_id = $this->_mapRenderer;
377:         }
378: 
379:         return $this->_preparePriceRenderer($type_id)
380:             ->setProduct($product)
381:             ->setDisplayMinimalPrice($displayMinimalPrice)
382:             ->setIdSuffix($idSuffix)
383:             ->toHtml();
384:     }
385: 
386:     /**
387:      * Retrieve URL to item Product
388:      *
389:      * @param  Mage_Wishlist_Model_Item|Mage_Catalog_Model_Product $item
390:      * @param  array $additional
391:      * @return string
392:      */
393:     public function getProductUrl($item, $additional = array())
394:     {
395:         if ($item instanceof Mage_Catalog_Model_Product) {
396:             $product = $item;
397:         } else {
398:             $product = $item->getProduct();
399:         }
400:         $buyRequest = $item->getBuyRequest();
401:         if (is_object($buyRequest)) {
402:             $config = $buyRequest->getSuperProductConfig();
403:             if ($config && !empty($config['product_id'])) {
404:                 $product = Mage::getModel('catalog/product')
405:                     ->setStoreId(Mage::app()->getStore()->getStoreId())
406:                     ->load($config['product_id']);
407:             }
408:         }
409:         return parent::getProductUrl($product, $additional);
410:     }
411: }
412: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0