如何獲取所有magento訂單狀態(待定,完成,處理等)的列表?如何獲取所有Magento訂單狀態(列出所有magento訂單狀態)
它應顯示所有值,如magento後端中order-index網格頁面中的「status」下拉字段。
如何獲取所有magento訂單狀態(待定,完成,處理等)的列表?如何獲取所有Magento訂單狀態(列出所有magento訂單狀態)
它應顯示所有值,如magento後端中order-index網格頁面中的「status」下拉字段。
只要使用的代碼這個簡單的行:
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" } }
獲取所有的訂單狀態,並保存陣列$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']
);
}
下面是獲得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
)
.....