0

I have created a custom module with the form and form is saving the data to DB perfectly now i want to show all the data in my admin Grid custom page.

I have tried it but when ever i visit the page it goes to 404

Here is my review.xml file where i defined the menu in the directory app > design > adminhtml > default > default > layout with the following code in it:

 <? xml version = "1.0" ?>
  <layout version="0.1.0">
     <reviewmycompany_adminhtml_review_index>
         <reference name="content">
           <block type="reviewmycompany/adminhtml_review" name="review" />
           </reference>
     </reviewmycompany_adminhtml_review_index>
   </layout>  

And have my ReviewController.php in app > code > community > OptFirst > ReviewMyCompany > controllers > adminhtml with the following code:

       <?php

     class OptFirst_ReviewMyCompany_Adminhtml_ReviewController extends Mage_Adminhtml_Controller_action
         {

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

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

}

And my Review.php file in app > code > community > OptFirst > ReviewMyCompany > Block > adminhtml as follows

      <?php
       class OptFirst_ReviewMyCompany_Block_Adminhtml_Review extends Mage_Adminhtml_Block_Widget_Grid_Container
        {
         public function __construct()
          {
          $this->_controller = 'adminhtml_review';
          $this->_blockGroup = 'review';
          $this->_headerText =  Mage::helper('optfirst_reviewmycompany')->__('Manage Social Icons');
          $this->_addButtonLabel = Mage::helper('optfirst_reviewmycompany')->__('Add Employee');
           parent::__construct();
        }
     }

And My Grid.php files in app > code > community > OptFirst > ReviewMyCompany > Block > adminhtml >Review with the following code:

<?php

     class OptFirst_ReviewMyCompany_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_Block_Widget_Grid
      {
      public function __construct()
        {
    parent::__construct();
    $this->setId('reviewGrid');
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
}

protected function _prepareCollection()
{
    $collection = Mage::getModel('optfirst_reviewmycompany/review')->getCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns()
{
    $this->addColumn('id', array(
      'header'    => Mage::helper('reviewmycompany')->__('ID'),
      'align'     =>'right',
      'width'     => '10px',
      'index'     => 'id',
    ));

    $this->addColumn('name', array(
      'header'    => Mage::helper('reviewmycompany')->__('Name'),
      'align'     =>'left',
      'index'     => 'name',
      'width'     => '50px',
    ));


    $this->addColumn('content', array(
        'header'    =>     Mage::helper('reviewmycompany')->__('Description'),
        'width'     => '150px',
        'index'     => 'content',
    ));
    return parent::_prepareColumns();
 }

}

So can you please look into this and let me know why it all happening why its going to 404?

Thanks!

1 Answer 1

0

In the SUPEE-6788 Magento changed the admin routing to stop plugin vendors defining there own frontname. i.e. all admin routes must now be under the admin route rather than a user defined route. Any custom admin routes will 404.

To test if this is the case you can enable compatibility mode in the admin System > Configuration > Advanced > Admin. If your module then starts working you will know that this is the issue.

Here's another post describing the issue in detail How to update admin routers of custom module for patch SUPEE-6788

The layout xml node is based on the admin route url.

<layout version="0.1.0">
    <reviewmycompany_adminhtml_review_index>
        <reference name="content">
           <block type="reviewmycompany/adminhtml_review" name="review" />
        </reference>
    </reviewmycompany_adminhtml_review_index>
</layout>

reviewmycompany_adminhtml_review_index

should be

adminhtml_reviewmycompany_review_index

But you'll need to check your config in config.xml admin route node

<admin>
    <route>

    </route>
</admin>
17
  • my admin routes in config.xml is like this: <admin> <routers> <adminhtml> <args> <modules> <optfirst_reviewmycompany after="Mage_Adminhtml">OptFirst_ReviewMyCompany_Adminhtml</optfirst_reviewmycompany> </modules> </args> </adminhtml> </routers> </admin>
    – Xabby
    Nov 26, 2016 at 11:14
  • Well that looks okay. I'd try changing your layout xml node from reviewmycompany_adminhtml_review_index to adminhtml_reviewmycompany_review_index
    – RichieJP81
    Nov 26, 2016 at 11:56
  • Thats fixed .. Now Grid is not loading and not showing any data on the page, instead of it showing blank white page.. @Weaves81
    – Xabby
    Nov 26, 2016 at 13:46
  • Ah yep see the issue there. Within layout XML content section you have a block type reviewmycompany/adminhtml_review try changing that to adminhtml/reviewcompany_review for the same reason that we changed the node
    – RichieJP81
    Nov 26, 2016 at 14:28
  • SO for what reason now its not showing grid container? but when i echo any thing in my controller index method it print, but not the grid
    – Xabby
    Nov 26, 2016 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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