本文整理匯總了PHP中Varien_Event_Observer::getSession方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getSession方法的具體用法?PHP Varien_Event_Observer::getSession怎麽用?PHP Varien_Event_Observer::getSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getSession方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: adminCheckGuestOrder
/**
* Catch guest order creation in admin
*
* @param Varien_Event_Observer $observer
* @return void
*/
public function adminCheckGuestOrder(Varien_Event_Observer $observer)
{
/* @var $request Mage_Core_Controller_Request_Http */
$request = $observer->getRequestModel();
/** @var $session Mage_Adminhtml_Model_Session_Quote */
$session = $observer->getSession();
if ($request->getParam('is_guest_order')) {
// In case of guest order mark the quote appropriately
$session->getQuote()->setCustomerIsGuest(true);
if (($originalOrderId = $session->getPreviousOrderId()) && !$session->getIsGuestAddressPopulated()) {
// Populate address fields from the original order
$originalOrder = Mage::getModel('sales/order')->load($originalOrderId);
if ($originalOrder->getId()) {
$session->getQuote()->getBillingAddress()->setCustomerAddressId('');
Mage::helper('core')->copyFieldset('sales_copy_order_billing_address', 'to_order', $originalOrder->getBillingAddress(), $session->getQuote()->getBillingAddress());
$session->getQuote()->getShippingAddress()->setCustomerAddressId('');
Mage::helper('core')->copyFieldset('sales_copy_order_shipping_address', 'to_order', $originalOrder->getShippingAddress(), $session->getQuote()->getShippingAddress());
// Don't set our "guest address populated" flag on the session just yet,
// because quote isn't saved during this request in every case. Wait for save.
$session->getQuote()->setFlagGuestAddressOnSave(true);
}
}
}
}
示例2: uploadSkuCsv
/**
* Upload and parse CSV file with SKUs
*
* @param Varien_Event_Observer $observer
* @return null
*/
public function uploadSkuCsv(Varien_Event_Observer $observer)
{
/** @var $helper Enterprise_Checkout_Helper_Data */
$helper = Mage::helper('enterprise_checkout');
$rows = $helper->isSkuFileUploaded($observer->getRequestModel()) ? $helper->processSkuFileUploading($observer->getSession()) : array();
if (empty($rows)) {
return;
}
/* @var $orderCreateModel Mage_Adminhtml_Model_Sales_Order_Create */
$orderCreateModel = $observer->getOrderCreateModel();
$cart = $this->_getBackendCart($observer);
$cart->prepareAddProductsBySku($rows);
$cart->saveAffectedProducts($orderCreateModel, false);
}