I am new with Magento. And trying to create my own model.
So I start with a small test
The model folder structure as the following:
FirstStore/Demo/block
FirstStore/Demo/etc/config.xml
FirstStore/Demo/controller
FirstStore/Demo/Model/Product.php
FirstStore/Demo/Helper
FirstStore/Demo/sql
the etc/config.xml
code:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<version>0.0.1</version>
</modules>
</config>
and the Model/Product.php
code:
class FirstStore_Demo_Model_Product
{
public function sayhello(){
echo 'Hello , World with Magento';
}
}
and the app/etc/modules/FirstStore_Demo.xml
code:
<?xml version="1.0"?>
<config>
<modules>
<FirstStore_Demo>
<active>true</active>
<codePool>local</codePool>
</FirstStore_Demo>
</modules>
</config>
finally I am running this code under test.php page at the magento root dir
the test.php
code:
require_once 'app/Mage.php';
Mage::app();
$product = new FirstStore_Demo_Model_Product;
$product->sayhello();
the error at localhost/magento/test.php
is:
Fatal error: Class 'FirstStore_Demo_Model_Product' not found in C:\xampp\htdocs\php\magento\test.php
FirstStore
folder located inapp/code/local
or at leastapp/code/community
?config.xml
with<?xml version="1.0" encoding="UTF-8"?> <config> <FirstStore_Demo> <modules> <version>0.0.1</version> </modules> </FirstStore_Demo> <global><models><firststore_demo><class>FirstStore_Demo_Model</class></firststore_demo></models></global> </config>
and call the model with$product = Mage::getModel('firststore_demo/product');
to see what happensapp/code/local
$product = Mage::getModel('FirstStore_Demo/Product'); $product->sayhello();
Hackathon
orAitoc
?