2013-04-18 182 views

回答

4

只要使用的代码这个简单的行:

Mage::getModel('sales/order_status')->getResourceCollection()->getData(); 

例如:

var_dump( Mage::getModel('sales/order_status')->getResourceCollection()->getData() ); 

结果:

array(10) { [0]=> array(2) { ["status"]=> string(8) "canceled" ["label"]=> string(8) "Canceled" } [1]=> array(2) { ["status"]=> string(6) "closed" ["label"]=> string(6) "Closed" } [2]=> array(2) { ["status"]=> string(8) "complete" ["label"]=> string(8) "Complete" } [3]=> array(2) { ["status"]=> string(5) "fraud" ["label"]=> string(15) "Suspected Fraud" } [4]=> array(2) { ["status"]=> string(6) "holded" ["label"]=> string(7) "On Hold" } [5]=> array(2) { ["status"]=> string(14) "payment_review" ["label"]=> string(14) "Payment Review" } [6]=> array(2) { ["status"]=> string(7) "pending" ["label"]=> string(7) "Pending" } [7]=> array(2) { ["status"]=> string(15) "pending_payment" ["label"]=> string(15) "Pending Payment" } [8]=> array(2) { ["status"]=> string(14) "pending_paypal" ["label"]=> string(14) "Pending PayPal" } [9]=> array(2) { ["status"]=> string(10) "processing" ["label"]=> string(10) "Processing" } } 
0

获取所有的订单状态,并保存阵列$orderStatus[status][label]$status关联阵列:

$orderStatusCollection = Mage::getModel('sales/order_status')->getResourceCollection()->getData(); 
$status = array(); 
$status = array(
    '-1'=>'Please Select..' 
); 

foreach($orderStatusCollection as $orderStatus) { 
    $status[] = array (
     'value' => $orderStatus['status'], 'label' => $orderStatus['label'] 
    ); 
} 
0

下面是获得DOP模式下的输出方式:

$statuses = Mage::getModel('sales/order_status')->getCollection() 
        ->toOptionArray() 
    echo '<pre>';print_r($statuses);echo '</pre>'; 
    //this will output: 
    Array 
    (
     [0] => Array 
      (
       [status] => canceled 
       [label] => Canceled 
      ) 

     [1] => Array 
      (
       [status] => cancel_ogone 
       [label] => Cancelled Ogone 
      ) 

     [2] => Array 
      (
       [status] => closed 
       [label] => Closed 
      ) 

     [3] => Array 
      (
       [status] => complete 
       [label] => Complete 
      ) 
    ..... 
相关问题