2013-12-13 140 views
1

将massAction添加到新的Magento Admin模块后,我被重定向到该模块的主页面,而不是我最后一次出现的位置。作为一个例子:我有一个月的下拉菜单,所以我选择“十一月”,然后从分页中选择“第3页”。后来,当我选择并运行对一个或多个项目的操作,我重定向回当月,第1magento管理员重定向到模块主模块后的主页

我加入massAction从这个帖子:http://inchoo.net/ecommerce/magento/how-to-add-massactions-to-magentos-grid/ 这是我结束了:

protected function _prepareMassaction() 
{ 
    parent::_prepareMassaction(); 

    $this->setMassactionIdField('entity_id'); 
    $this->getMassactionBlock()->setFormFieldName('value_id'); 

    $this->getMassactionBlock()->addItem('deactivate', array(
     'label'  => Mage::helper('renewals')->__('Deactivate'), 
     'url'  => $this->getUrl('*/*/massDeactivate'), 
     'confirm' => Mage::helper('renewals')->__('Are you sure you want to deactivate these accounts?'), 
    )); 

    return $this; 
} 

和我的控制器数据:

public function massDeactivateAction() 
{ 
    $value_ids = $this->getRequest()->getParam('value_id'); 

    $helper = Mage::helper('helper/data'); 
    foreach ($value_ids as $value_id) { 
     $helper->deactivateValue($value_id); 
    } 

    $this->_redirect('*/*/index'); 
    return; 
} 

任何想法会造成这种不停留在当前页面,我上? 它正在管理产品页面上工作,但有趣的是,当我点击一个页面时,页码不会进入URL,所以它显示它正在通过POST提交或者在我正在使用的特定页面上提交得到。我不确定这是否与问题有关。

回答

1

看看@Custom Module with Custom Database Table

看看@您的Grid.php,你$this->setSaveParametersInSession(true)$this->setUseAjax(true);

class <Namespace>_<Module>_Block_Adminhtml_<Module>_Grid extends Mage_Adminhtml_Block_Widget_Grid 
{ 
    public function __construct() 
    { 
     parent::__construct(); 
     .... 
     $this->setSaveParametersInSession(true); 
     $this->setUseAjax(true); 
    } 
+0

我也不得不添加'阵列( '_当前'=>真)'来我的重定向,然后与你建议的添加,它开始工作,如人们所期望的。谢谢! –