3

Ok. Getting a strange one here. Creating custom module with multiple grid pages. First grid works 100% no problems, but all others failing with

Call to a member function setSaveParametersInSession() on boolean

I have gone through the suggestions here, which all seem to point toward the _blockGroup and _controller references not pointing to the correct location for the Grid.php block file, but so far as I can see, they are pointing correctly. Given that the first grid works fine, and the others have been created using the exact same template, I'm now rather baffled. A second pair of eyes on the code might help?

config.xml (blocks snippet)

`<global>
    <blocks>
        <rmaassistant>
            <class>FullFlow_RMAAssistant_Block</class>
        </rmaassistant>
    </blocks>
</global>`

Here is the block that works..

app/code/local/FullFlow/RMAAssistant/controllers/Adminhtml/CaseController.php

class FullFlow_RMAAssistant_Adminhtml_CaseController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->_addContent($this->getLayout()->createBlock('rmaassistant/adminhtml_case_items'));
        $this->renderLayout();
    }
}

app/code/local/FullFlow/RMAAssistant/Block/Adminhtml/Case/Items.php

class FullFlow_RMAAssistant_Block_Adminhtml_Case_Items extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_blockGroup = 'rmaassistant';
        $this->_controller = 'adminhtml_case_items';
        $this->_headerText = Mage::helper('adminhtml')->__('RMA Assistant - Cases');
        parent::__construct();
        $this->_removeButton('add');
    }
}

app/code/local/FullFlow/RMAAssistant/Block/Adminhtml/Case/Items/Grid.php

class FullFlow_RMAAssistant_Block_Adminhtml_Case_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('case_items');
        $this->setDefaultSort('case_id');
    }

    protected function _customerNameCondition($collection, $column)
    {
        if(!$value = trim($column->getFilter()->getValue()))
        {
            return;
        }
        if(is_numeric($value))
        {
            $this->getCollection()->addCustomersToFilter($value);
        }
        else
        {
            $inputKeywords = explode(' ' , $value);
            $customerIds = array();

            foreach(Mage::getModel('rmaassistant/case')->getCollection()->addCustomerNameToSelect() as $key => $item)
            {
                if(in_array($item->getCustomerId(), $customerIds))
                {
                    continue;
                }
                $fullname = trim($item->getFullname());
                $match = false;
                if(count($inputKeywords) > 1)
                {
                    foreach($inputKeywords as $keyword)
                    {
                        if(strstr($fullname, $keyword))
                        {
                            $match = true;
                        }
                    }
                }
                else
                {
                    $firstname = trim($item->getFirstname());
                    $lastname = trim($item->getLastname());
                    if(strstr(strtolower($firstname), strtolower($value)) || strstr(strtolower($lastname), strtolower($value)) || strstr(strtolower($fullname), strtolower($value)))
                    {
                        $match = true;
                    }
                }
                if($match)
                {
                    $customerIds[] = $item->getCustomerId();
                }
            }
            if(!empty($customerIds))
            {
                $this->getCollection()->addCustomersToFilter($customerIds);
            }
        }
    }

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

    protected function _prepareColumns()
    {
        $this->addColumn('id', array(
            'header' => Mage::helper('rmaassistant')->__('Case ID'),
            'sortable' => true,
            'width' => '60',
            'index' => 'case_id'
        ));
        $this->addColumn('reference', array(
            'header' => Mage::helper('rmaassistant')->__('Reference'),
            'sortable' => true,
            'width' => '100',
            'index' => 'reference',
            'type' => 'varchar'
        ));
        $this->addColumn('fullname', array(
            'header' => Mage::helper('rmaassistant')->__('Customer'),
            'sortable' => true,
            'index' => 'customer_id',
            'format' => '$fullname',
            'filter_condition_callback' => array($this, '_customerNameCondition')
        ));
        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }


}

Above works fine (I have omitted Model files as I'm pretty sure these are not the cause. The following is another much simpler grid, which fails.

app/code/local/FullFlow/RMAAssistant/controllers/Adminhtml/OrdersourceController.php

class FullFlow_RMAAssistant_Adminhtml_OrdersourceController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->_addContent($this->getLayout()->createBlock('rmaassistant/adminhtml_ordersource_items'));
        $this->renderLayout();
    }
}

app/code/local/FullFlow/RMAAssistant/Block/Ordersource/Items.php

class FullFlow_RMAAssistant_Block_Adminhtml_Ordersource_Items extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_blockGroup = 'rmaassistant';
        $this->_controller = 'adminhtml_ordersource_items';
        $this->_headerText = Mage::helper('adminhtml')->__('RMA Assistant - Settings - Order Sources Maintenance');
        parent::__construct();
        $this->_removeButton('add');
    }
}

app/code/local/FullFlow/RMAAssistant/Block/Ordersource/Items/Grid.php

class FullFlow_RMAAssistant_Block_Adminhtml_Ordersource_Items_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('ordersource_items');
        $this->defaultSort('order_source_id');
    }

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

    protected function _prepareColumns()
    {
        $this->addColumn('id', array(
            'header' => Mage::helper('rmaassistant')->__('Order Source ID'),
            'sortable' => true,
            'width' => '60',
            'index' => 'order_source_id'));
        $this->addColumn('admin_label', array(
            'header' => Mage::helper('rmaassistant')->__('Admin Label'),
            'sortable' => true, 
            'width' => '100',
            'index' => 'admin_label',
            'type' => 'varchar'));
        $this->addColumn('frontend_label', array(
            'header' => Mage::helper('rmaassistant')->__('Frontend Label'),
            'sortable' => true,
            'width' => '100',
            'index' => 'frontend_label',
            'type' => 'varchar'));
        return parent::_prepareColumns();
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }
}

Any ideas?