如何在自定义模块中获取magento 2中的订单数组?

时间:2016-03-08 11:46:13

标签: magento-2.0

我需要自定义模块控制器中的订单数组。怎么弄?

尝试了这个,但没有工作:

$orderCollection = Mage::getModel('sales/order')->getCollection(); echo "";            
print_r($orderCollection);

错误:

"致命错误:Class' WebHive \ SPS \ Controller \ Index \ Mage'在第76行和第34行的C:\ wamp \ www \ magento_test \ app \ code \ WebHive \ SPS \ Controller \ Index \ Index.php中找不到;

所有建议都将受到赞赏....

1 个答案:

答案 0 :(得分:0)

可能以下可能对您有所帮助。 在控制器功能中试用此代码

    require_once 'app/Mage.php'; 
    Mage::app(); 
    $orderCollection = Mage::getModel('sales/order')->getCollection();