Allan Brown

January 19, 2010

Define or pre-select products or items in a massaction Magento grid

Recently while building an administration interface for Magento (in adminhtml) I was needing to select products which should be added to a newsletter template (custom module).  The problem is that there is no obvious way to pre-select items or products when using a massaction grid in Magento.  The logic im trying to manipulate is contained in Mage_Adminhtml_Block_Widget_Grid.

The solution is to change (or pre-populate) the getRequest parameters (_POST values) so that the grid thinks that products have been selected on a previous page.  This can be done using the example code below, which should work for Magento massaction grids for products.

$this->getRequest()->setParam('internal_products',implode(',',$productIdArray));

$productIdArray contains a simple array of ids matching products.  Such as array(12,13,14,15)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

Powered by WordPress