Magento:在不创建发票或装运的情况下,是否可以将订单设置为处理状态?

Magento:在不创建发票或装运的情况下,是否可以将订单设置为处理状态?,magento,Magento,魔法师1.6版 我想修改checkmo付款方法,以便在创建订单时将订单提升到处理状态。我发现,通过更改/app/code/core/Mage/Payment/etc/system.xml(是的,现在只需在测试服务器上摆弄core,就可以正确地修改它,如果它正常工作的话)文件: <checkmo translate="label"> <fields> <order_status translate="label"> <source_

魔法师1.6版

我想修改checkmo付款方法,以便在创建订单时将订单提升到处理状态。我发现,通过更改/app/code/core/Mage/Payment/etc/system.xml(是的,现在只需在测试服务器上摆弄core,就可以正确地修改它,如果它正常工作的话)文件:

<checkmo translate="label">
  <fields>
    <order_status translate="label">
      <source_model>adminhtml/system_config_source_order_status_new</source_model>

adminhtml/system\u config\u source\u order\u status\u new
通过删除source_模型中的“new”,您可以在属于处理状态的配置中选择订单状态

但是,订单并不是真正处于处理状态。它们仍处于新建/挂起状态,但状态与处理状态不同。奇怪的混血儿

这不太管用,因为我的目标是能够轻松地在我为处理状态创建的4种自定义订单状态之间切换订单。原因是要使所有订单、check或CC处于相同的状态,以便可以对它们进行类似的处理。Authnet模块将CC订单置于处理状态,我希望checkmo订单加入它们。(相反,如果我可以使CC订单进入新的/待处理状态,我可以将我的自定义状态分配到该状态)无论哪种方式,我都需要所有新订单在创建时处于相同的状态,而不管是否存在发票或装运

谢谢


注意:这些相关问题并未完全解决此问题:6095096、6415547、4170628)

设置订单状态的重要操作在Mage_Sales_Model_order_Payment::Place()中处理:

但是,在Mage_Sales_Model_Order::setState()中,它不会检查订单状态和订单状态之间的关系。因此,奇怪的混合

有很多方法可以解决这个问题,一种是添加事件“checkout\u type\u onepage\u save\u order\u after”的观察者,并在那里重置状态。我的首选方法是在付款方式模型中添加回调:

class Celera_AaCredit_Model_Payment extends Mage_Payment_Model_Method_Abstract
{
protected $_code  = 'aa_credit'; 
protected $_isInitializeNeeded = true; //Required for the initialize() callback to happen 

/* Workaround to assign the correct order state to the corresponding status set in system config */

/**
 * Invoke in Mage_Sales_Model_Order_Payment
 * Required for the initialize() callback to happen     
 *      
 * @return string
 */                 
public function getConfigPaymentAction()
{
    return 'init'; //set flag to initialize $this after order is created and the payment is placed
}

/**
 * Update order state to system configuration 
 *
 * @return Mage_Payment_Model_Method_Abstract
*/ 
public function initialize($action, $stateObject)
{                          
    if ($status = $this->getConfigData('order_status')) {
        $stateObject->setStatus($status);
        $state = $this->_getAssignedState($status);
        $stateObject->setState($state);
        $stateObject->setIsNotified(true);            
    }
    return $this;
}

/**
 * Get the assigned state of an order status
 *     
 * @param string order_status
 */              
protected function _getAssignedState($status)
{
    $item = Mage::getResourceModel('sales/order_status_collection')
              ->joinStates()
              ->addFieldToFilter('main_table.status', $status)
              ->getFirstItem();
    return $item->getState();
}
}

谢谢经过更多的挖掘,我发现了这是一个观察者,正如你所建议的。
class Celera_AaCredit_Model_Payment extends Mage_Payment_Model_Method_Abstract
{
protected $_code  = 'aa_credit'; 
protected $_isInitializeNeeded = true; //Required for the initialize() callback to happen 

/* Workaround to assign the correct order state to the corresponding status set in system config */

/**
 * Invoke in Mage_Sales_Model_Order_Payment
 * Required for the initialize() callback to happen     
 *      
 * @return string
 */                 
public function getConfigPaymentAction()
{
    return 'init'; //set flag to initialize $this after order is created and the payment is placed
}

/**
 * Update order state to system configuration 
 *
 * @return Mage_Payment_Model_Method_Abstract
*/ 
public function initialize($action, $stateObject)
{                          
    if ($status = $this->getConfigData('order_status')) {
        $stateObject->setStatus($status);
        $state = $this->_getAssignedState($status);
        $stateObject->setState($state);
        $stateObject->setIsNotified(true);            
    }
    return $this;
}

/**
 * Get the assigned state of an order status
 *     
 * @param string order_status
 */              
protected function _getAssignedState($status)
{
    $item = Mage::getResourceModel('sales/order_status_collection')
              ->joinStates()
              ->addFieldToFilter('main_table.status', $status)
              ->getFirstItem();
    return $item->getState();
}
}