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:
user_id.....................img_url
(id of user, primary).............(image name, text)
and edit config.xml
in (app\code\community\Manthan\Marketplace\etc\config.xml
):
<models>
<marketplace>
<class>Manthan_Marketplace_Model</class>
<resourceModel>marketplace_mysql4</resourceModel>
</marketplace>
<marketplace_mysql4>
<class>Manthan_Marketplace_Model_Mysql4</class>
<entities>
<seller>
<table>manthan_marketplace_seller</table>
</seller>
<photos>
<table>manthan_marketplace_photos</table><= I add this code
</photos>
<vendorproduct>
<table>manthan_marketplace_vendorproduct</table>
</vendorproduct>
<review>
<table>manthan_marketplace_review</table>
</review>
<rating>
<table>manthan_marketplace_rating</table>
</rating>
<sellerrate>
<table>manthan_marketplace_seller_rated</table>
</sellerrate>
<payment>
<table>manthan_marketplace_payment</table>
</payment>
</entities>
</marketplace_mysql4>
</models>
<resources>
<marketplace_setup>
<setup>
<module>Manthan_Marketplace</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</marketplace_setup>
<marketplace_write>
<connection>
<use>core_write</use>
</connection>
</marketplace_write>
<marketplace_read>
<connection>
<use>core_read</use>
</connection>
</marketplace_read>
</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() {
$this->_init("marketplace/photos");
}
}
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() {
$this->_init('marketplace/photos');
}
}
now when i use tis code :
$img = Mage::getModel('marketplace/photos');
var_dump($img);
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:
$result=$img->getCollection()->getData();
return:
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!!