问题
I recently installed a clean version of Magento. I had a custom module what was working perfectly on the old one, but not on the new one(Both 1.9.2.1). It shows up under System->Configuration->Advanced->Advanced. When ever i try to call mydomain/index.php/cron. It will redirect to the 404 page. I tried to add the rest of the folders what are in tutorials : Block, Helper,model and sql. But no luck. As i said it is working on the older installation with the same version number. I just copied the whole module and the file to the etc folder.
Module structure:
- code
- local
- Mxsxs2
- Cron
- controllers
- IndexController.php
- etc
- config.xml
- controllers
- Cron
- Mxsxs2
- local
- etc
- modules
- Mxsxs2_Cron.xml
- modules
Files:
app/code/local/Mxsxs2/Cron/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Mxsxs2_Cron>
<version>1.0.0</version>
</Mxsxs2_Cron>
</modules>
<frontend>
<routers>
<cron>
<use>standard</use>
<args>
<module>Mxsxs2_Cron</module>
<frontName>cron</frontName>
</args>
</cron>
</routers>
</frontend>
</config>
app/code/local/Mxsxs2/Cron/controllers/IndexController.php
<?php
class Mxsxs2_Cron_IndexController extends Mage_Core_Controller_Front_Action
{
public $importfolder="var/import";
private $errormessages=array();
private $READ=null;
private $WRITE=null;
private $wasindb=0;
private $noofwarehouses=3; //for cost check
public function indexAction(){
echo("asd");
}
//----rest of the code and fucntions they are not important if i remove them it still does not work
}
app/etc/modules/Mxsxs2_Cron.xml
<?xml version="1.0"?>
<config>
<modules>
<Mxsxs2_Cron>
<active>true</active>
<codePool>local</codePool>
</Mxsxs2_Cron>
</modules>
</config>
回答1:
I have the latest Magento 1.9.x.x installed and had a similar problem. To debug it this question helps me a lot:Why is my Magento module not being loaded?. Basically you need to check Mage_Core_Model_Config. I also wonder why I can see my module in System->Configuration->Advanced->Advanced but it gives 404 error. Basically it's an error in Magento and the names for modules are broken. Somewhere Magento forces the names to have the first character Upper-case. It's not working with the first character lower-case (but it is shown in ystem->Configuration->Advanced->Advanced).
回答2:
Try to change the frontName, it may make some conflicts with newer version of magento :
app/code/local/Mxsxs2/Cron/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<Mxsxs2_Cron>
<version>1.0.0</version>
</Mxsxs2_Cron>
</modules>
<frontend>
<routers>
<cron>
<use>standard</use>
<args>
<module>Mxsxs2_Cron</module>
<frontName>testname</frontName>
</args>
</cron>
</routers>
</frontend>
</config>
clear cache then access the url mydomain/index.php/testname
来源:https://stackoverflow.com/questions/32188034/magento-1-9-2-1-custom-module-404