Magento管理网格将数据从Action发送到Controller

Geo*_*off 3 grid action magento adminhtml

我正在尝试编写一个自定义操作来运行我已构建的管理网格.是否可以通过get或post从网格中的列向控制器发送值?

我试过谷歌搜索,但我无法在任何地方找到适当的解释.如果可用,链接到列设置的说明('getter','type'等)也很有用.

Jon*_*Day 10

将此代码添加到Grid.php:

        $this->addColumn('action',
            array(
            'header'    =>  Mage::helper('yourmodulename')->__('Action'),
            'width'     => '100',
            'type'      => 'action',
            'getter'    => 'getId',
            'actions'   => array(
                    array(
                            'caption'   => Mage::helper('yourmodulename')->__('Edit'),
                            'url'       => array('base'=> '*/*/edit'),
                            'field'     => 'id'
                    )
            ),
            'filter'    => false,
            'sortable'  => false,
            'index'     => 'stores',
            'is_system' => true,
    ));
Run Code Online (Sandbox Code Playgroud)

这将构建一个"编辑"URL,其中所选行的Id作为URL的一部分.它看起来像是getter返回的<frontname>/<controllername>/edit/id/<value>地方. valuegetId()

getter字段将执行任何标准的Magento魔术getter,即任何属性都是gettable.所以,你可以有getName或者getProductUrl或者getIsLeftHanded,如果你想和你的控制器可以解析的属性.

然后,控制器可以使用检索传递的值 Mage::app()->getRequest()->getParam('attributename');

在文档/教程方面,请阅读@AlanStorm网站上的这篇文章,因为它可能有所帮助.

HTH,
JD