I have created a module that list the orders that are available to be moderated in a grid in adminhtml.
I need to pass the orderId from the grid view to the detail view and I don’t know how to do it.
Here is my Grid.php
{
public function __construct() {
parent::__construct();
$this->setId('moderationGrid');
// This is the primary key of the database
$this->setDefaultSort('increment_id');
$this->setDefaultDir('ASC');
$this->setSaveParametersInSession(true);
}
protected function _prepareCollection() {
$collection = Mage::getModel('sales/order')->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns() {
$this->addColumn('increment_id', array(
'header' => Mage::helper('sales')->__('Order Number'),
'align' =>'center',
'index' => 'increment_id',
));
$this->addColumn('created_at', array(
'header' => Mage::helper('sales')->__('Purchase Date'),
'align' => 'center',
'index' => 'created_at',
'type' => 'datetime',
));
$this->addColumn('action', array(
'header' => Mage::helper('moderation')->__('Action'),
'align' => 'center',
'type' => 'action',
'getter' => 'getId',
'actions' => array(
array(
'caption' => Mage::helper('sales')->__('Review'),
'url' => array('base'=>'*/adminhtml_moderation/view'),
'field' => 'increment_id'
)
),
'filter' => false,
'sortable' => false,
'index' => 'stores',
'is_system' => true,
));
return parent::_prepareColumns();
}
And here is my view Form.php
class Moderation_Block_Adminhtml_Moderation_View_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('moderation/form.phtml');
}
public function getOrder()
{
$moderationId = $this->getRequest()->getParam('increment_id');
$order = Mage::getModel('sales/order')->load();
}
}
You need to implement one more custom function in your grid.php (hint: this file named not by conventions, must be capital “G” – Grid.php):
That will give some other classes URL for yours every row.
For a reference look at
Mage_Adminhtml_Block_Catalog_Product_Gridline 320.