Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Problem adding our own models. 
 
aimos
Jr. Member
 
Total Posts:  18
Joined:  2007-12-28
 

I think there is a problem with accessing our own models.

I would like to extend in my own namespace, which I do at the moment, but I seems that you can’t create your own models the normal way.

Mage::getModel(’community/group’);

will try to access a model below the “mage” folder, not my own one.

Warning: include(Mage\Community\Model\Group.php) [function.include]: failed to open stream: No such file or directory in L:\de_cookelani_www\app\code\core\Mage\Core\functions.php on line 44
[0] in __autoload() in L:\de_cookelani_www\app\code\core\Mage\Core\functions.php on line 44
[1] in __autoload("Mage_Community_Model_Group")
[2] in class_exists("Mage_Community_Model_Group") in L:\de_cookelani_www\app\code\core\Mage\Core\Model\Config.php on line 585

So I think, a new paramater is needed, or something like:

Mage::getModel(’ronolo/community/group’);

Or have I done things wrong?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Please paste your module’s config.xml

 
Magento Community Magento Community
Magento Community
Magento Community
 
aimos
Jr. Member
 
Total Posts:  18
Joined:  2007-12-28
 

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

<?xml version="1.0"?>
<config>
  <global>
    <
blocks>
      <
community>
        <class>
Ronolo_Community_Block</class>
      </
community>
    </
blocks>
  </global>
  <
frontend>
    <
routers>
      <
community>
        <use>
standard</use>
        <
args>
          <
module>Ronolo_Community</module>
          <
frontName>community</frontName>
        </
args>
      </
community>
    </
routers>
    <
layout>
      <
updates>
        <
community>
          <
file>community.xml</file>
        </
community>
      </
updates>
    </
layout>
  </
frontend>
</
config>

There has to be an way to load models from the Mage core folder and to load models from my namespace. And this should at least be possible from my namespace. I guess visa vice should be possible too. There will be case were I just want to add a few lines in the magento code, that my extention will be loaded.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aimos
Jr. Member
 
Total Posts:  18
Joined:  2007-12-28
 

I found a workaround. Just name the Model “absolute” and it will be loaded just fine.

So if you are in your own Namespace just do Mage::getModel("Mynamespace_Foobar_Model_Barfoo");

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jonathan Hedrén
Member
 
Total Posts:  67
Joined:  2007-08-31
Sweden
 
aimos - 24 February 2008 08:39 AM

I found a workaround. Just name the Model “absolute” and it will be loaded just fine.

So if you are in your own Namespace just do Mage::getModel("Mynamespace_Foobar_Model_Barfoo");

OT: This “workaround” also works in layout xml’s when specifying a type for a block.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top