3

I've followed this tutorial from the Magento Wiki, but I get a 404 when accessing my front controller.

After doing research, I found this question facing the same problem and I did all the suggested checks, but to no avail. My compiler and cache are disabled, and to discard hardware-related issues I've cleared my browser's cache and cookies, I've tried in Ubuntu 14.10 with Firefox, Windows 8.1 with all major browsers (including Opera) and iOS 8.1.3 with Safari (both on iPad and iPhone). **(EDIT: I've also cleared the /var/cache/ contents)

My idea is to be able to access company.com/distro and display some information in there. For that, I have the following files for my Company_Distro extension:

/app/etc/modules/Company_Distro.xml

<config>
    <modules>
        <Company_Distro>
            <active>true</active>
            <codePool>local</codePool>
        </Company_Distro>
    </modules>
</config>

/app/code/local/Company/Distro/etc/config.xml

<config>
    <modules>
        <Company_Distro>
            <version>0.1.0</version>
        </Company_Distro>
    </modules>
    <frontend>
        <routers>
            <company_distro>
                <use>standard</use>
                <args>
                    <module>Company_Distro</module>
                    <frontName>distro</frontName>
                </args>
            </company_distro>
        </routers>
    </frontend>
</config>

/app/code/local/Company/Distro/controllers/IndexController.php

class Company_Distro_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction() {
        echo 'Hello';
    }
}

Am I missing something? Am I doing anything wrong? Any help will be greatly appreciated.

Thanks.

  • How do you call the controller in url? – Vivek Aasaithambi Mar 6 '15 at 13:10
  • It's all explain in the replies below. I've tried all the possible combinations, such as: company.com/distro, company.com/distro/index, company.com/distro/index/index, company.com/index.php/distro, company.com/index.php/distro/index and company.com/index.php/distro/index/index – VDD Mar 6 '15 at 13:14
7

After trying all your suggestions and doing even more research, I thought I should review the index.php file of Magento and I've realised that I had to type the store code in the URL, so now company.com/store_code/distro seems to work fine.

Thanks to Digital Pianist and John Cuthbert for their help. I can't upvote yet due to lack of enough reputation, but I'll do as soon as it's possible.

1

Whilst you have disabled the Cache in Magento the cache files still are generated so please remove all contents from var/cache/* first of all.

Both configurations look valid - the frontName should define where it is accessible: example.com/distro/index/index

The url structure gets defined as // (a more detailed explaination is here: http://www.solvingmagento.com/magento-routers-a-look-under-the-hood/)

  • Thanks for your reply. I always clear the var/cache folder too, but that hasn't solve it either. – VDD Mar 6 '15 at 11:02
1

This is the easiest way.

Regenerate your structure using this:

http://www.silksoftware.com/magento-module-creator/

Then, merge your existing logic into the generated structure from the module creator.

In Magento, there are subtle, unstated rules about case-sensitivity and file naming that are nearly impossible to eyeball - even in a few files. For example, organization name must begin with a capital letter, or it won't load the module.

1

I believe the router part should look like this for this to work:

<frontend>
    <routers>
        <distro>
            <use>standard</use>
            <args>
                <module>Company_Distro</module>
                <frontName>distro</frontName>
            </args>
        </distro>
    </routers>
</frontend>

Replace company_distro by distro under your routers tag.

  • Thanks for your prompt reply, but after trying that, it hasn't solved the issue. I really don't know what's wrong with my extension. – VDD Mar 6 '15 at 10:45
  • Can you confirm you're trying to access the following page: yourstoreurl.com/index.php/distro/index/index ? – Raphael at Digital Pianism Mar 6 '15 at 10:54
  • Yes, as well as company.com/distro, company.com/distro/index, company.com/distro/index/index, company.com/index.php/distro and company.com/index.php/distro/index – VDD Mar 6 '15 at 10:56
  • 1
    Did you ensure the module output is not disabled in the backend ? – Raphael at Digital Pianism Mar 6 '15 at 11:19
  • 1
    Yes, that was one of the first things I tried, as that question that I posted was suggesting. I've made sure the module output is enabled on the backend as well as checked that disable_local_modules is set to false in /app/etc/local.xml – VDD Mar 6 '15 at 11:28

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.