سؤال

How can I add a field in admin panel > system > configuration > General Tab ?

Please specify Path for file in Magento 1.9

I am using code below but no success:

<sections>
    <custom translate="label" module="custom">
        <label>Custom</label>
        <tab>general</tab>
        <sort_order>60</sort_order>
        <show_in_default>1</show_in_default>
        <show_in_website>1</show_in_website>
        <show_in_store>1</show_in_store>
    <groups>
        <store_number translate="label">
                <label>Store Customer Care Number</label>
                <frontend_type>text</frontend_type>
                <sort_order>100</sort_order>
                <show_in_default>1</show_in_default>
                <show_in_website>1</show_in_website>
                <show_in_store>1</show_in_store>
                <fields>
                    <contact_info translate="label">
                        <label>Store Customer Care Number</label>
                        <frontend_type>text</frontend_type>                    
                        <sort_order>2</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                    </contact_info>                        
                </fields>
         </store_number>
    </groups>
    </custom>
</sections>
هل كانت مفيدة؟

المحلول

In your module add below code:

In file app/code/local/Namesapce/Modulename/etc/system.xml

 <general>            
       <groups>
            <test translate="label">
                    <label>Test Options</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enable translate="label">
                            <label>Enable</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>                       
                            <sort_order>2</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <can_be_empty>1</can_be_empty>
                        </enable>                        
                    </fields>
                </test>
        </groups>
   </general>

نصائح أخرى

A module can be created using following files:

app/etc/modules/Vendor_Module.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Vendor_Module>
            <active>true</active>
            <codePool>local</codePool>
        </Vendor_Module>
    </modules>
</config>

app/code/local/Vendor/Module/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Vendor_Module>
            <version>0.0.1</version>
        </Vendor_Module>
    </modules>
    <global>
        <helpers>
            <class>Vendor_Module_Helper</class>
        </helpers>
    </global>
</config>

app/code/local/Vendor/Module/etc/system.xml

<?xml version="1.0"?>
<config>
    <sections>
        <custom translate="label" module="module">
            <label>Custom</label>
            <tab>general</tab>
            <sort_order>60</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>                    
                <custom_group>
                    <fields>
                        <hours translate="label">
                            <label>Store Contact Hours</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>21</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </hours>
                    </fields>
                </custom_group>
            </groups>
        </custom>
    </sections>
</config>

app/code/local/Vendor/Module/Helper/Data.php

<?php

class Vendor_Module_Helper_Data extends Mage_Core_Helper_Abstract
{
}

In this example, I've added a Store Contact Hours field but you can change it to whatever you want.

The value of the field will be accessible by Mage::getStoreConfig('custom/custom_group/hours');

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