0

Update (solution):

The problem seems to come from a difference between my local environment (OS X) which is case-insensitive and my test/live environment (Linux) which is case-sensitive. As the accepted answer indicates, the problem was a capital "R" which should have been a lower case "r" in my controller filename and classname.

I'll keep the question below as-is, in case anyone ends up with the same problem.


While this certainly isn't a new question as such, I haven't been able to solve it from the other solutions, so I was hoping someone might give my code a quick look for any immediate errors.

The problem

I'm trying to create an extension on Magento 1.8.1.0, it loads it and adds sub-menu items to the correct place (a sub-menu under Reports with its own items), but when clicking on the menu items I get a 404 page.

The weird thing is that this only happens on my live server and not on my local copy of the site (i.e. the routes are fine there).

What have I tried?

Besides having cleared every cache I can think of and logging in and out of the admin panel, I am even currently testing it without cache enabled at all.

I also tried to look at other extensions and changing the XML tag naming, but to no success.

The files

An overview of the files (the extension is Codetalk_CustomReports):

Codetalk/
  CustomReports/
    controlllers/
      Adminhtml/
        CustomReportsController.php
    etc/
      adminhtml.xml
      config.xml
    Helper/
      Data.php

The Codetalk/CustomReports/controllers/Adminhtml/CustomReportsController.php file:

<?php
class Codetalk_CustomReports_Adminhtml_CustomReportsController extends Mage_Adminhtml_Controller_Action {
    public function stockoverviewAction() {
        $this->loadLayout();
        $block = $this->getLayout()
            ->createBlock('core/text', 'stock-overview')
            ->setText("Stock overview");
        $this->_addContent($block);
        $this->renderLayout();
    }
    public function salesoverviewAction() {
        $this->loadLayout();
        $block = $this->getLayout()
            ->createBlock('core/text', 'sales-overview')
            ->setText("Sales overview");
        $this->_addContent($block);
        $this->renderLayout();
    }
}

The Codetalk/etc/adminhtml.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <report translate="title">
            <children>
                <Codetalk_CustomReports>
                    <title>Custom Reports</title>
                    <sort_order>90</sort_order>
                    <children>
                        <stockoverview>
                            <title>Full Stock Overview</title>
                            <sort_order>1</sort_order>
                            <action>adminhtml/customreports/stockoverview</action>
                        </stockoverview>
                        <salesoverview>
                            <title>Full Sales Overview</title>
                            <sort_order>1</sort_order>
                            <action>adminhtml/customreports/salesoverview</action>
                        </salesoverview>
                    </children>
                </Codetalk_CustomReports>
            </children>
        </report>
    </menu>

    <acl>
        <resources>
            <admin>
                <children>
                    <report>
                        <children>
                            <Codetalk_CustomReports translate="title">
                                <title>Codetalk Custom Reports</title>
                                <sort_order>1</sort_order>
                                <children>
                                    <stockoverview>
                                        <title>Full Stock Overview</title>
                                    </stockoverview>
                                    <salesoverview>
                                        <title>Full Sales Overview</title>
                                    </salesoverview>
                                </children>
                            </Codetalk_CustomReports>
                        </children>
                    </report>
                </children>
            </admin>
        </resources>
    </acl>

</config>

And lastly, the Codetalk/etc/config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Codetalk_CustomReports>
            <version>0.2.0</version>
        </Codetalk_CustomReports>
    </modules>

    <global>
        <helpers>
            <Codetalk_CustomReports>
                <class>Codetalk_CustomReports_Helper</class>
            </Codetalk_CustomReports>
        </helpers>
    </global>

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Codetalk_CustomReports before="Mage_Adminhtml">Codetalk_CustomReports_Adminhtml</Codetalk_CustomReports>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

</config>
3

Name your controller class Codetalk/CustomReports/controllers/Adminhtml/CustomreportsController.php instead of Codetalk/CustomReports/controllers/Adminhtml/CustomReportsController.php and change the class name accordingly.

Codetalk_CustomReports_Adminhtml_CustomreportsController instead of Codetalk_CustomReports_Adminhtml_CustomReportsController

| improve this answer | |
  • Oh my God, that worked immediately! Thanks :) Could this have anything to do with a case-sensitive filesystem vs a case-insensitive file system (my local is OS X and test/live is Linux)? Also, I'll accept your answer in 9 minutes when the cooldown is off. – Tehnix Nov 2 '15 at 9:58
  • 1
    yes, this is related to case-sensitivity. – Marius Nov 2 '15 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.