2012-11-03 86 views
2

我在此處查看演練:http://www.excellencemagentoblog.com/magento-add-custom-fields-checkout-page在Magento結賬中添加自定義字段以審覈訂單步驟

我最初被要求打開一個關於自定義字段不保存到表格的問題,當字段被移動到審查順序步驟而不是引用文章的開票步驟時。所以我正在改寫我的問題,因爲我儘可能縮小了這個範圍。這是我的觀察類

class Excellence_Custom_Model_Observer{ 
public function saveQuoteBefore($evt){ 
    $quote = $evt->getQuote(); 
    $post = Mage::app()->getFrontController()->getRequest()->getPost(); 
    if(isset($post['custom']['sales_person'])){ 
     $var = $post['custom']['sales_person']; 
     $quote->setSalesPerson($var); 
    } 
} 
public function saveQuoteAfter($evt){ 
    $quote = $evt->getQuote(); 
    if($quote->getSalesPerson()){ 
     $var = $quote->getSalesPerson(); 
     if(!empty($var)){ 
      $model = Mage::getModel('custom/custom_quote'); 
      $model->deteleByQuote($quote->getId(),'sales_person'); 
      $model->setQuoteId($quote->getId()); 
      $model->setKey('sales_person'); 
      $model->setValue($var); 
      $model->save(); 
     } 
    } 
} 
public function loadQuoteAfter($evt){ 
    $quote = $evt->getQuote(); 
    $model = Mage::getModel('custom/custom_quote'); 
    $data = $model->getByQuote($quote->getId()); 
    foreach($data as $key => $value){ 
     $quote->setData($key,$value); 
    } 
} 
public function saveOrderAfter($evt){ 
    $order = $evt->getOrder(); 
    $quote = $evt->getQuote(); 
    if($quote->getSalesPerson()){ 
     $var = $quote->getSalesPerson(); 
     if(!empty($var)){ 
      $model = Mage::getModel('custom/custom_order'); 
      $model->deleteByOrder($order->getId(),'sales_person'); 
      $model->setOrderId($order->getId()); 
      $model->setKey('sales_person'); 
      $model->setValue($var); 
      $order->setSalesPerson($var); 
      $model->save(); 
     } 
    } 
} 
public function loadOrderAfter($evt){ 
    $order = $evt->getOrder(); 
    $model = Mage::getModel('custom/custom_order'); 
    $data = $model->getByOrder($order->getId()); 
    foreach($data as $key => $value){ 
     $order->setData($key,$value); 
    } 
} 

}

通過法師::日誌()我能看到saveQuoteBefore()只呼籲計費一步。這就是爲什麼當我移動領域時,它從未記錄。

是否有另一個鉤子,我需要保存它在審查順序步驟?

回答

相關問題