1

So, I am trying to override a Gallery module I've downloaded and add some fields to the admin form, which would help me to include more options to the frontend.

The module I've downloaded is Image Gallery with categories or SAG_Gallery to be precise.

One of the files I am currently interested with is located in /app/code/community/Sag/Gallery/Block/Adminhtml/Category/Edit/Tab/Form.php.

So I created a sample module and added it to /etc/modules named AcmeDemo, so now I have /etc/modules/AcmeDemo.xml.

In there I've added the following code:

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

I've also created the path, as follows: /app/code/local/Acme/Demo. The module is loaded succesfully as I was able to confirm it by looking at my admin panel in "Advanced" options, it's there.

Then I created few directories to mimic the original path, as follows:

/app/code/local/Acme/Demo/Block/Adminhtml/Category/Edit/Tab

and in there I've created the file Form.php with the following code (it's an example, I'm trying to "kill" the form, to ensure my code works)

class Bogara_Gallery_Block_Adminhtml_Category_Edit_Tab_Form extends Sag_Gallery_Block_Adminhtml_Category_Edit_Tab_Form {

    protected function _prepareForm() {
        exit;
    }

}

I've added the following configuration in /app/code/local/Acme/Demo/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Acme_Demo>
            <version>0.0.1</version>
        </Acme_Demo>
    </modules>
    <global>
        <blocks>
            <acme_demo>
                <class>Acme_Demo_Block</class>
            </acme_demo>
            <adminhtml>
                <rewrite>
                    <category_edit_tab_form>Acme_Demo_Block_Adminhtml_Category_Edit_Tab_Form</category_edit_tab_form>
                </rewrite>
            </adminhtml>
        </blocks>
    </global>
</config>

which appears to be wrong, since the original Form.php is still being executed. Probably is some silly mistake, or something that I've missed.

Any kind of advice/help will be really appreciated. Thanks.

1 Answer 1

2

This should be different:

<adminhtml>
    <rewrite>
        <category_edit_tab_form>Acme_Demo_Block_Adminhtml_Category_Edit_Tab_Form</category_edit_tab_form>
    </rewrite>
<adminhtml>

look in the file app/code/community/Sag/Gallery/etc/config.xml and search for a tag named <blocks>.
You should find something like this:

<blocks>
    <sag_gallery><!-- this may be different, but it's what you need -->
        <class>Sag_Gallery_Block</class>
    </sag_gallery>
</blocks>

get the tag name I marked above with a comment, and add this to your module's config instead of <adminhtml>....

<sag_gallery>
    <rewrite>
        <adminhtml_category_edit_tab_form>Acme_Demo_Block_Adminhtml_Category_Edit_Tab_Form</adminhtml_category_edit_tab_form>
    </rewrite>
</sag_gallery>
3
  • Marius, always very good explanation! )
    – electroid
    Commented Aug 1, 2016 at 12:35
  • @Marius what should I right in place of <adminhtml_category_edit_tab_form> , if I want to rewrite any custom extension (I want to add new tab to aw_blog extension).
    – Mac
    Commented Dec 13, 2018 at 12:17
  • It depends from extension to extension. I have no idea how aw_blog is configured.
    – Marius
    Commented Dec 13, 2018 at 12:19

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.