Hi i build a indexcontrollor in module brand like this
class Blank_Brand_IndexController extends Mage_Core_Controller开发者_如何学Go_Front_Action
{
public function indexAction()
{
echo 'Foo Index Action';
$this->addaction();
}
public function addAction()
{
echo 'Foo add Action';
$this->deleteAction();
}
}
When I put in the address: http://www.myshop.com/index.php/brand/
, it echos Foo Index Action
With this URL, though, it does nothing: http://www.myshop.com/index.php/brand/add
What could be the problem here causing this? This could save a lot of problems for me which I have with URL rewriting in Magento!
It's a common oversight.
This url
http://www.myshop.com/index.php/brand/
is equivalent to this url
http://www.myshop.com/index.php/brand/index/index
The URI portion "brand" is your module. The first "index" URI portion is your controller, the second "index" URI portion is your action method.
Module: brand
Controller: index
Action: index
So, let's consider this URL
http://www.myshop.com/index.php/brand/add
This is equivalent to
http://www.myshop.com/index.php/brand/add/index
Which gives us
Module: brand
Controller: add
Action: index
The URL you're trying to call is looking for a controller named
class Blank_Brand_AddController ....
When it doesn't find one, it reports back 404.
If you wanted to call the addAction
method on your index controller, you'd want the following URL
http://www.myshop.com/index.php/brand/index/add
I wrote an article on this - perhaps it would help: http://prattski.com/2010/06/24/magento-overriding-core-files-blocks-models-resources-controllers/
精彩评论