本文整理匯總了PHP中Varien_Event_Observer::getStatus方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Event_Observer::getStatus方法的具體用法?PHP Varien_Event_Observer::getStatus怎麽用?PHP Varien_Event_Observer::getStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Event_Observer
的用法示例。
在下文中一共展示了Varien_Event_Observer::getStatus方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateQty
public function updateQty(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig('deals/general/enabled')) {
if (Mage::getStoreConfig('deals/general/update') == 'order') {
$order = $observer->getOrder();
$status = $observer->getStatus();
$items = $order->getAllItems();
$ids = $qty = array();
foreach ($items as $itemId => $item) {
$ids[] = $item->getProductId();
$qty[] = $item->getQtyOrdered();
}
// Update deal if order status is complete
if ($status == 'complete') {
if (count($ids) > 0) {
foreach ($ids as $key => $productId) {
$product = Mage::getModel('catalog/product')->load($productId);
$deal = Mage::getModel('deals/deals')->getCollection()->addFieldToFilter('product_id', $productId)->addFieldToFilter('status', 2)->getFirstItem();
if ($deal->getId()) {
$dealModel = Mage::getModel('deals/deals');
$dealQty = $oldDealQty = $deal->getMaxDealQty();
$sold = $deal->getSold();
$sold = $sold + $qty[$key];
$dealModel->setSold($sold);
if ($dealQty == '') {
$dealModel->setMaxDealQty(NULL);
} else {
if ($dealQty > 0) {
$dealQty = $deal->getDealQty() - $sold;
$dealModel->setMaxDealQty($dealQty);
//Mage::helper('deals/data')->updateDealQty($productId, $sold);
}
if ($dealQty < 1) {
Mage::helper('deals/data')->updateProduct($productId);
$dealModel->setStatus(3);
}
}
$dealModel->setId($deal->getId())->save();
}
}
}
}
}
}
}
示例2: updateOrderState
/**
* Update the order state and status when it's been updated
*
* @param Varien_Event_Observer $observer
*/
public function updateOrderState(Varien_Event_Observer $observer)
{
$riskifiedOrderStatusHelper = Mage::helper('full/order_status');
$riskifiedInvoiceHelper = Mage::helper('full/order_invoice');
$order = $observer->getOrder();
$riskifiedStatus = (string) $observer->getStatus();
$riskifiedOldStatus = (string) $observer->getOldStatus();
$description = (string) $observer->getDescription();
$newState = $newStatus = null;
$currentState = $order->getState();
$currentStatus = $order->getStatus();
Mage::helper('full/log')->log("Checking if should update order '" . $order->getId() . "' from state: '{$currentState}' and status: '{$currentStatus}'");
Mage::helper('full/log')->log("Data received from riskified: status: " . $riskifiedStatus . ", old_status: " . $riskifiedOldStatus . ", description: " . $description);
switch ($riskifiedStatus) {
case 'approved':
if ($currentState == Mage_Sales_Model_Order::STATE_HOLDED && ($currentStatus == $riskifiedOrderStatusHelper->getOnHoldStatusCode() || $currentStatus == $riskifiedOrderStatusHelper->getTransportErrorStatusCode())) {
$newState = $riskifiedOrderStatusHelper->getSelectedApprovedState();
$newStatus = $riskifiedOrderStatusHelper->getSelectedApprovedStatus();
}
break;
case 'declined':
if ($currentState == Mage_Sales_Model_Order::STATE_HOLDED && ($currentStatus == $riskifiedOrderStatusHelper->getOnHoldStatusCode() || $currentStatus == $riskifiedOrderStatusHelper->getTransportErrorStatusCode())) {
$newState = $riskifiedOrderStatusHelper->getSelectedDeclinedState();
$newStatus = $riskifiedOrderStatusHelper->getSelectedDeclinedStatus();
}
break;
case 'submitted':
if ($currentState == Mage_Sales_Model_Order::STATE_PROCESSING || $currentState == Mage_Sales_Model_Order::STATE_HOLDED && $currentStatus == $riskifiedOrderStatusHelper->getTransportErrorStatusCode()) {
$newState = Mage_Sales_Model_Order::STATE_HOLDED;
$newStatus = $riskifiedOrderStatusHelper->getOnHoldStatusCode();
}
break;
case 'error':
if ($currentState == Mage_Sales_Model_Order::STATE_PROCESSING && $riskifiedInvoiceHelper->isAutoInvoiceEnabled()) {
$newState = Mage_Sales_Model_Order::STATE_HOLDED;
$newStatus = $riskifiedOrderStatusHelper->getTransportErrorStatusCode();
}
}
$changed = false;
// if newState exists and new state/status are different from current and config is set to status-sync
if ($newState && ($newState != $currentState || $newStatus != $currentStatus) && Mage::helper('full')->getConfigStatusControlActive()) {
if ($newState == Mage_Sales_Model_Order::STATE_CANCELED) {
Mage::helper('full/log')->log("Order '" . $order->getId() . "' should be canceled - calling cancel method");
$order->cancel();
}
$order->setState($newState, $newStatus, $description);
Mage::helper('full/log')->log("Updated order '" . $order->getId() . "' to: state: '{$newState}', status: '{$newStatus}', description: '{$description}'");
$changed = true;
} elseif ($description && $riskifiedStatus != $riskifiedOldStatus) {
Mage::helper('full/log')->log("Updated order " . $order->getId() . " history comment to: " . $description);
$order->addStatusHistoryComment($description);
$changed = true;
} else {
Mage::helper('full/log')->log("No update to state,status,comments is required for " . $order->getId());
}
if ($changed) {
try {
$order->save();
} catch (Exception $e) {
Mage::helper('full/log')->log("Error saving order: " . $e->getMessage());
return;
}
}
}