|
Hi everybody!
I need to create a new controller on app/code/local/MyCompany/Catalog/controllers
I have tried out this acrticle:
http://www.magentocommerce.com/boards/viewthread/15914/
I can override an existing method on existing controller,
but failed to add new method on my controller.
The case:
1. Created app\code\local\MyCompany\Catalog\controllers\ProductController.php
class MyCompany_Catalog_ProductController extends Mage_Catalog_ProductController { public function viewAction() { exit('viewAction executed'); } public function fabricAction() { exit('fabricAction executed'); } }
2. Created app\code\local\MyCompany\Catalog\etc\config.xml
<modules> <MyCompany_Catalog> <version>0.0.1</version> <depends></depends> </MyCompany_Catalog> </modules> <global> <routers> <catalog> <rewrite> <product> <to>MyCompany_Catalog/product</to> <override_actions>true</override_actions> <actions> <view><to>MyCompany_Catalog/product/view</to></view> <fabric>MyCompany_Catalog/product/fabric</fabric> </actions> </product> </rewrite> </catalog> </routers> <global>
<frontend> <routers> <mycompany_catalog_routes> <use>standard</use> <args> <module>MyCompany_Catalog</module> <frontName>mycompany_catalog_routes</frontName> </args> </mycompany_catalog_routes> </routers> <events></events> <translate></translate> <layout></layout> </frontend> </modules> ]
As result of my code, i can override view method on ProductController
and see “viewAction executed” on http://myhost/index.php/catalog/product/view
But new method “fabric” do not work and when access to http://myhost/index.php/catalog/product/fabric,
i got “404 Not Found” error.
My question is:
1. how to create new method on MyCompany\Catalog\controllers\ProductController.php ?
2. how to create new controller, i.e MyCompany\Catalog\controllers\MyProductController.php ?
Anybody can help me?
Thanks a lot!
|