I use (Manthan_Marketplace) extension in my Magento store
I want to add a table to this extension
so create a custom table (photos) in Magento database with name:(manthan_marketplace_photos) Table photos structure:
(id of user, primary).............(image name, text)

and edit config.xml in (app\code\community\Manthan\Marketplace\etc\config.xml):

                   <table>manthan_marketplace_photos</table><= I add this code 
    </resources>..................some more code  

Then I create a Photos.php in (app\code\community\Manthan\Marketplace\Model):

class Manthan_Marketplace_Model_Photos extends Mage_Core_Model_Abstract {  
        protected function _construct() {


and create Photos.php in(app\code\community\Manthan\Marketplace\Model\Mysql4):

class Manthan_Marketplace_Model_Mysql4_Photos extends Mage_Core_Model_Resource_Db_Abstract {
    protected function _construct() {
        $this->_init('marketplace/photos', 'user_id');


and after that create Collection.php in(app\code\community\Manthan\Marketplace\Model\Mysql4\Photos):

class Manthan_Marketplace_Model_Mysql4_Photos_Collection extends Mage_Core_Model_Resource_Db_Abstract {
    public function _construct() {


now when i use tis code :

$img = Mage::getModel('marketplace/photos');

it return:

object(Manthan_Marketplace_Model_Photos)#60 (15) { ["_eventPrefix":protected]=> string(13) "core_abstract" ["_eventObject":protected]=> string(6) "object" ["_resourceName":protected]=> string(18) "marketplace/photos" ["_resource":protected]=> NULL ["_resourceCollectionName":protected]=> string(29) "marketplace/photos_collection" ["_cacheTag":protected]=> bool(false) ["_dataSaveAllowed":protected]=> bool(true) ["_isObjectNew":protected]=> NULL ["_data":protected]=> array(0) { } ["_hasDataChanges":protected]=> bool(false) ["_origData":protected]=> NULL ["_idFieldName":protected]=> NULL ["_isDeleted":protected]=> bool(false) ["_oldFieldsMap":protected]=> array(0) { } ["_syncFieldsMap":protected]=> array(0) { } }

but when i use this code:



Call to undefined method Manthan_Marketplace_Model_Mysql4_Photos_Collection::getData()

why getData() is undefined for this one but is ok for another model?
thanks a lot for your help!!

2 Answers 2


Because your collection should extend Mage_Core_Model_Resource_Db_Collection_Abstract, not Mage_Core_Model_Resource_Db_Abstract.

But be careful with Collection::getData(). I described the pitfalls with this method here: How to correctly select the first item from a filtered collection?

getData() on collections works different from other methods. It does not check if the collection is loaded, instead it checks if the _data property is empty. When you load a collection, _data is not populated, only when you call getData()!


This results in a second database query as soon as you call getData() and this time, your new filter is applied. But it does not change the _items property, so your previously loaded result is still used for everything else.

By the way, I still did not come across any reasonable use case for this method. It's used internally by load() but probably should not have been public. The core doesn't use it from outside the collection class anywhere as far as I see.

Use getItems() instead to inspect the items of the collection.


Try updating app\code\community\Manthan\Marketplace\Model\Mysql4\Photos.php

class Manthan_Marketplace_Model_Mysql4_Photos extends Mage_Core_Model_Mysql4_Abstract {
    protected function _construct() {
        $this->_init('marketplace/photos', 'user_id');


And app\code\community\Manthan\Marketplace\Model\Mysql4\Photos\Collection.php

class Manthan_Marketplace_Model_Mysql4_Photos_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
    public function _construct() {


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.