0

I wan't to extend local extension model with this existing config.xml:

<config>
    <modules>
        <Smartwave_All>
            <version>1.0.0</version>
        </Smartwave_All>
    </modules>      
    <global>
        ...
        <models>
            <core>
                <rewrite>
                    <layout>Smartwave_All_Model_Core_Layout</layout>
                </rewrite>
            </core>
            <all>
                <class>Smartwave_All_Model</class>
            </all>
        </models>
        ...
    </global>
</config>

This is the file which I wan't to extend with my public function (app/code/local/Smartwave/All/Model/Core/Layout.php):

<?php 
class Smartwave_All_Model_Core_Layout extends Mage_Core_Model_Layout
{ ...

Ok, now here are my extension files(app/etc/modules/SampleCompany_Test.xml):

<?xml version="1.0"?>
<config>
    <modules>
        <SampleCompany_Test>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Smartwave_All/>
            </depends>
        </SampleCompany_Test>
    </modules>
</config>

And my config.xml (app/code/local/SampleCompany/Test/etc/config.xml):

<?xml version="1.0"?>
<config>
    <modules>
        <SampleCompany_Test>
            <version>0.1</version>
        </SampleCompany_Test>
    </modules>
    <global>
        <models>
            <smartwave_all>
                <rewrite>
                    <core_layout>SampleCompany_Test_Model_Layout</core_layout>
                </rewrite>
            </smartwave_all>
        </models>
    </global>
</config>

And of course my Layout.php (app/code/local/SampleCompany/Test/Model/Layout.php):

class SampleCompany_Test_Model_Layout extends Smartwave_All_Model_Core_Layout
{
    public function myNewFunction()
    {
        ...
    }
}

I can't get this to work. Main problem is because Smartwave All is rewriting Mage/Core/Model/Layout.php core file and it is in conflict with my other extension which do the same (rewrites Layout.php). Now I wan't to extend Smartwave All instead of core Layout.php.

Thanks for any suggestions on this.

0

The problem here is that you're declaring your Smartwave_All models like this:

<all>
     <class>Smartwave_All_Model</class>
</all>

But you're doing the rewrite like this:

<smartwave_all>
   <rewrite>
        <core_layout>SampleCompany_Test_Model_Layout</core_layout>
   </rewrite>
</smartwave_all>

Where it should be:

<all>
   <rewrite>
        <core_layout>SampleCompany_Test_Model_Layout</core_layout>
   </rewrite>
</all>

Or the other way around you can change your models declaration like this:

<smartware_all>
     <class>Smartwave_All_Model</class>
</smartware_all>

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.