cancel
Showing results for 
Search instead for 
Did you mean: 

Magento custom modules model returns empty dataset

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Magento custom modules model returns empty dataset

I have created custom module.I'm trying to get data from model.

$suits = Mage::getModel('suits/suits');

config.xml

	         <models>
			<suits>
				<class>Bespoke_Suits_Model</class>
				<resourceModel>suits_resource</resourceModel>
			</suits>
			<suits_resource>
				<class>Bespoke_Suits_Model_Resource</class>
				<entities>
					<suits>
						<table>suits</table>
					</suits>
				</entities>
			</suits_resource>
		</models>
		<resources>
			<suits_setup>
				<setup>
					<module>Bespoke_Suits</module>
					<class>Bespoke_Suits_Model_Resource_Setup</class>
				</setup>
				<connection>
					<use>core_setup</use>
				</connection>
			</suits_setup>
			<suits_write>
				<connection>
					<use>core_write</use>
				</connection>
			</suits_write>
			<suits_read>
				<connection>
					<use>core_read</use>
				</connection>
			</suits_read>
		</resources>

Model/Resource/Suits.php

<?php

class Bespoke_Suits_Model_Resource_Suits extends Mage_Core_Model_Resource_Db_Abstract{
	
	public function _construct(){
		//parent::_construct();
		$this->_init('suits/suits','suits_id');
	}
}

Model/Suits.php

<?php

class Bespoke_Suits_Model_Suits extends Mage_Core_Model_Abstract{
	
	public function _construct(){
		parent::_construct();
		$this->_init('suits/suits');
	}
	
	public function load($id, $field=null){
		$resource =  $this->_getResource();
		if (!$resource) {
			throw new UnexpectedValueException('Resource instance is not available');
		}
		return parent::load($bespoke_id, $field);
	}	
	
	public function test(){
		echo "test!!";
	}
}

 

What could be the reason for this.My model is loading,only thing is not getting data from table.Please help me.

1 REPLY 1

Re: Magento custom modules model returns empty dataset

Problem solved.

Removed load() function from Model/Suits.php.