00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_ProductAlert 00023 * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 /** 00029 * Product Alert Abstract Email Block 00030 * 00031 * @category Mage 00032 * @package Mage_ProductAlert 00033 * @author Magento Core Team <core@magentocommerce.com> 00034 */ 00035 abstract class Mage_ProductAlert_Block_Email_Abstract extends Mage_Core_Block_Template 00036 { 00037 /** 00038 * Product collection array 00039 * 00040 * @var array 00041 */ 00042 protected $_products = array(); 00043 00044 /** 00045 * Current Store scope object 00046 * 00047 * @var Mage_Core_Model_Store 00048 */ 00049 protected $_store; 00050 00051 /** 00052 * Set Store scope 00053 * 00054 * @param int|string|Mage_Core_Model_Website|Mage_Core_Model_Store $store 00055 * @param Mage_ProductAlert_Block_Email_Price 00056 */ 00057 public function setStore($store) 00058 { 00059 if ($store instanceof Mage_Core_Model_Website) { 00060 $store = $store->getDefaultStore(); 00061 } 00062 if (!$store instanceof Mage_Core_Model_Store) { 00063 $store = Mage::app()->getStore($store); 00064 } 00065 00066 $this->_store = $store; 00067 00068 return $this; 00069 } 00070 00071 /** 00072 * Retrieve current store object 00073 * 00074 * @return Mage_Core_Model_Store 00075 */ 00076 public function getStore() 00077 { 00078 if (is_null($this->_store)) { 00079 $this->_store = Mage::app()->getStore(); 00080 } 00081 return $this->_store; 00082 } 00083 00084 /** 00085 * Convert price from default currency to current currency 00086 * 00087 * @param double $price 00088 * @param boolean $format Format price to currency format 00089 * @param boolean $includeContainer Enclose into <span class="price"><span> 00090 * @return double 00091 */ 00092 public function formatPrice($price, $format = true, $includeContainer = true) 00093 { 00094 return $this->getStore()->convertPrice($price, $format, $includeContainer); 00095 } 00096 00097 /** 00098 * Reset product collection 00099 * 00100 */ 00101 public function reset() 00102 { 00103 $this->_products = array(); 00104 } 00105 00106 /** 00107 * Add product to collection 00108 * 00109 * @param Mage_Catalog_Model_Product $product 00110 */ 00111 public function addProduct(Mage_Catalog_Model_Product $product) 00112 { 00113 $this->_products[$product->getId()] = $product; 00114 } 00115 00116 /** 00117 * Retrieve product collection array 00118 * 00119 * @return array 00120 */ 00121 public function getProducts() 00122 { 00123 return $this->_products; 00124 } 00125 00126 /** 00127 * Get store url params 00128 * 00129 * @return string 00130 */ 00131 protected function _getUrlParams() 00132 { 00133 return array( 00134 '_store' => $this->getStore(), 00135 '_store_to_url' => true 00136 ); 00137 } 00138 }