Magento new component controller does not take effect or 404

Source: Internet
Author: User

Check for link errors

There are two possible link errors: spelling errors; the other is that store view code is added to the link in the background, but it is not written to the address bar during the test --

Check whether the component is enabled

Sometimes the component is not enabled for some reason, so the related controller is naturally unavailable. You can go to System/Configuration> ADVANCED/Advanced in the background to check whether the component exists in the list.

If the component is not opened, it is generally caused by spelling problems in the configuration file or program. In particular, 70% is caused by incorrect case sensitivity when it is locally available but put on the server --

Check the config. xml configuration file of the component.

Taking Native product components as an example, the frontend controller is configured as follows:

<Config>
...
<Frontend>
<Routers>
<Catalog>
<Use> standard </use>
<Args>
<Module> Mage_Catalog </module>
<FrontName> catalog </frontName>
</Args>
</Catalog>
</Routers>
</Frontend>
...
</Config>

If you need to override this controller, you can configure it as follows:

<Config>
...
<Frontend>
<Routers>
<Catalog>
<Args>
<Modules>
<Infinity_Catalog before = "Mage_Catalog"> Infinity_Catalog </Infinity_Catalog>
</Modules>
</Args>
</Catalog>
</Routers>
</Frontend>
...
</Config>
 

Check the file name, class name, and method name of the component and controller.

Magento's component directory contains two Controller-related folders: Controller and controllers. The former is generally used to define routing methods, and seems to be rarely used; the latter is where the controller is placed. Unlike other common components (Block, Helper, and Model), the first letter of the controller folder is lower-case, and there is a s at the end (would you really like to think about the architecture, is that a crush on small s, well, I know that you are "small" because the rewriting method is different from "big", and "s" is used to distinguish it from the Controller ).

The controller file name is


[Controller name (uppercase)] Controller. php

For example, the front-end controller of the native product is named ProductController. php. It is also different from other common components (Block, Helper, Model), with a Controller.

The controller class name is


[Namespace (uppercase letters)] _ [component name (uppercase letters)] _ [Controller name (uppercase letters)] Controller
For example, the front-end controller class of the native product is Mage_Catalog_ProductController. Unlike other common components (Block, Helper, and Model), the feature term "Controller" is placed at the end of the class name, rather than after the [component name.

The behavior method name is


[Behavior (lower-case)] Action

This method must be public and generally does not contain any parameter. For example, the method name on the detailed page of the native foreground product is defined as public function viewAction ().


Check by inserting code

Generally, the above steps can solve the problem. If the problem persists, you need to insert the log code in the following two methods to check whether the related modules, controllers, and behaviors have any problems.

Mage_Core_Controller_Varien_Router_Standard: match
Mage_Core_Controller_Varien_Front: dispatch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.