0

Hi I am developing a module & creating a custom admin grid by following this inchoo article http://inchoo.net/magento/how-to-create-a-custom-grid-from-scratch/
but it's not working just blank screen in content area enter image description here

my code is here

Ooorza/PaypalAdaptivePayment/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Ooorza_PaypalAdaptivePayment>
            <version>1.0.6</version>
        </Ooorza_PaypalAdaptivePayment>
    </modules>
    <global>
        <models>
      <paypaladaptivepayment>
        <class>Ooorza_PaypalAdaptivePayment_Model</class>
        <resourceModel>paypaladaptivepayment_mysql4</resourceModel>
      </paypaladaptivepayment>
      <paypaladaptivepayment_mysql4>
        <class>Ooorza_PaypalAdaptivePayment_Model_Mysql4</class>
        <entities>        
              <paytransaction>
                <table>ooorza_adaptivepayment_paytransaction</table>
              </paytransaction>
        </entities>
      </paypaladaptivepayment_mysql4>
    </models>

        <resources>
            <ooorza_paypaladaptivepayment_setup>
                <setup>
                    <module>Ooorza_PaypalAdaptivePayment</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </ooorza_paypaladaptivepayment_setup>
            <ooorza_paypaladaptivepayment_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </ooorza_paypaladaptivepayment_write>
            <ooorza_paypaladaptivepayment_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </ooorza_paypaladaptivepayment_read>
        </resources>

        <helpers>
            <paypaladaptivepayment>
                <class>Ooorza_PaypalAdaptivePayment_Helper</class>
            </paypaladaptivepayment>
        </helpers>

        <blocks>
            <paypaladaptivepayment>
                <class>Ooorza_PaypalAdaptivePayment_Block</class>
            </paypaladaptivepayment>            
        </blocks>


    <frontend>
        <routers>
            <paypaladaptivepayment>
                <use>standard</use>
                <args>
                    <module>Ooorza_PaypalAdaptivePayment</module>
                    <frontName>paypaladaptivepayment</frontName>
                </args>
            </paypaladaptivepayment>            
        </routers>

    </frontend>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <paypaladaptivepayment before="Mage_Adminhtml">Ooorza_PaypalAdaptivePayment_Adminhtml</paypaladaptivepayment>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

</config>

Ooorza/PaypalAdaptivePayment/Model/Paytransaction.php

<?php

class Ooorza_PaypalAdaptivePayment_Model_Paytransaction extends Mage_Core_Model_Abstract
{
    protected function _construct(){

       $this->_init("paypaladaptivepayment/paytransaction");

    }

}

Ooorza/PaypalAdaptivePayment/Model/Mysql4/Paytransaction.php

<?php
class Ooorza_PaypalAdaptivePayment_Model_Mysql4_Paytransaction extends Mage_Core_Model_Mysql4_Abstract
{
    protected function _construct()
    {
        $this->_init("paypaladaptivepayment/paytransaction", "pay_id");
    }
} 

Ooorza/PaypalAdaptivePayment/Model/Mysql4/Paytransaction/Collection.php

<?php
    class Ooorza_PaypalAdaptivePayment_Model_Mysql4_Paytransaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
    {

        public function _construct(){
            $this->_init("paypaladaptivepayment/paytransaction");
        }

    }

Ooorza/PaypalAdaptivePayment/controllers/Adminhtml/TransactionController.php

<?php

class Ooorza_PaypalAdaptivePayment_Adminhtml_TransactionController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        $this->_title($this->__('Transaction'))->_title($this->__('Adaptive Transaction'));
        $this->loadLayout();
        //$this->_setActiveMenu('paypaladaptivepayment/adaptivepayment');
        $this->_addContent($this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_adaptivepayment_transaction'));
        $this->renderLayout();

    }

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

    public function exportOoorzaCsvAction()
    {
        $fileName = 'adaptivepayment_transaction.csv';
        $grid = $this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_adaptivepayment_transaction_grid');
        $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
    }

    public function exportOoorzaExcelAction()
    {
        $fileName = 'adaptivepayment_transaction.xml';
        $grid = $this->getLayout()->createBlock('paypaladaptivepayment/adminhtml_adaptivepayment_transaction_grid');
        $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
    }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/AdaptivePayment/Transaction.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_AdaptivePayment_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_blockGroup = 'paypaladaptivepayment';
        $this->_controller = 'adminhtml_adaptivepayment_transaction';
        $this->_headerText = Mage::helper('paypaladaptivepayment')->__('paypaladaptivepayment Tranaction');
        parent::__construct();
        $this->_removeButton('add');
    }
}

Ooorza/PaypalAdaptivePayment/Block/Adminhtml/AdaptivePayment/Transaction/Grid.php

<?php

class Ooorza_PaypalAdaptivePayment_Block_Adminhtml_AdaptivePayment_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('adaptive_transaction');
        $this->setDefaultSort('pay_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
    }

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

    protected function _prepareColumns()
    {
        $this->addColumn('pay_id',
             array(
                    'header' => 'ID',
                    'align' =>'right',
                    'width' => '50px',
                    'index' => 'pay_id',
               ));
       $this->addColumn('order_id',
               array(
                    'header' => 'Order ID',
                    'align' =>'left',
                    'index' => 'order_id',
              ));
       $this->addColumn('transaction_id', array(
                    'header' => 'transaction id',
                    'align' =>'left',
                    'index' => 'transaction_id',
             ));
        $this->addColumn('paykey', array(
                     'header' => 'paykey',
                     'align' =>'left',
                     'index' => 'paykey',
          ));

        $this->addColumn('transaction_status', array(
                     'header' => 'transaction_status',
                     'align' =>'left',
                     'index' => 'transaction_status',
          ));

        $this->addColumn('currency', array(
                     'header' => 'currency',
                     'align' =>'left',
                     'index' => 'currency',
          ));

        $this->addColumn('amount', array(
                     'header' => 'amount',
                     'align' =>'left',
                     'index' => 'amount',
          ));

        $this->addColumn('vendor_mail', array(
                     'header' => 'vendor_mail',
                     'align' =>'left',
                     'index' => 'vendor_mail',
          ));

        $this->addColumn('sender_mail', array(
                     'header' => 'sender_mail',
                     'align' =>'left',
                     'index' => 'sender_mail',
          ));
         return parent::_prepareColumns();

    }

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

Thanks in advance

4
  • I think you made some mistakes in naming your classes / files etc. It's is very important this is correct and is the same everywhere otherwise things won't be recognized. For example sometimes i see you using Namespace_Modulename, Module_Namespace, you should decide what you use and use it everywhere correctly. I think you should change naming of your adminhtml controller.
    – FROSIT
    Jul 22 '15 at 13:02
  • Here's some references so help you solve your problems. Alan Storm and the boys an Inchoo write great guides for this. inchoo.net/magento/how-to-create-a-custom-grid-from-scratch
    – FROSIT
    Jul 22 '15 at 13:04
  • @FROSIT Module_Namespace is just mistake in question typing, but not in actual files, i already developing grid by following this inchoo article you describe
    – Dinesh
    Jul 22 '15 at 13:09
  • there is lot's of confusion/mistakes while changing Namesapce & Module name so i update question with actual name and proving more details about models , also include with suggestion of answer Marius but problem is same.
    – Dinesh
    Jul 23 '15 at 7:20
4

Your blocks are declared like this:

    <blocks>
        <modulename>
            <class>Namespace_Modulename_Block</class>
        </modulename>            
    </blocks>

but you call this in your controller

$this->getLayout()->createBlock('namespace_modulename/adminhtml_sales_order_grid')->toHtml()

so the block with the alias 'namespace_modulename/adminhtml_sales_order' does not exist.
it should be 'modulename/adminhtml_sales_order'.
But I bet that won't work either, because you have no block called Namespace_Module_Block_Adminhtml_Sales_Order.
I assume you want an instance of the block Namespace_Modulename_Block_Adminhtml_AdaptivePayment_Transaction.
for that use createBlock('modulename/adminhtml_adaptivePayment_transaction').

Also the grid block should not be in the file named Namespace/Modulename/Block/Adminhtml/AdaptivePayment/Transactions/Grid.php. it should be Namespace/Modulename/Block/Adminhtml/AdaptivePayment/Transaction/Grid.php. So Transaction (singular) instead of Transactions (plural)

0
0

Without looking too deeply, you have an error in your controller. You use namespace_modulename as the short name, but in the posted config.xml the shortname is modulename. As I said, I didn't look beyond that so you could have more problems.

<?php

class Module_Namespace_Adminhtml_TransactionController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        $this->loadLayout();
        $this->_addContent($this->getLayout()->createBlock('namespace_modulename/adminhtml_sales_order'));
        $this->renderLayout();
    }

I'd like to address a few other things I see in your question.

Loading blocks manually in the controller is fairly bad behaviour as it breaks extensibility. The old Magento code used to do this and some of the code still does this. Just because it's done like this in core doesn't make it good code. Instead you should be using the layout XML to build the page layouts. This will allow you and others to change the page layout at a later date via add-on XML that extends/modifies/removes blocks.

In your config.xml file you have config/global/resources//connection sections where you have boilerplate connection code that is 100% useless. The read/write/setup connections will default to the core/default connection without you adding that manually.

Again in your config.xml you use modulename_mysql4 while the mysql4 concept/name/label has been deprecated by Magento in the manner you are using. A more correct name in this case would be modulename_resource.

1
  • i also try resource instead of mysql4 but same problem, i also updated the question
    – Dinesh
    Jul 23 '15 at 7:18

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.