1

I am trying to override two class i.e

  • Mage_Adminhtml_Block_Review_Edit_Form and
  • Mage_Review_Model_Resource_Review

But they are not being override. please help..

The directory structure is:

local -->
       Efk --> 
           Adminhtml -->
               Block -->
                    Review -->
                         Edit -->
                             Form.php
               etc -->
                    config.xml
           Review -->
               etc -->
                    config.xml
               Model -->
                    Resource -->
                         Review.php

Here are my overrided files:

etc/modules/Efk_all (working fine.. checked in admin panel)

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

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

local/Efk/Review/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Review>
            <version>1.0</version>
        </Efk_Review>
    </modules>
    <global>
        <models>
            <review_resource>
                <rewrite>
                    <review>Efk_Review_Model_Resource_Review</review>
                </rewrite>
            </review_resource>
        </models>
    </global>
</config>

local/Efk/Adminhtml/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Adminhtml>
            <version>1.0</version>
        </Efk_Adminhtml>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <review_edit_form>Efk_Adminhtml_Block_Review_Edit_Form</review_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>
1
  • I know overriding is not good but it has a big long story why I am still doing this..
    – Mr_Green
    Commented Nov 21, 2013 at 7:04

4 Answers 4

3

You have a few errors in your rewrites. The following code should work. You do not need the full name after the <rewrite> think of it in terms of Mage::getModel('first/second_part') with the <rewrite> as the /

local/Efk/Review/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Review>
            <version>1.0</version>
        </Efk_Review>
    </modules>
    <global>
        <models>
            <review>
                <rewrite>
                    <resource_review>Efk_Review_Model_Resource_Review</resource_review>
                </rewrite>
            </review>
        </models>
    </global>
</config>

local/Efk/Adminhtml/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Adminhtml>
            <version>1.0</version>
        </Efk_Adminhtml>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <review_edit_form>Efk_Adminhtml_Block_Review_Edit_Form</review_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>
4
  • I had tried the same first then move to the one which I mentioned above :).. not working
    – Mr_Green
    Commented Nov 21, 2013 at 8:27
  • are they both not working or just one? Commented Nov 21, 2013 at 8:28
  • both not working..
    – Mr_Green
    Commented Nov 21, 2013 at 8:35
  • I updated my post after reading this link.. still it is not working.. please check.
    – Mr_Green
    Commented Nov 21, 2013 at 8:59
0

app/code/local/Efk/Adminhtml1/Block/Adminhtml/Review/Edit/Form.php

<?php
class Efk_Adminhtml1_Block_Adminhtml_Review_Edit_Form extends Mage_Adminhtml_Block_Review_Edit_Form
{
    protected function _prepareForm()
    {
        parent::_prepareForm();
    }
}

app/code/local/Efk/Adminhtml1/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Adminhtml1>
            <version>1.0</version>
        </Efk_Adminhtml1>
    </modules>
    <global>
        <blocks>
            <adminhtml1>
                <class>Efk_Adminhtml1_Block</class>
            </adminhtml1>
            <adminhtml>
                <rewrite>
                    <review_edit_form>Efk_Adminhtml1_Block_Adminhtml_Review_Edit_Form</review_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

app/code/local/Efk/Review/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Efk_Review>
            <version>1.0</version>
        </Efk_Review>
    </modules>
    <global>
        <models>
            <review_resource>
                <rewrite>
                    <review>Efk_Review_Model_Resource_Review</review>
                </rewrite>
            </review_resource>
        </models>
    </global>
</config>

app/code/local/Efk/Review/Model/Resource/Review.php

<?php
class Efk_Review_Model_Resource_Review extends Mage_Review_Model_Resource_Review
{


}

app/etc/modules/Efk_All.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <EFk_Review>
            <active>true</active>
            <codePool>local</codePool>
        </EFk_Review>

        <Efk_Adminhtml1>
            <active>true</active>
            <codePool>local</codePool>
        </Efk_Adminhtml1>
    </modules>
</config>
17
  • Can you please relate your code to what I have posted above? it is complicated for me to understand. please...
    – Mr_Green
    Commented Nov 21, 2013 at 8:10
  • Updated the answer
    – Sukeshini
    Commented Nov 21, 2013 at 8:31
  • do mean to do like this? fiddle. Sorry I am new to overriding stuff. so I can't understand.
    – Mr_Green
    Commented Nov 21, 2013 at 8:36
  • if I do what I mentioned, I am getting this error Fatal error: Call to a member function getFormData() on a non-object in C:\xampp\htdocs\efk\app\code\core\Mage\Review\Block\Form.php on line 42.
    – Mr_Green
    Commented Nov 21, 2013 at 8:40
  • Sorry, for my poor explanation. Did you try the code which I have provided
    – Sukeshini
    Commented Nov 21, 2013 at 8:40
0

The problem was that the class to which I was overriding was calling a method in its parent class with same name.

return parent::_afterSave();  //calling parent class's _afterSave() 

So, when I overriden this class with my method _afterSave() then I was calling again the overriden class's method instead of the grand parent's class. That was just double overriding.

After realizing this I called the grand parent class with name:

return Mage_Abstract::_afterSave() //calling grand parent class's _afterSave()

As my understanding, I written a blog in which I explained the same issue.

Link

0

We need to combin those two answers :

  1. https://magento.stackexchange.com/a/11032/46286
  2. https://magento.stackexchange.com/a/11029/46286

Try to add following to the first answer

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <EFk_Review>
            <active>true</active>
            <codePool>local</codePool>
        </EFk_Review>

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.