Magento Forum

   
How to extend Mage_Core_Model_App? 
 
Andreas Bruckmeier
Jr. Member
 
Total Posts:  8
Joined:  2008-05-14
 

Hi,

i successfully extended the class Mage_Catalog_Block_Product_View according to those howtos:
- How To Create a Featured Product
- Changing and Customizing Magento Code

But what is the correct way to extend Mage_Core_Model_App?

my extension class in app/code/local/Xxx/Core/Model/App.php

<?php
class Xxx_Core_Model_App extends Mage_Core_Model_App {
    
public function __construct() {
        parent
::__construct();
        
// output to file in order to identify which class is loaded
    
}
}
?>

my config in app/etc/modules/Xxx_Core.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Xxx_Core>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Xxx_Core>
    </
modules>
</
config>

my config in app/code/local/Xxx/Core/etc/config.xml

<?xml version="1.0"?>
<config>
    <global>
        <
models>
            <
core>
                <
rewrite>
                    <
app>Xxx_Core_Model_App</app>
                </
rewrite>
            </
core>
        </
models>
    </global>
</
config>

I disabled all caches, but my extension class is not loaded by magento.

And by the way: is there any function for debug output or a variable to append it to?

 
Magento Community Magento Community
Magento Community
Magento Community
 
asrenzo
Member
 
Avatar
Total Posts:  42
Joined:  2008-02-25
France
 

@Andreas

Did you succeed in creating a custom Core/Model/App.php ? I’m stucked like you seem to be for this file also

@Anyone else

Does anybody else know how to do this ?

Regards,

Laurent

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

Only classes that are instantiated using Mage::getModel(’module/model’) can be overloaded.

Mage_Core_Model_App is instantiated as a regular PHP class ($app = new Mage_Core_Model_App), because it is one of the first classes instantiated, before Magento configuration is available.

So, the only way to have custom Mage_Core_Model_App is the regular PHP way of doing it, meaning copying it to app/code/local/Mage/Core/Model/App.php and let include_path do its work.

 
Magento Community Magento Community
Magento Community
Magento Community
 
asrenzo
Member
 
Avatar
Total Posts:  42
Joined:  2008-02-25
France
 

Thanks moshe for this quick answer.

 
Magento Community Magento Community
Magento Community
Magento Community
 
wakanina
Member
 
Total Posts:  45
Joined:  2012-03-14
 
Moshe - 28 May 2008 11:54 PM

Only classes that are instantiated using Mage::getModel(’module/model’) can be overloaded.

Mage_Core_Model_App is instantiated as a regular PHP class ($app = new Mage_Core_Model_App), because it is one of the first classes instantiated, before Magento configuration is available.

So, the only way to have custom Mage_Core_Model_App is the regular PHP way of doing it, meaning copying it to app/code/local/Mage/Core/Model/App.php and let include_path do its work.

So this means copy the whole code to it. Is this right?

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