如何在magento中对销售订单中的批量操作进行排序

如何在magento中对销售订单中的批量操作进行排序,magento,Magento,我使用扩展名在magento back-end on sale>order中创建了一个名为invoice的新批量操作。 我在模块Block/Sale/Order中创建了grid.phtml,以在销售订单的后端显示我的批量操作 grid.phmtl:- <?php class Iclp_Batchupdate_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid { protected func

我使用扩展名在magento back-end on sale>order中创建了一个名为invoice的新批量操作。 我在模块Block/Sale/Order中创建了grid.phtml,以在销售订单的后端显示我的批量操作

grid.phmtl:-

<?php
class Iclp_Batchupdate_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{   
    protected function _prepareMassaction()
    {
        parent::_prepareMassaction();

        // Append new mass action option 
        $this->getMassactionBlock()->addItem('batchupdate',array('label' => $this->__('invoice'), 
                  'url'   => $this->getUrl('batchupdate/index/batchinvoice') //this should be the url where there will be mass operation
            )
        );
    }
}

你必须自己重新安排集体行动

打开至
app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

这里有一个名为
\u prepareMassaction()
的方法,在这个方法中,我们编写了所有的mass action。如果要将取消体量动作显示为最后一个选项,则必须在添加所有体量动作后添加它。在下面的代码中,我也做了同样的事情

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/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'),
    ));

    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'),
        ));
    }

    return $this;
}
注意:请记住不要直接更改核心文件。覆盖模块中的文件

用此文件替换您的文件

 <?php
    class Iclp_Batchupdate_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
    {   
       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'=> $this->__('Cancel'),
                     'url'  => $this->getUrl('*/sales_order/massCancel'),
                ));
            }

            if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/hold')) {
                $this->getMassactionBlock()->addItem('hold_order', array(
                     'label'=> $this->__('Hold'),
                     'url'  => $this->getUrl('*/sales_order/massHold'),
                ));
            }

            /**
             * This is your mass action. It's starts from here.
             * Also check this url is working or not
             */
            $this->getMassactionBlock()->addItem('batchupdate',array(
                'label' => $this->__('invoice'),
                'url'   => $this->getUrl('batchupdate/index/batchinvoice') //this should be the url where there will be mass operation
            ));
            /**
             * It's end here
             */

            $this->getMassactionBlock()->addItem('pdfdocs_order', array(
                'label'=> $this->__('Print All'),
                'url'  => $this->getUrl('*/sales_order/pdfdocs'),
            ));

            $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
                'label'=> $this->__('Print Credit Memos'),
                'url'  => $this->getUrl('*/sales_order/pdfcreditmemos'),
            ));

            $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
                 'label'=> $this->__('Print Invoices'),
                 'url'  => $this->getUrl('*/sales_order/pdfinvoices'),
            ));

            $this->getMassactionBlock()->addItem('pdfshipments_order', array(
                 'label'=> $this->__('Print Packingslips'),
                 'url'  => $this->getUrl('*/sales_order/pdfshipments'),
            ));                

            $this->getMassactionBlock()->addItem('print_shipping_label', array(
                 'label'=> $this->__('Print Shipping Labels'),
                 'url'  => $this->getUrl('*/sales_order_shipment/massPrintShippingLabel'),
            ));

            if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/unhold')) {
                $this->getMassactionBlock()->addItem('unhold_order', array(
                    'label'=> $this->__('Unhold'),
                    'url'  => $this->getUrl('*/sales_order/massUnhold'),
                ));
            }

            return $this;
        }
    }

我正在使用我的模块执行此操作,我不想更改核心文件。“我该如何使用我的模块。@兰杰青我已经更新了我的答案,请用我的代码替换你的代码。”。请自己更正代码缩进。我不想要这个。根据你的代码,所有的集体行动都会再次生成,但我只想对集体行动进行排序。我不会再次生成集体行动。在我的代码中,我刚刚覆盖了Mage\u Adminhtml\u Block\u Sales\u Order\u网格的
\u prepareMassaction
。您认为在您的代码中这意味着什么。它工作正常,但实际上我客户的要求不允许我覆盖该文件。还有别的办法吗??