如何在magento 2中获取订单收集对象

ARV*_*KAR 3 magento2

我是magento2的初学者,我将尝试检索所有与订单相关的信息,而该信息只想在管理端显示,例如订单的ID,订单状态,商店名称,订单日期,付款方式等。在这里,我尝试获取订单信息,例如订单ID,订单状态,但页面将重定向到主页/仪表板。

我使用产品集合对象获取与产品相关的信息,但如何获取所有订单信息。

我不知道如何使用订单收集对象或订单存储库对象获取订单信息,并且该订单信息显示在magento2的管理端。

这是我的视图或info.phtml文件是:

<?php     $_order = $block->getOrder(3);
$orderAdminDate = $block->formatDate(
$block->getOrderAdminDate($_order->getCreatedAt()),
\IntlDateFormatter::MEDIUM, true );
echo 'Order Status = '.$_order->getStatusLabel();
echo 'Order Id = '. $_order->getRealOrderId();    ?>
Run Code Online (Sandbox Code Playgroud)

这是我的Info.php阻止文件是:

class Info extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder
{
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Sales\Model\Order\Address\Renderer $addressRenderer,
array $data = []
) {    $this->addressRenderer = $addressRenderer;
parent::__construct($context, $adminHelper, $data);
}
public function getOrder()
{    return $this->_coreRegistry->registry('current_order');    }    }
Run Code Online (Sandbox Code Playgroud)

Shi*_*ine 5

您可以通过下面的代码

<?php
 namespace 'moduleNameSpace';
class ModelClass extends \Magento\Framework\View\Element\Template
{

protected $_orderCollectionFactory;

public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
    array $data = []
) {
    $this->_orderCollectionFactory = $orderCollectionFactory;

    parent::__construct($context, $data);
    $this->_isScopePrivate = true;
}

protected function _construct()
{
    parent::_construct();
    $this->_orderCollectionFactory->create()->addAttributeToSelect('*')

}
   public function getSalesOrderCollection(array $filters = []){

    return $this->orderCollectionFactory;
}       
}
Run Code Online (Sandbox Code Playgroud)