0

I'm looking to create a completely separate admin grid using Sales Order data.

Unfortunately, every tutorial I've seen is to modify the existing sales_order_grid with new columns, etc. But haven't quite figured out how to recreate a separate admin grid using sales_order data.

Just for an example, I need to create a separate admin grid displaying orders with specific order status.


Edit, here's the current state of my module:

Vendor/Module/etc/adminhtml/menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
  <menu>
    <add id="Vendor_Module::po_report" title="Purchase Orders" translate="title" module="Vendor_Module" sortOrder="85" parent="Magento_Reports::report_salesroot" action="purchaseorder/report" resource="Vendor_Module::po_report"/>
  </menu>
</config>

Vendor/Module/etc/adminhtml/routes.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
  <router id="admin">
    <route id="purchaseorder" frontName="purchaseorder">
      <module name="Vendor_Module"/>
    </route>
  </router>
</config>

Vendor/Module/Controller/Adminhtml/Report/Index.php

<?php
namespace Vendor\Module\Controller\Adminhtml\Report;

class Index extends \Magento\Framework\App\Action\Action
{
  protected $_pageFactory;
  public function __construct(
    \Magento\Framework\App\Action\Context $context,
    \Magento\Framework\View\Result\PageFactory $pageFactory)
    {
      $this->_pageFactory = $pageFactory;
      return parent::__construct($context);
    }

    public function execute()
    {
      return $this->_pageFactory->create();
    }
  }

Vendor/Module/view/adminhtml/layout/purchaseorder_report_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
    <referenceContainer name="content">
     <uiComponent name="vendor_module_purchaseorders_report"/>
    </referenceContainer>
  </body>
</page>

From here, I'm stuck on how exactly to replicate the sales_order grid using uicomponent while also using my own filters on the order collection. (ie: A grid only containing orders with a status of pending_payment)

  • This is not hard at all. Did you ever try anything, if yes then added your module. Then easy to customize. – Sohel Rana Feb 5 at 17:46
  • @SohelRana , updated with my current code. I'm lost when it comes to using uicomponents and how to properly setup a grid using my own collection of orders. – AJ47 Feb 5 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.