Magento admin grid sending data from Action to Controller

I am trying to write a custom action to run the admin grid that I created. Is it possible to send a value from a column in the grid to the controller via get or post?

I tried a search on Google, but I can not find a suitable explanation for this. A link to an explanation of the column settings ("getter", "type", etc.) will also be useful if available.

+2
source share
1 answer

Add this code to your 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, )); 

This will create an β€œEdit” URL with the ID of the selected row as part of the URL. It will look something like <frontname>/<controllername>/edit/id/<value> , where value returned by the getId() receiver.

The getter field will execute any of the standard Magento magic getters, i.e. any attribute is gettable. That way you can have getName or getProductUrl or getIsLeftHanded if you want, and your controller can parse the attribute.

Then the controller can get this passed value using Mage::app()->getRequest()->getParam('attributename');

For documentation / tutorials, read this article on @AlanStorm's website as this may help.

NTN
Jd

+9
source

Source: https://habr.com/ru/post/1385930/


All Articles