2
votes

I am just a newbie to the magento extensions. I want to create a new module named as storeinfo in magento version 1.7.0.2 . For that I have my folder structure for app/local is like this

magento directory
  app
    code
      community
      core
      local---
            |--- New(foldername)--
                  |---Storeinfo(foldername)--
                        |-Block
                          controllers
                          etc
                          Helper
                          sql

code for New_Storeinfo.xml which is inside magentodirectory/app/etc is something like this

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

Now inside the directory magentodirectory/app/code/local/New/Storeinfo/etc/config.xml is like this

<?xml version="1.0"?>
<config>
  <modules>
    <New_Storeinfo>
      <version>0.1.1</version>
    </New_Storeinfo>
  </modules>

  <frontend>
    <routers>
      <storeinfo>
        <use>standard</use>
        <args>
          <module>New_Storeinfo</module>
          <frontName>storeinfo</frontName>
        </args>
      </storeinfo>
    </routers>
    <layout>
      <updates>
        <storeinfo>
          <file>newstoreinfo.xml</file>
        </storeinfo>
      </updates>
    </layout>
  </frontend>

  <adminhtml>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <system>
              <children>
                <config>
                  <children>
                    <storeinfo>
                      <title>Store Map</title>
                    </storeinfo>
                  </children>
                </config>
              </children>
            </system>
          </children>
        </admin>
      </resources>
    </acl>
  </adminhtml>

  <global>
        <models>
            <storeinfo>
                <class>New_Storeinfo_Model</class>
        <resourceModel>storeinfo_mysql4</resourceModel>
            </storeinfo>
        </models>
    <resources>
            <storeinfo_setup>
                <setup>
                    <module>New_Storeinfo</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </storeinfo_setup>
            <storeinfo_write>
                <connection>
                  <use>core_write</use>
                </connection>
            </storeinfo_write>
            <storeinfo_read>
               <connection>
                <use>core_read</use>
              </connection>
            </storeinfo_read>
        </resources>
    <blocks>
            <storeinfo><class>New_Storeinfo_Block</class></storeinfo>
        </blocks>
    <helpers>
            <storeinfo>
                <class>New_Storeinfo_Helper</class>
            </storeinfo>
        </helpers>
    </global>
  <default>
        <storeinfo>
      <address>
        <enabled>1</enabled>
        <title>Our Store Address</title>
        <address>Replace this with Your Address with or without HTML code here....</address>
      </address>
      <storeinfo>
        <enabled>1</enabled>
        <title>Our Location Map</title>
        <map_location>Paste Map HTML code here...</map_location>
      </storeinfo>
    </storeinfo>
    </default>
</config>

Now for the directory magentodirectory/app/code/local/New/Storeinfo/etc/system.xml my code is like this

<?xml version="1.0"?>
<config>
    <tabs>
        <storeinfo translate="label" module="storeinfo">
            <label>Store Map &amp; Address</label>
            <sort_order>132</sort_order>
        </storeinfo>
    </tabs>
    <sections>
        <storeinfo translate="label" module="storeinfo">
            <label>Map &amp; Address Info.</label>
            <tab>storeinfo</tab>
            <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>
            <groups>
                <storeinfo translate="label">
                    <label>Settings</label>
                    <comment><![CDATA[
                        <p>
                            <div>Add Store info:</div>
                        </p>
                    ]]></comment>
                    <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>
                        <enabled translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>0</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </enabled>
                        <title translate="label">
                            <label>Title</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>
                        </title>
                        <map_location translate="label">
                            <label>Location Map HTML code</label>
                            <frontend_type>textarea</frontend_type>
                            <sort_order>3</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <comment><![CDATA[Collect you store map html code from any of the maps code provides like <strong>Google, Yahoo..</strong>]]></comment>
                        </map_location>
                    </fields>
                </storeinfo>
                <address translate="label">
                    <label>Address</label>
                    <comment><![CDATA[
                        <p>
                            <div>Add Store Address to your Magento Store:</div>
                        </p>
                    ]]></comment>
                    <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>
                    <fields>
                        <enabled translate="label">
                            <label>Enabled</label>
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>0</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </enabled>
                        <title translate="label">
                            <label>Title</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>
                        </title>
                        <address translate="label">
                            <label>Address</label>
                            <frontend_type>textarea</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>
                            <comment>Put you store address with or without HTML code</comment>
                        </address>
                    </fields>
                </address>
            </groups>
        </storeinfo>
    </sections>
</config>

But after all the codes the menu for Storeinfo is not showing in magento's admin configuration tab. So can someone kindly tell me what is the issue here?Any help and suggestions will be really appreciable. Thanks...

6
you go to system-->configuration-->Advanced--> enable Disable Modules Output--> check if you modules created or not.VIVEK-MDU
@VIVEK-MDU yes the module is showing in advanced but it is not showing in configuration tab.I have tried many times to make it on and ff from advanced tab.. but nothing is happening...NewUser
Do you have a helper called Data.php in you helper folder? Have you refreshed your cache?Emi

6 Answers

1
votes

The question was answered on magento.stackexchange.com with additional details.
The problem is in the declaration xml file. The tag <codepool> should be <codePool> - uppercase P.

1
votes

remove the below code from config.xml

<adminhtml>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <system>
              <children>
                <config>
                  <children>
                    <storeinfo>
                      <title>Store Map</title>
                    </storeinfo>
                  </children>
                </config>
              </children>
            </system>
          </children>
        </admin>
      </resources>
    </acl>
  </adminhtml>

and create an adminhtml.xml file in etc folder with below content

<?xml version="1.0"?>
<config>
    <acl>
      <resources>
        <all>
          <title>Allow Everything</title>
        </all>
        <admin>
          <children>
            <system>
              <children>
                <config>
                  <children>
                    <storeinfo>
                      <title>Store Map</title>
                    </storeinfo>
                  </children>
                </config>
              </children>
            </system>
          </children>
        </admin>
      </resources>
    </acl>
  </config>
1
votes

I would suggest using a generator to build most of the basic stuff like that to avoid spelling errors etc.

http://www.silksoftware.com/magento-module-creator

1
votes

Unless it was a typo, you mention your New_Storeinfo.xml is located in:

magentodirectory/app/etc


This should actually be located in this folder:

magentodirectory/app/etc/modules

Refresh cache, and now your module should show up under System -> Configuration -> Advanced

1
votes

Try this way. Its used to create a menu tab for magento admin.

Create your folder structure for your needs.

then app/code/local/company_name/module_name/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <JR_CreateAdminController>
            <version>1.0.0</version>
        </JR_CreateAdminController>
    </modules>
    <global>
        <helpers>
            <jr_createadmincontroller>
                <!-- Helper definition needed by Magento -->
                <class>Mage_Core_Helper</class>
            </jr_createadmincontroller>
        </helpers>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <foo_bar before="Mage_Adminhtml">JR_CreateAdminController_Adminhtml</foo_bar>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

then you create admin panel menu using this way app/code/community/company_name/module_name/etc/adminhtml.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <menu>
        <mycustomtab module="jr_createadmincontroller" translate="title">
            <title>My Custom Tab</title>
            <sort_order>100</sort_order>
            <children>
                <index module="jr_createadmincontroller" translate="title">
                    <title>Index Action</title>
                    <sort_order>1</sort_order>
                    <action>adminhtml/custom</action>
                </index>
                <list module="jr_createadmincontroller" translate="title">
                    <title>List Action</title>
                    <sort_order>2</sort_order>
                    <action>adminhtml/custom/list</action>
                </list>
            </children>
        </mycustomtab>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <custom translate="title" module="jr_createadmincontroller">
                        <title>My Controller</title>
                        <sort_order>-100</sort_order>
                        <children>
                            <index translate="title">
                                <title>Index Action</title>
                                <sort_order>1</sort_order>
                            </index>
                            <list translate="title">
                                <title>List Action</title>
                                <sort_order>2</sort_order>
                            </list>
                        </children>
                    </custom>
                </children>
            </admin>
        </resources>
    </acl>
</config>

you can create own controller for your module app/code/community/company_name/module_name/controllers/Adminhtml/CustomController.php

<?php

class JR_CreateAdminController_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('mycustomtab')
            ->_title($this->__('Index Action'));

        // my stuff

        $this->renderLayout();
    }

    public function listAction()
    {
        $this->loadLayout()
            ->_setActiveMenu('mycustomtab')
            ->_title($this->__('List Action'));

        // my stuff

        $this->renderLayout();
    }
}

and you want to create configuration tab : create system.xml and use this code

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <tabs>
        <inchoo translate="label" module="mymodule">
            <label>Inchoo Extensions</label>
            <sort_order>100</sort_order>
        </inchoo>
    </tabs>
    <sections>
        <inchoo translate="label" module="mymodule">
            <label>Extension Options</label>
            <tab>inchoo</tab>
            <sort_order>1000</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <inchoo_group translate="label" module="mymodule">
                    <label>My Extension Options</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>1000</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <inchoo_input translate="label">
                            <label>My Input Field: </label>
                            <comment>My Comment</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </inchoo_input>
                        <inchoo_select translate="label">
                            <label>My Dropdown: </label>
                            <comment>Source model provider Magento's default Yes/No values</comment>
                            <frontend_type>select</frontend_type>
                            <sort_order>90</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                        </inchoo_select>
                    </fields>
                </inchoo_group>
            </groups>
        </inchoo>
    </sections>
</config>

I'm sure this would work for you.

0
votes

You didn't have this problem but for posterity's sake I've noticed that if you have any comments in your /app/etc/modules/New_Storeinfo.xml file, the module won't show up in System > Configuration > Advanced > Advanced :: Disable Modules Output