如何在销售订单onclick中的自定义操作中获取选定的订单ID? [英] How can I get the selected order ids in custom action in sales order onclick?

查看:94
本文介绍了如何在销售订单onclick中的自定义操作中获取选定的订单ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在销售订单中添加了名为发票"的新批量操作.我想在单击此操作时创建发票.当我从列表中选择订单,然后在对销售订单的操作中选择发票时,如何获取订单ID.

I have added new mass action named as invoice in sales order. And I want to create an invoice on clicking this action. How I get the order id when I select the order from list and then select invoice in the action on sales order.

我的新批量操作发票显示在操作中,但是当我选择发票操作并提交时,我无法为所选订单创建发票.

My new mass action invoice are shown in the action but when I select the invoice action and submit than I am not able to make the invoice for the selected order.

app/code/local/MagePsycho/Newmodule/Block/Sales/Order/Grid.php:

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

        // Append new mass action option 
        $this->getMassactionBlock()->addItem(
            'newmodule',
            array('label' => $this->__('New Mass Action Title'), 
                  'url'   => $this->getUrl('newmodule/controller/action') //this should be the url where there will be mass operation
            )
        );
    }
}

app/code/local/MagePsycho/Newmodule/etc:-

app/code/local/MagePsycho/Newmodule/etc:-

 <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <sales_order_grid>MagePsycho_Newmodule_Block_Sales_Order_Grid</sales_order_grid>
                </rewrite>

<events>
        <core_block_abstract_prepare_layout_before>
            <observers>
                <newmodule_core_block_abstract_prepare_layout_before>
                    <class>newmodule/observer</class>
                    <method>addMassAction</method>
                </newmodule_core_block_abstract_prepare_layout_before>
            </observers>
        </core_block_abstract_prepare_layout_before>
    </events>
            </adminhtml>
        </blocks> 
    </global>

app/code/local/MagePsycho/Newmodule/Model/Observer.php:-

app/code/local/MagePsycho/Newmodule/Model/Observer.php:-

<?php
class MagePsycho_Newmodule_Model_Observer
{
    public function addMassAction($observer)
    {
        echo 'hello magento';
        $block = $observer->getEvent()->getBlock();
        if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
            && $block->getRequest()->getControllerName() == 'sales_order')
        {
            $block->addItem('newmodule', array(
                'label' => 'New Mass Action Title',
                'url' => Mage::app()->getStore()->getUrl('newmodule/controller/action'),
            ));
        }
    }
}

我该怎么做才能开具发票?

What can I do to make invoice on my action?

推荐答案

您可以通过getRequest在如下所示的自定义控制器操作的getParam方法中获取此信息

You can get this by getRequest in getParam method of your custom controllers action like below

  public function massChangeTypeAction()
    {
      $orderIds = (array)$this->getRequest()->getParam('order_ids');        
    }

您可以打印$orderIds以从网格中获取选定的订单.

You can print $orderIds to get selected order from grid.

这篇关于如何在销售订单onclick中的自定义操作中获取选定的订单ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆