Here I want show you how to add custom menu for order filter in admin. sometime client want to custom menu with some filter orders.
Here I show you get only processing orders with custom menu with this custom module.
Follow this steps and create module or files.
app\etc\modules\Jwd_Orderstosend.xml
<?xml version="1.0"?> <config> <modules> <Jwd_Orderstosend> <active>true</active> <codePool>local</codePool> </Jwd_Orderstosend> </modules> </config>
app\code\local\Jwd\Orderstosend\Block\Adminhtml\Order\Items.php
<?php class Jwd_Orderstosend_Block_Adminhtml_Order_Items extends Mage_Adminhtml_Block_Widget_Grid_Container { public function __construct() { $this->_blockGroup = 'jwd_orderstosend'; $this->_controller = 'adminhtml_order_items'; $this->_headerText = Mage::helper('adminhtml')->__('Orders to send'); parent::__construct(); $this->_removeButton('add'); } } ?>
app\code\local\Jwd\Orderstosend\Block\Adminhtml\Order\Items\Grid.php
<?php class Jwd_Orderstosend_Block_Adminhtml_Order_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid { public function __construct() { parent::__construct(); $this->setId('order_items'); $this->setUseAjax(false); $this->setDefaultSort('created_at'); $this->setDefaultDir('DESC'); $this->setSaveParametersInSession(true); } /** * Retrieve collection class * * @return string */ protected function _getCollectionClass() { return 'sales/order_grid_collection'; } protected function _prepareCollection() { //$collection = Mage::getResourceModel($this->_getCollectionClass()); $collection = Mage::getResourceModel('sales/order_collection') ->join(array('a' => 'sales/order_address'), 'main_table.entity_id = a.parent_id AND a.address_type != \'billing\'', array( 'city' => 'city', 'country_id' => 'country_id' )) ->join(array('c' => 'customer/customer_group'), 'main_table.customer_group_id = c.customer_group_id', array( 'customer_group_code' => 'customer_group_code' )) ->addExpressionFieldToSelect( 'fullname', 'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})', array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname')) ->addExpressionFieldToSelect( 'products', '(SELECT GROUP_CONCAT(\' \', x.name) FROM sales_flat_order_item x WHERE {{entity_id}} = x.order_id AND x.product_type != \'configurable\')', array('entity_id' => 'main_table.entity_id') ) ; $collection->addFieldToFilter('status', 'Processing'); $collection->addFieldToFilter('payment_validated', '1'); $this->setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns() { $this->addColumn('real_order_id', array( 'header'=> Mage::helper('sales')->__('Order #'), 'width' => '80px', 'type' => 'text', 'index' => 'increment_id', )); $this->addColumn('created_at', array( 'header' => Mage::helper('sales')->__('Purchased On'), 'index' => 'created_at', 'type' => 'datetime', 'width' => '200px', )); $this->addColumn('fullname', array( 'header' => Mage::helper('sales')->__('Name'), 'index' => 'fullname', 'width' => '200px', 'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)' )); $this->addColumn('country', array( 'header' => Mage::helper('sales')->__('Country'), 'index' => 'country_id', 'filter' => false, 'width' => '200px', 'renderer' => 'adminhtml/widget_grid_column_renderer_country' )); $this->addColumn('base_grand_total', array( 'header' => Mage::helper('sales')->__('G.T. (Base)'), 'index' => 'base_grand_total', 'type' => 'currency', 'width' => '100px', 'currency' => 'base_currency_code', )); $this->addColumn('status', array( 'header' => Mage::helper('sales')->__('Status'), 'index' => 'status', 'type' => 'options', 'width' => '200px', 'filter' => false, 'options' => Mage::getSingleton('sales/order_config')->getStatuses(), )); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { $this->addColumn('action', array( 'header' => Mage::helper('sales')->__('Action'), 'width' => '50px', 'type' => 'action', 'getter' => 'getId', 'actions' => array( array( 'caption' => Mage::helper('sales')->__('View'), 'url' => array('base'=>'*/sales_order/view'), 'field' => 'order_id' ) ), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'is_system' => true, )); } $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS')); $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV')); $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel XML')); return parent::_prepareColumns(); } protected function _prepareMassaction() { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('order_ids'); $this->getMassactionBlock()->setUseSelectAll(false); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) { $this->getMassactionBlock()->addItem('cancel_order', array( 'label'=> Mage::helper('sales')->__('Cancel'), 'url' => $this->getUrl('*/sales_order/massCancel'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) { $this->getMassactionBlock()->addItem('hold_order', array( 'label'=> Mage::helper('sales')->__('Hold'), 'url' => $this->getUrl('*/sales_order/massHold'), )); } if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) { $this->getMassactionBlock()->addItem('unhold_order', array( 'label'=> Mage::helper('sales')->__('Unhold'), 'url' => $this->getUrl('*/sales_order/massUnhold'), )); } $this->getMassactionBlock()->addItem('pdfinvoices_order', array( 'label'=> Mage::helper('sales')->__('Print Invoices'), 'url' => $this->getUrl('*/sales_order/pdfinvoices'), )); $this->getMassactionBlock()->addItem('pdfshipments_order', array( 'label'=> Mage::helper('sales')->__('Print Packingslips'), 'url' => $this->getUrl('*/sales_order/pdfshipments'), )); $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array( 'label'=> Mage::helper('sales')->__('Print Credit Memos'), 'url' => $this->getUrl('*/sales_order/pdfcreditmemos'), )); $this->getMassactionBlock()->addItem('pdfdocs_order', array( 'label'=> Mage::helper('sales')->__('Print All'), 'url' => $this->getUrl('*/sales_order/pdfdocs'), )); $this->getMassactionBlock()->addItem('print_shipping_label', array( 'label'=> Mage::helper('sales')->__('Print Shipping Labels'), 'url' => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'), )); return $this; } public function getRowUrl($row) { if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId())); } return false; } public function getGridUrl() { return $this->getUrl('*/*/grid', array('_current'=>true)); } } ?>
app\code\local\Jwd\Orderstosend\controllers\Adminhtml\Order\ItemsController.php
<?php class Jwd_Orderstosend_Adminhtml_Order_ItemsController extends Mage_Adminhtml_Controller_Action { public function indexAction() { $this->loadLayout()->_setActiveMenu('sales/order_items'); $this->_addContent($this->getLayout()->createBlock('jwd_orderstosend/adminhtml_order_items')); $this->renderLayout(); } /** * Order grid */ public function gridAction() { /*$this->loadLayout(false); $this->renderLayout();*/ $this->loadLayout()->_setActiveMenu('sales/order_items'); $this->_addContent($this->getLayout()->createBlock('jwd_orderstosend/adminhtml_order_items')); $this->renderLayout(); } } ?>
app\code\local\Jwd\Orderstosend\etc\config.xml
<?xml version="1.0"?> <config> <modules> <Jwd_Orderstosend> <version>0.1.0</version> </Jwd_Orderstosend> </modules> <global> <models> <jwd_orderstosend> <class>Jwd_Orderstosend_Model</class> <resourceModel>custom_orders_resource</resourceModel> </jwd_orderstosend> </models> <resources> <jwd_orderstosend_setup> <setup> <module>Jwd_Orderstosend</module> </setup> </jwd_orderstosend_setup> </resources> <blocks> <jwd_orderstosend> <class>Jwd_Orderstosend_Block</class> </jwd_orderstosend> </blocks> <helpers> <orderstosend> <class>Jwd_Orderstosend_Helper</class> </orderstosend> </helpers> </global> <adminhtml> <menu> <sales> <children> <order_items translate="title"> <title>Orders to send</title> <sort_order>11</sort_order> <action>adminhtml/order_items/index</action> </order_items> </children> </sales> </menu> </adminhtml> <admin> <routers> <adminhtml> <args> <modules> <jwd_orderstosend before="Mage_Adminhtml">Jwd_Orderstosend_Adminhtml</jwd_orderstosend> </modules> </args> </adminhtml> </routers> </admin> </config>
app\code\local\Jwd\Orderstosend\Helper\Data.php
<?php class Jwd_Orderstosend_Helper_Data extends Mage_Core_Helper_Abstract { } ?>
Hope this is helpfull and save time to get result.
Justwebdevelopment can also help you in...
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services
Thanks for finally talking about > Expert Magento 2 Freelancers – Justwebdevelopment < Liked it!