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
00033
00034 class Mage_Adminhtml_Model_Session_Quote extends Mage_Core_Model_Session_Abstract
00035 {
00036 const XML_PATH_DEFAULT_CREATEACCOUNT_GROUP = 'customer/create_account/default_group';
00037
00038
00039
00040
00041
00042
00043 protected $_quote = null;
00044
00045
00046
00047
00048
00049
00050 protected $_customer= null;
00051
00052
00053
00054
00055
00056
00057 protected $_store = null;
00058
00059
00060
00061
00062
00063
00064 protected $_order = null;
00065
00066 public function __construct()
00067 {
00068 $this->init('adminhtml_quote');
00069 if (Mage::app()->isSingleStoreMode()) {
00070 $this->setStoreId(Mage::app()->getStore(true)->getId());
00071 }
00072 }
00073
00074
00075
00076
00077
00078
00079 public function getQuote()
00080 {
00081 if (is_null($this->_quote)) {
00082 $this->_quote = Mage::getModel('sales/quote');
00083 if ($this->getStoreId() && $this->getQuoteId()) {
00084 $this->_quote->setStoreId($this->getStoreId())
00085 ->load($this->getQuoteId());
00086 }
00087 elseif($this->getStoreId() && $this->hasCustomerId()) {
00088 $this->_quote->setStoreId($this->getStoreId())
00089 ->setCustomerGroupId(Mage::getStoreConfig(self::XML_PATH_DEFAULT_CREATEACCOUNT_GROUP))
00090 ->assignCustomer($this->getCustomer())
00091 ->setIsActive(false)
00092 ->save();
00093 $this->setQuoteId($this->_quote->getId());
00094 }
00095 $this->_quote->setIgnoreOldQty(true);
00096 $this->_quote->setIsSuperMode(true);
00097 }
00098 return $this->_quote;
00099 }
00100
00101
00102
00103
00104
00105
00106 public function getCustomer()
00107 {
00108 if (is_null($this->_customer)) {
00109 $this->_customer = Mage::getModel('customer/customer');
00110 if ($customerId = $this->getCustomerId()) {
00111 $this->_customer->load($customerId);
00112 }
00113 }
00114 return $this->_customer;
00115 }
00116
00117
00118
00119
00120
00121
00122 public function getStore()
00123 {
00124 if (is_null($this->_store)) {
00125 $this->_store = Mage::app()->getStore($this->getStoreId());
00126 if ($currencyId = $this->getCurrencyId()) {
00127 $this->_store->setCurrentCurrencyCode($currencyId);
00128 }
00129 }
00130 return $this->_store;
00131 }
00132
00133
00134
00135
00136
00137
00138 public function getOrder()
00139 {
00140 if (is_null($this->_order)) {
00141 $this->_order = Mage::getModel('sales/order');
00142 if ($this->getOrderId()) {
00143 $this->_order->load($this->getOrderId());
00144 }
00145 }
00146 return $this->_order;
00147 }
00148 }