0

I want to override the default functionality of stores (adding some fields like commission , location to deliver etc ), but i am not able to configure it. My configure file as follows

    <config>
  ...

    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <store before="Mage_Adminhtml">Mycompany_Store_Adminhtml_Store</store>
                    </modules>
                </args>
            </adminhtml>
        </routers>
</admin>
 </global>
....
 </config>

It doesnt work at all.

1

With my comment on Marius' answer, his solution should work.

However, you c/should be doing this using system.xml, which allows you to specify fields in System Configuration. You can then read these values using Mage::getStoreConfig() and perform the logic which you need.

<sections>
    <general>
        <groups>
            <store_information>
                <fields>
                    <commission>
                        <label>Commission</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>10</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </commission>
                </fields>
            </store_information>
        </groups>
    </general>
</sections>
0

Try with this configuration:

<admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <Mycompany_Store before="Mage_Adminhtml">Mycompany_Store_Adminhtml</Mycompany_Store>
                    </modules>
                </args>
            </adminhtml>
        </routers>
</admin>

Your controller should be in this file: Mycompany/Store/controllers/Adminhtml/System/StoreController.php and it should look like this:

<?php
require_once 'Mage/Adminhtml/controllers/System/StoreController.php';
class Mycompany_Store_Adminhtml_System_StoreController extends Mage_Adminhtml_System_StoreController{
    //your methods here
}

This is how you should override the store controller. What I don't understand is why you need to do this. You can add all the settings you want in the system->configuration section using the system.xml file from one of your modules and you can read them easily with Mage::getStoreConfig('path/to/setting').
or if you want extra fields in the store entity just add them in the table core_store and fields for them in the form for add/edit store. Here is how you can do that.

I really recommend putting your values in the config section.

  • it doesnt work bro. Actually what i want to do is add fields like commission and locations to deliver the products (for home delivery). For that i need to override the StoreController right. – safwan Apr 4 '13 at 9:04
  • 1
    Then I'm not sure I get the big picture here. What you are trying to add, has something to do with the 'store' object itself? Or you need to change something to a delivery method? or you just need to list some details about the home delivery somewhere in a page and that depends on the store? – Marius Apr 4 '13 at 11:02
  • yes exactly.. i want to add locations for home delivery in each stores. its like each store will be having multiple locations to deliver their products.. customer selects the place to deliver during his payment process. And also for each stores there should be a field commission in %. – safwan Apr 5 '13 at 12:34
  • 1
    in this case I recommend implementing the commission and the locations inside the delivery method module for home delivery, not in the store object. – Marius Apr 5 '13 at 12:36
  • 2
    @Marius FYI The path to the file is incorrect. It should be Mycompany/Store/controllers/Adminhtml/System/StoreController.php – benmarks May 10 '13 at 11:44
0

Finally i came up with a solution..

<global>

        <rewrite>        
            <mycompany_store_adminhtml_system_storecontroller>
                <from><![CDATA[#^/admin/system_store/#]]></from> <!-- Mage_Adminhtml_System_StoreController  -->
                <to>/store/adminhtml_system_store/</to> <!-- Mycompany_Store_Adminhtml_System_StoreController  -->
            </mycompany_store_adminhtml_system_storecontroller>
        </rewrite>
</global>
  • I had tried all the way. I think this is the way my magento version supports.. – safwan Apr 9 '13 at 4:10
  • 2
    this is the old way you should override controllers in Magento. But for the new versions (I don't know the version that started supporting this) the way I described it is supported and recommended. The way you use it will stop working if you change the url key for your admin. – Marius Apr 9 '13 at 8:14
  • ok.. thanks bro... But the way you told was not working... I am not getting what is the problem.. Can i rewrite the class using any magento module creator ? – safwan Apr 9 '13 at 12:59

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.