سؤال

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.

هل كانت مفيدة؟

المحلول 3

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>

نصائح أخرى

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>

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top