2

I have created a custom admin module and necessary assets. When I call getCollection using created model its giving me error

Warning: include(Company\Module\Model\Resource\Event\Collection.php): failed to open stream: No such file or directory  in C:\wamp\www\domain\lib\Varien\Autoload.php on line 93

#0 C:\wamp\www\domain\lib\Varien\Autoload.php(93): mageCoreErrorHandler(2, 'include(Fouraxi...', 'C:\\wamp\\www\\cra...', 93, Array)
#1 C:\wamp\www\domain\lib\Varien\Autoload.php(93): Varien_Autoload::autoload()
#2 [internal function]: Varien_Autoload->autoload(Company...')
#3 [internal function]: spl_autoload_call('Company...')
#4 C:\wamp\www\domain\app\code\core\Mage\Core\Model\Config.php(1346): class_exists('Company...')
#5 C:\wamp\www\domain\app\code\core\Mage\Core\Model\Config.php(1380): Mage_Core_Model_Config->getModelInstance('Module_res...', Object(Company_Module_Model_Resource_Event))
#6 C:\wamp\www\domain\app\Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('Module/eve...', Object(Company_Module_Model_Resource_Event))
#7 C:\wamp\www\domain\app\code\core\Mage\Core\Model\Abstract.php(208): Mage::getResourceModel('Module/eve...', Object(Company_Module_Model_Resource_Event))
#8 C:\wamp\www\domain\app\code\core\Mage\Core\Model\Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection()
#9 C:\wamp\www\domain\app\code\local\Company\Module\Block\Adminhtml\Print\Grid.php(7): Mage_Core_Model_Abstract->getCollection()
#10 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(626): Company_Module_Block_Adminhtml_Print_Grid->_prepareCollection()
#11 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php(632): Mage_Adminhtml_Block_Widget_Grid->_prepareGrid()
#12 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(918): Mage_Adminhtml_Block_Widget_Grid->_beforeToHtml()
#13 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#14 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('grid', true)
#15 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Widget\Grid\Container.php(77): Mage_Core_Block_Abstract->getChildHtml('grid')
#16 C:\wamp\www\domain\app\design\adminhtml\default\default\template\widget\grid\container.phtml(36): Mage_Adminhtml_Block_Widget_Grid_Container->getGridHtml()
#17 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(241): include('C:\\wamp\\www\\cra...')
#18 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml\\defau...')
#19 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#20 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Template.php(81): Mage_Core_Block_Template->_toHtml()
#21 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Widget\Container.php(308): Mage_Adminhtml_Block_Template->_toHtml()
#22 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Adminhtml_Block_Widget_Container->_toHtml()
#23 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#24 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#25 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#26 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#27 C:\wamp\www\domain\app\design\adminhtml\default\default\template\page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content')
#28 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(241): include('C:\\wamp\\www\\cra...')
#29 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml\\defau...')
#30 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Template.php(286): Mage_Core_Block_Template->renderView()
#31 C:\wamp\www\domain\app\code\core\Mage\Adminhtml\Block\Template.php(81): Mage_Core_Block_Template->_toHtml()
#32 C:\wamp\www\domain\app\code\core\Mage\Core\Block\Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#33 C:\wamp\www\domain\app\code\core\Mage\Core\Model\Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#34 C:\wamp\www\domain\app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput()
#35 C:\wamp\www\domain\app\code\local\Company\Module\controllers\Adminhtml\ModuleController.php(22): Mage_Core_Controller_Varien_Action->renderLayout()
#36 C:\wamp\www\domain\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Company_Module_Adminhtml_ModuleController->viewAction()
#37 C:\wamp\www\domain\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#38 C:\wamp\www\domain\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#39 C:\wamp\www\domain\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#40 C:\wamp\www\domain\app\Mage.php(684): Mage_Core_Model_App->run(Array)
#41 C:\wamp\www\domain\index.php(87): Mage::run('', 'store')
#42 {main}

config.xml

<models>
            <Module>
                <class>Company_Module_Model</class>
                <resourceModel>Module_resource</resourceModel>
            </Module>
            <Module_resource>
                <class>Company_Module_Model_Resource</class>
                <entities>
                    <event>
                        <table>Module_event_data</table>
                    </event>
                    <event_registrant>
                        <table>Module_event_registrant</table>
                    </event_registrant>
                </entities>
            </Module_resource>
        </models>
        <resources>
            <Module_setup>
                <setup>
                    <module>Company_Module</module>
                    <class>Mage_Core_Model_Resource_Setup</class>
                </setup>
            </Module_setup>
        </resources>
        <blocks>
            <Module>
                <class>Company_Module_Block</class>
            </Module>
        </blocks>

Grid Block

class Company_Module_Block_Adminhtml_Print_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    protected function _prepareCollection()
    {
        $collection = Mage::getModel('Module/event')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }
    protected function _prepareColumns()
    {
        $this->addColumn('order_id', array(
            'type'=>'text',
            'index'=>'name',
            'header'=>$this->__('Print Id')
        ));
        return parent::_prepareColumns();
    }
}

Edit:::

<?php

class Company_Module_Model_Resource_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
    public function _construct() {
        $this->_init('Module/event');
    }
}
  • did you create this file Fouraxissolutions\Casestation\Model\Resource\Event\Collection.php – Qaisar Satti Feb 11 '16 at 6:42
  • No. Is it necessary to create Collection.php when calling getCollection()? – Dushan Feb 11 '16 at 6:46
  • yes bro when you call casestation/event this will get collection from this file Spacename/Casestation/Model/Resource/Event/Collection.php – Qaisar Satti Feb 11 '16 at 6:48
1

the problem with missing the collection file

Module\Name\Model\Resource\Event\Collection.php

you need to create the collection file. because

when you call module/event this will get collection from this file Spacename/module/Model/Resource/Event/Collection.php

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.