1

I Loaded a model called fabric_news using this code,

Mage::getModel('fabric_news/news')->getCollection();

But magento tries to load module from wrong name space. So It throws errors Like

Warning: include(Mage/Magentostudy/News/Model/News.php): failed to open stream: No such file or directory in /var/www/test/magento_custom/lib/Varien/Autoload.php on line 94

Kindly help me to overcome this issue.

Another one thing When I call Mage::getModel('fabric_news/news')->getCollection(); function in fabric_news module it is working well. but in fabric_tool module, It is not.

fabric_news config.xml.

<?xml version="1.0"?>
<!--
/**
 * Module configuration
 *
 * @author Fabric
 */
-->
<config>
    <modules>
        <Fabric_News>
            <version>1.0.0.0.1</version>
        </Fabric_News>
    </modules>
    <global>
        <models>
            <fabric_news>
                <class>Fabric_News_Model</class>
                <resourceModel>news_resource</resourceModel>
            </fabric_news>
            <news_resource>
                <class>Fabric_News_Model_Resource</class>
                <entities>
                    <news>
                        <table>fabric_news</table>
                    </news>
                </entities>
            </news_resource>
        </models>
        <helpers>
            <fabric_news>
                <class>Fabric_News_Helper</class>
            </fabric_news>
        </helpers>
        <blocks>
            <fabric_news>
                <class>Fabric_News_Block</class>
            </fabric_news>
        </blocks>
        <resources>
            <fabric_news_setup>
                <setup>
                    <module>Fabric_News</module>
                    <class>Mage_Core_Model_Resource_Setup</class>
                </setup>
            </fabric_news_setup>
        </resources>
        <events>
            <before_news_item_display>
                <observers>
                    <fabric_news>
                        <class>fabric_news/observer</class>
                        <method>beforeNewsDisplayed</method>
                    </fabric_news>
                </observers>
            </before_news_item_display>
        </events>
    </global>
    <frontend>
        <routers>
            <fabric_news>
                <use>standard</use>
                <args>
                    <module>Fabric_News</module>
                    <frontName>news</frontName>
                </args>
            </fabric_news>
        </routers>
        <layout>
            <updates>
                <fabric_news>
                    <file>fabric_news.xml</file>
                </fabric_news>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Fabric_News before="Mage_Adminhtml">Fabric_News_Adminhtml</Fabric_News>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <fabric_news>
                    <file>fabric_news.xml</file>
                </fabric_news>
            </updates>
        </layout>
    </adminhtml>
    <default>
        <news>
            <view>
                <enabled>1</enabled>
                <items_per_page>20</items_per_page>
                <days_difference>3</days_difference>
            </view>
        </news>
    </default>
</config>
  • What s the wrong module name? – Sundar Mar 5 '15 at 9:52
  • magento loads correct module.. but It does not load correct name space. – Vivek Aasaithambi Mar 5 '15 at 9:55
  • 2
    What does your config.xml look like. Magento attempts to prefix a name space with mage_ if if can't find the class name. – Peter O'Callaghan Mar 5 '15 at 10:21
  • Paste your config.xml here. – Sundar Mar 5 '15 at 10:23
  • Have updated my question – Vivek Aasaithambi Mar 5 '15 at 11:17
3

Perform a case insensitive search of your entire module for the string magentostudy. Best guess is that in app/code/{codePool}/Fabric/News/Resource/News.php you'll have something like:

protected function _construct()
{
    $this->_init('magentostudy_news/news', 'entity_id');
}
  • No, It has correct code like $this->_init('fabric_news/news','news_id'); – Vivek Aasaithambi Mar 5 '15 at 12:03
  • ...and did you search for the string magentostudy in your entire project? – Peter O'Callaghan Mar 5 '15 at 12:06
  • Hi, Thanks for trying to help me. The problem was with my editor. I searched so many times, But found no result. After you said, I changed my editor and searched magentostudy. And found and fixed. Now It is working well. @Cags – Vivek Aasaithambi Mar 5 '15 at 13:08

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.