app/etc/modules/Nat_Products.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Nat_Products>
<active>true</active>
<codePool>local</codePool>
</Nat_Products>
</modules>
</config>
=====
app/code/local/Nat/Products/etc/config.xmlapp/etc/modules/Nat_Products.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Nat_Products>
<version>0.1.0</version>
</Nat_Products>
</modules>
<global>
<models>
<nat_products>
<class>Nat_Products_Model</class>
</nat_products>
</models>
</global>
<frontend>
<routers>
<addproduct>
<use>standard</use>
<args>
<module>Nat_Products</module>
<frontName>addproduct</frontName>
</args>
</addproduct>
</routers>
</frontend>
</config>
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Nat_Products>
<active>true</active>
<codePool>local</codePool>
</Nat_Products>
</modules>
</config>
app/code/local/Nat/Products/controllers/IndexController.phpapp/code/local/Nat/Products/etc/config.xml
<?xml version="1.0" encoding="UTF-8"? >
<config >
<modules >
<Nat_Products >
<version >0.1.0</version >
</Nat_Products >
</modules >
<global >
<models >
<nat_products >
<class >Nat_Products_Model</class >
</nat_products >
</models >
</global >
<frontend >
<routers >
<addproduct >
<use >standard</use >
<args >
<module >Nat_Products</module >
<frontName >addproduct</frontName >
</args >
</addproduct >
</routers >
</frontend >
</config >
<?php=====
class Nat_Products_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {app/code/local/Nat/Products/controllers/IndexController.php
<?php
class Nat_Products_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
echo 'Hello World from ' . __CLASS__ . "<br\>";
$product = Mage::getModel("products/addproduct"); // returns false
echo $product->hello();
}
}
}
=====
app/code/local/Nat/Products/Model/Addproduct.php
<?php
class Nat_Products_Model_Addproduct extends Mage_Core_Model_Abstract
{app/code/local/Nat/Products/Model/Addproduct.php
<?php
class Nat_Products_Model_Addproduct extends Mage_Core_Model_Abstract
{
public function hello()
{
return "hello world from " .__CLASS__;
}
}
}
Hello World from Nat_Products_IndexController
( ! ) Fatal error: Call to a member function hello() on a non-object in maglocal.com\app\code\local\Nat\Products\controllers\IndexController.php on line 9
Hello World from Nat_Products_IndexController ( ! ) Fatal error: Call to a member function hello() on a non-object in maglocal.com\app\code\local\Nat\Products\controllers\IndexController.php on line 9