Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Create a new model
 
ESSUA
Member
 
Avatar
Total Posts:  34
Joined:  2008-12-20
 

Hello, can any body help me?
I want to create a new module for Magento. I create a controllers, but have a very big problems with model.
My steps:
I create a folder /app/core/code/Mage/AdminHtml/controllers/Ebay
In that folder I have a file:
TransferController.php

<?php
class Mage_Adminhtml_Ebay_TransferController extends Mage_Adminhtml_Controller_Action
{
protected function _construct()
    
{
    }
    
function _initTransfer()
    
{
    }
    
public function newAction()
    
{
        $this
->loadLayout();
        
$this->_setActiveMenu('catalog/products');
        
$model Mage::getModel('ebay/ebay')->getDataForSave();
                
$this->renderLayout();
    
}  
    
protected function _isAllowed()
    
{
        
return Mage::getSingleton('admin/session')->isAllowed('ebay/ebay');
    
}
}

I create a folder /app/core/code/Mage/Ebay
In this folder i have: etc folder with config.xml file:

<?xml version="1.0"?>
<config>
    <
modules>
        <
Mage_Ebay>
            <
version>0.8.0</version>
        </
Mage_Ebay>
    </
modules>
    <global>
        <
models>
            <
ebay>
                <class>
Mage_Ebay_Model</class>
                <
resourceModel>ebay_mysql4</resourceModel>
            </
ebay>
            <
ebay_mysql4>
                <class>
Mage_Ebay_Model_Mysql4</class>
                <
entities>
                    <
info>
                        <
table>ebay</table>
                    </
info>
                </
entities>
            </
ebay_mysql4>
        </
models>
        <
resources>
            <
ebay_setup>
                <
setup>
                    <
module>Mage_Ebay</module>
                </
setup>
                <
connection>
                    <use>
core_setup</use>
                </
connection>
            </
ebay_setup>
            <
ebay_write>
                <
connection>
                    <use>
core_write</use>
                </
connection>
            </
ebay_write>
            <
ebay_read>
                <
connection>
                    <use>
core_read</use>
                </
connection>
            </
ebay_read>
        </
resources>
    </global>
</
config>

And MODEL folder with this structure:

Ebay/Model/
                      
Ebay.php
                      Mysql4
                                       Ebay
                                       Collection
.php
First Ebay.php file:
<?php 
class Mage_Ebay_Model_Ebay extends Mage_Core_Model_Abstract
{
    
protected function _construct()
    
{
        $this
->_init('ebay/ebay');
        
$init $this->_getResource('ebay/ebay');
        
var_dump($init);
    
}
}
?>

Mysql/Ebay.php

<?php

class Mage_Ebay_Model_Mysql4_Ebay extends Mage_Core_Model_Mysql4_Abstract
{
protected function _construct() 
    
{
        $this
->_init('ebay/ebay''site_id');
    
}
}
?>
Collection.php
<?php
class Mage_Ebay_Model_Mysql4_Ebay_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
   
protected function _construct()
    
{
        $this
->_init('ebay/ebay');
    
}
}

After all this when I load

magento.com/admin/ebay_transfer/new
Look at First Ebay.php file
I make
$this->_init('ebay/ebay');
        
$init $this->_getResource('ebay/ebay');
        
var_dump($init);

But in the screen I see bool(false). How I understand there is someting wrong when i initialized model
Can some one help me?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top