0

I have a custom grid that shows all the CMS Blocks. When I use the search bar in the grid to filter out a title it redirects me to a 404 page. Is there something wrong with my grid to cause the redirect to an unknown page?

Also, not sure if it matters but this is happening on Enterprise Edition 1.12. I have another instance that is EE-1.13, which this is not an issue.

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;
      }

}

Controller:

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;
    }
  }

}
  • 1
    I think you miss the gridAction in your controller – MeenakshiSundaram R Apr 9 '15 at 4:17
  • I added a gridAction, which it didn't have before, but still getting a 404. – dnelson Apr 9 '15 at 4:39
  • Show your controller file – MeenakshiSundaram R Apr 9 '15 at 4:42
  • I have added the controller. – dnelson Apr 9 '15 at 5:06
1

The action name is missing in your getGridUrl() method

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

Edit : Change your gridAction() like below

public function gridAction(){
    $this->loadLayout();
    $this->renderLayout();
}
| improve this answer | |
  • The search works, but when the page loads there is only a simple grid display and no CSS styling or menus. Problem with the gridAction()? – dnelson Apr 9 '15 at 5:42
  • I have updated my answer. – MeenakshiSundaram R Apr 9 '15 at 6:18
  • Thanks for the help, but now the grid has disappeared and the menus are shown when Filtering. Here is what the url looks like site_url.com/index.php/admin/custom_app/adminhtml_glcmsblock/grid/product_filter/[long_text_of_random_letters]/internal_gl_block_ids[]//form_key/19lHJZ9ZTIvKP4Ob/ – dnelson Apr 9 '15 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.