Pregunta

Tengo una cuadrícula personalizada que muestra todos los bloques de CMS.Cuando utilice la barra de búsqueda en la cuadrícula para filtrar un título, me redirige a una página 404.¿Hay algo mal con mi cuadrícula para causar el redirecto a una página desconocida?

Además, no estoy seguro de si importa, pero esto está sucediendo en Enterprise Edition 1.12.Tengo otra instancia que es EE-1.13, que esto no es un problema.

class TP_CustomApp_Block_Adminhtml_Glcmsblock_Grid extends Mage_Adminhtml_Block_Widget_Grid {

      public function __construct() {
        parent::__construct();
        $this->setId('glcmsblockGrid');
        $this->setDefaultSort('entity_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
        $this->setVarNameFilter('product_filter');
      }

      protected function _prepareCollection() {
        $store =  $this->getRequest()->getParam('store', '');
        Mage::getSingleton('core/session')->unsObjectType();
        Mage::getSingleton('core/session')->setObjectType(‘cms/block’);
        $collection = Mage::getModel('cms/block')->getCollection()->addStoreFilter($store->getId());
        $this->setCollection($collection);
        return parent::_prepareCollection();
      }

      protected function _prepareColumns() {

        $this->addColumn('title', array(
            'header' => Mage::helper('cms')->__('Title'),
            'align' => 'left',
            'index' => 'title',
            'width' => '25%',
        ));

        $this->addColumn('identifier', array(
            'header' => Mage::helper('cms')->__('Identifier'),
            'align' => 'left',
            'index' => 'identifier',
            'width' => '20%',
        ));

        …

        return parent::_prepareColumns();
      }

      public function getGridUrl() {
        return $this->getUrl('*/*', array('_current' => true));
      }

      public function getRowUrl($row) {
        return '"';
      }

      protected function _prepareMassaction() {
        $this->setMassactionIdField('entity_id');
        $this->getMassactionBlock()->setFormFieldName('gl_block_ids[]');
        $this->getMassactionBlock()->addItem('add', array(
            'label' => ‘Do some stuff’,
            'url' => $this->getUrl('*/*/massAdd'),
        ));
        return $this;
      }

}

controlador:

class TP_CustomApp_Adminhtml_GlcategoryController extends Mage_Adminhtml_Controller_Action {

  public function indexAction() {
    $this->loadLayout();
    $this->_setActiveMenu(‘MyApp/do_something’);
    $this->renderLayout();
  }

  public function gridAction(){
    $this->loadLayout();
    $this->getResponse()->setBody(
        $this->getLayout()->createBlock('MyApp/adminhtml_glcategory_grid')->toHtml()
    );
  }

  public function filterAction() {
    $post = $this->getRequest()->getPost();
    $radio = $post['filter'];
    Mage::getSingleton('core/session')->unsCategoryFilter();
    Mage::getSingleton('core/session')->setCategoryFilter($radio);
    $store = $post['store_id'];
    if ($store != '') {
      $this->_redirect('MyApp/adminhtml_glcategory', array('_query' => array('store' => $store)));
      return $this;
    }
    else {
      $this->_redirect('*/*');
      return $this;
    }
  }

  public function massAddAction() {
    $post = $this->getRequest()->getPost();
    $selected_category_ids = $post['gl_category_ids'];
    if (count($selected_category_ids) > 0) {
      // do some stuff with the ids
      return $this;
    }
    else {
      Mage::getSingleton('adminhtml/session')->addError('Please select a record.');
      $this->_redirect('*/*');
      return $this;
    }
  }

}

¿Fue útil?

Solución

Falta el nombre de la acción en su método getGridUrl()

public function getGridUrl() { 
      return $this->getUrl('*/*/grid', array('_current' => true)); 
} 

Editar: Cambie su gridAction() como a continuación

public function gridAction(){
    $this->loadLayout();
    $this->renderLayout();
}

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top