0

I'm very new to Magento, and working through some tutorials.

I am trying to setup a new Model, and, without created a Model file first, tried to access it to make sure that it was configured correctly.

I received the error Warning: include(Mage\Complex\Model\Complexpost.php) instead of Warning: include(Eav\Complex\Model\Complexpost.php), which I was expecting.

My folder structure is as follows:

app
  code
    local
      Eav
        Complex
          Block
          controllers
            IndexController.php
          etc
            config.xml
          Helper
          Model
          sql

I have also created the file app/etc/modules/Eav_Complex.xml with the content

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

The IndexController.php file looks like this:

<?php
class Eav_Complex_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $complex = Mage::getModel("complex/complexpost");
        var_dump($complex);
    }
}

and my config looks like this:

<config>
    <modules>
        <Eav_Complex>
            <version>0.1.0</version>
        </Eav_Complex>
    </modules>

    <frontend>
        <routers>
            <complex>
                <use>standard</use>
                <args>
                    <module>Eav_Complex</module>
                    <frontName>complex</frontName>
                </args>
            </complex>
        </routers>
    </frontend>

    <global>
        <models>
            <complex>
                <class>Eav_Complex_Model</class>
                <resourceModel>complex_resource</resourceModel>
            </complex>

            <complex_resource>
                <class>Eav_Complex_Model_Resource</class>
                <entities>
                    <complexpost>
                        <table>complex_post</table>
                    </complexpost>
                </entities>
            </complex_resource>
        </models>
    </global>

</config>

The URL I was trying to access was http://127.0.0.1/magento1/complex (I have already made a HelloWorld module, which worked, so I'm sure that the URL is correct).

Can anyone see anything obviously out of place? Any help would be greatly appreciated!

4
  • 1
    it seams like you are doing it right. Did you clear the cache? Do you have an other module that has complex as a subtag of <models> in config.xml ?
    – Marius
    Mar 8 '16 at 9:01
  • @Marius DAMNIT - clearing the cache worked... I've been doing this for 2 days and I still forget to clear my cache :( Thank you! If you post your comment as an answer, I will gladly mark it as accepted.
    – Skytiger
    Mar 8 '16 at 9:02
  • 1
    @Skytiger I highly recommend disabling the cache during development to avoid this sort of issue. Mar 8 '16 at 13:40
  • @JosephLeedy Thanks, I did that shortly after this fiasco.
    – Skytiger
    Mar 9 '16 at 6:30
1

This issue can happen for 2 reasons (at least that's how many I know):

  • You did not clear the cache.
  • you have an other module that uses the key complex for model aliases
1
  • Thanks Marius, in this case it was the (silly) problem of a cache not being cleared :)
    – Skytiger
    Mar 8 '16 at 9:15

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.