【问题标题】:How to get all Magento Order status (List all magento order status)如何获取所有 Magento 订单状态(列出所有 Magento 订单状态)
【发布时间】:2013-04-18 10:05:53
【问题描述】:

如何获取所有 magento 订单状态(待处理、完成、处理等)的列表?

它应该显示所有值,例如 magento 后端订单索引网格页面中的“状态”下拉字段。

【问题讨论】:

    标签: magento


    【解决方案1】:

    只需使用这行简单的代码:

    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" } }
    

    【讨论】:

      【解决方案2】:

      获取所有订单状态并将数组$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']
          );
      }
      

      【讨论】:

        【解决方案3】:

        这里是获取dop-down输出的方法:

            $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
                    )
            .....
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-02-17
          • 2012-08-19
          • 1970-01-01
          • 1970-01-01
          • 2014-09-06
          • 2012-01-08
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多