0

my config.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Epage_Developer>
      <version>1.6.0</version>
    </Epage_Developer>
  </modules>
  <frontend>
    <routers>
      <developer>
        <use>standard</use>
        <args>
          <module>Epage_Developer</module>
          <frontName>developer</frontName>
        </args>
      </developer>
    </routers>
    <layout>
      <updates>
        <developer>
          <file>developer.xml</file>
        </developer>
      </updates>
    </layout>
  </frontend>
  <admin> 
    <routers>
      <developer>
        <use>admin</use>
        <args>
          <module>Epage_Developer</module>
          <frontName>admin_developer</frontName>
        </args>
      </developer>
      <adminhtml>
        <args>
          <modules>
            <developer before="Mage_Adminhtml">Epage_Developer_Adminhtml</developer>
          </modules>
        </args>
      </adminhtml>
    </routers>
  </admin>
  <global>
    <models>
      <developer>
        <class>Epage_Developer_Model</class>
        <resourceModel>developer_resource</resourceModel>
      </developer>
      <developer_resource>
        <class>Epage_Developer_Model_Resource</class>
        <entities>
          <developer>
            <table>developer</table>
          </developer>
        </entities>
      </developer_resource>
    </models>
    <resources>
      <developer_setup>
        <setup>
          <module>Epage_Developer</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </developer_setup>
      <developer_write>
        <connection>
          <use>core_write</use>
        </connection>
      </developer_write>
      <developer_read>
        <connection>
          <use>core_read</use>
        </connection>
      </developer_read>
    </resources> 
    <blocks>
      <developer>
        <class>Epage_Developer_Block</class>
      </developer>
    </blocks>
    <helpers>
      <developer>
        <class>Epage_Developer_Helper</class>
      </developer>
    </helpers>
  </global>
  <adminhtml>
    <menu>
      <developer module="developer">
        <title>developer</title>
        <sort_order>100</sort_order>
        <children>
          <developer module="developer">
            <title>Manage Developer</title>
            <sort_order>0</sort_order>
            <action>admin_developer/adminhtml_developer</action>
          </developer>
        </children>
      </developer>
    </menu>
    <acl>
      <resources>
        <all>
          <title>Alloe Everything</title> 
        </all>
        <admin>
          <children>
            <developer translate="title" module="developer">
              <title>developer</title>
              <sort_order>1000</sort_order>
              <children>
                <developer translate="title">
                  <title>Manage Developer</title>
                  <sort_order>0</sort_order>
                </developer>
              </children>
            </developer>
          </children>
        </admin>
      </resources>
    </acl>
    <layout>
      <updates>
        <developer>
          <file>developer.xml</file>
        </developer>
      </updates>
    </layout>
  </adminhtml>
</config>

Local/Epage/Developer/Model/Developer.php

class Epage_Developer_Model_Developer extends Mage_Core_Model_Abstract {

  protected function _construct() { 
    parent::_construct ();
    $this->_init('developer/developer');
  }

  public function savedeveloper($developer){
    $enquireCollection = Mage::getModel('developer/developer');
    $enquireCollection->settitle($developer['title']);
    $enquireCollection->setcontent($developer['content']);
    $enquireCollection->setstatus($developer['status']);
    return $enquireCollection->save();
  }

}

Model/Resource/Developer.php

class Epage_Developer_Model_Resource_Developer extends Mage_Core_Model_Resource_Db_Abstract{

  protected function _construct() {
    $this->_init('developer/developer', 'developer_id');
  }

}

Model/Resource/Developer/Collection.php

 class Epage_Developer_Model_Resource_Developer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract { 
  protected function _construct() {
    //parent::_construct ();
    $this->_init('developer/developer');
  }

}

Block/Adminhtml/Developer/Grid.php

<?php 
class Epage_Developer_Block_Adminhtml_Developer_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {  
        parent::__construct();
        $this->setId('developer_Grid');
        $this->setDefaultSort('developer_id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);

    }/*
    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('developer/developer_collection')
                      ->addAttributeToSelect('title')
                      ->addAttributeToSelect('content')
                      ->addAttributeToSelect('status');

             $this->setCollection($collection);
             return parent::_prepareCollection();
    }*/

    protected function _prepareCollection()
    { 
        // Instantiate the collection of data to be display on the grid
        $collection = Mage::getResourceModel('developer/developer_collection')->getCollection()->addAttributeToSelect('*');
        var_dump($collection);
        foreach($collections as $collection) {
            echo $collection->getId();
        }
        $this->setCollection($collection);
        parent::_prepareCollection();
        return $this; 
    }
    protected function _prepareColumns()
    {
        $this->addColumn('developer_id', 
                array(
                        'header' => Mage::helper('developer')->__('ID'),
                        'align' => 'right',
                        'width' => '50px',
                        'index' => 'ID',
                ));
        $this->addColumn('title', 
                array(
                        'header' => Mage::helper('developer')->__('title'),
                        'align' => 'left',
                        'index' => 'title',
                ));
        $this->addColumn('content',
                array(
                        'header' => Mage::helper('developer')->__('content'),
                        'align' => 'left',
                        'index' => 'content',
                ));
        $this->addColumn('status', array(
                        'header'    => Mage::helper('developer')->__('Status'),
                        'width'     => '120',
                        'align'     => 'left',
                        'index'     => 'status',
                        'type'      => 'options',
                        'options'   => array(0 => $this->__('Disabled'), 1 => $this->__('Enabled')),
                        'frame_callback' => array($this, 'decorateStatus')
        ));
        $this->addExportType('*/*/exportCsv', Mage::helper('developer')->__('CSV'));
        $this->addExportType('*/*/exportXml', Mage::helper('developer')->__('XML'));
        return parent::_prepareColumns();
    }
    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('developer_id');
        $this->getMassactionBlock()->setFormFieldName('developer');

        $this->getMassactionBlock()->addItem('delete', array(
                'label'    => Mage::helper('developer')->__('Delete'),
                'url'      => $this->getUrl('*/*/massDelete'),
                'confirm'  => Mage::helper('developer')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('developer/developer')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
                'label'=> Mage::helper('developer')->__('Change status'),
                'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
                'additional' => array(
                        'visibility' => array(
                                'name' => 'status',
                                'type' => 'select',
                                'class' => 'required-entry',
                                'label' => Mage::helper('developer')->__('Status'),
                                'values' => $statuses
                        )
                )
        ));
        return $this;
    }
    protected function _preparePage()
    {
        $this->getCollection()->setPageSize($this->getParam($this->getVarNameLimit(), $this->_defaultLimit));
        $this->getCollection()->setCurPage($this->getParam($this->getVarNamePage(), $this->_defaultPage));
    }
    public function getRowUrl($row)
    {

        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }
    public function getGridUrl() {
        return $this->getUrl('*/*/developer_grid', array('developer_id'=> Mage::registry('developer_data')->getId(), '_current' => true));
    }
}
?>

which place is error please let know.

My error was this

Fatal error: Call to undefined method Epage_Developer_Model_Resource_Developer_Collection::getCollection() in C:\xampp\htdocs\magentos\app\code\local\Epage\Developer\Block\Adminhtml\Developer\Grid.php on line 27

0

2 Answers 2

1

try this code

$collection = Mage::getModel('developer/developer')->getCollection();
0

Block/Adminhtml/Developer/Grid.php

in your Grid.php Try changing below code

From

$collection = Mage::getResourceModel('developer/developer_collection')->getCollection()->addAttributeToSelect('*');

To

$collection = Mage::getResourceModel('developer/developer_collection')->addAttributeToSelect('*');

Your Answer

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

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