How to Manage the Backend Functionality of Your Magento Store?

Helper contains the necessary functions for you; you can call in a helper from anywhere. An example of helper is as below

$helper = Mage::helper('monhelper');

The call can be related to

$helper = Mage::helper('monhelper/data');

Let's create a helper file

You will need to declare the helper in the config file in your Magento core. Configure your code in the <global> after the </blocks> field

<helpers>
   <test>
          <class>STTL_Test_Helper</class>
    </test>
</helpers>

Next, you will need to create the file app/code/local/STTL/Test/Helper/data.php which will contain the function bytwo($ nbr). A number will be used as an argument here. The return value in the output will be the number multiplied by two.Helper will extend the core class MageCoreHelper_Abstract

<?php
class STTL_Test_Helper_Data extends Mage_Core_Helper_Abstract{
   public function bytwo($nbr){
        return $nbr*2;
   }
}

Go to in/app/code/local/STTL/Test/Block/monblock.php and change the function here with the help of the code below

<?php
class STTL_Test_Block_Monblock extends Mage_Core_Block_Template
{
      public function methodblock()
      {
            $helper = Mage::helper('test');
            return '2*2 = '.$helper->bytwo(2);
      }
}

Let's Add a New Field

Let's say you want to create a plugin that will store information about payment card in the system>configuration.

Let's add a sidebar <<Cards> section with a <<cards>> group and a config tab to help store your card numbers

Let's begin by creating a structure for the project

<?xml version="1.0"?>
<config>
    <modules>
        <STTL_Ecard>
            <version>1.0.0</version>
            <depends>
            <!-- no dependencies -->
            </depends>
        </STTL_Ecard>
    </modules>
    <frontend>
           <routers>
              <route_ecard>
                  <use>standard</use>
                  <args>
                     <module>STTL_Ecard</module>
                     <frontName>ecard</frontName>
                  </args>
               </route_ecard>
           </routers>
        </frontend>
     <adminhtml>
      <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <ecard_section translate="title">
                                        <title>My Section </title>
                                        <sort_order>100</sort_order>
                                    </ecard_section>
                                </children>
                            </config>
                        </children>
                    </system>
                 </children>
            </admin>
        </resources>
    </acl>
     </adminhtml>
</config>

Create etc/system.xml and declare the menu here.

<?xml version="1.0" ?>
<config>
    <tabs>
        <ecard_tab translate="label">
            <label>Cartes</label>
            <sort_order>100</sort_order>
        </ecard_tab>
    </tabs>
    <sections>
        <ecard_section translate="label">
            <label>Cartes</label>
            <sort_order>200</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <tab>ecard_tab</tab>
            <groups>
                <ecard_group translate="label">
                    <label>Config</label>
                    <comment>Card Configuration</comment>
                    <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>
                    <fields>
                        <ecard_field translate="label comment">
                            <label>Card Number</label>
                            <comment>a text to help</comment>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                            <frontend_input>text</frontend_input>
                        </ecard_field>
                    </fields>
                </ecard_group>
            </groups>
        </ecard_section>
    </sections>
</config>

With this xml, you can add a tab to System>Configuration and then retrieve the information from the fields

Mage::getStoreConfig('ecardsection/ecardgroup/ecard_field');

You can test what you have created by creating a controller in controllers/IndexController.php

<?php
class STTL_Ecard_IndexController extends Mage_Core_Controller_Front_Action
{
    /*
     * To test Ecards functions...
     */
    public function indexAction()
    {
        echo  Mage::getStoreConfig('ecard_section/ecard_group/ecard_field');
    }
}

Conclusion

Creating a field or a helper will add functionality and new features to your store. You can even customize your store with the help of these fields. Hire Magento eCommerce developers to help you create custom fields or helper.

Deepa Ranganathan
  • magento backend functionality
  • magento store
By Deepa Ranganathan On 17 Jul, 15  Viewed: 137

Other blogs you may like

How to Programmatically Create a Dropdown Login for your Magento Store?

If you want to improve the interface of your Magento store, then you must include the dropdown login form. This would help create an interactive base for your consumers, and offer convenience too! Let’s see how you can include the form programmatically. Go to... By Deepa Ranganathan   On 07 Jul 2015  Viewed: 921

3 Ways to Track Shoppers Checking-in From Different Devices

Smart devices are just increasing and improving with time. The digital era has definitely introduced many devices that will offer convenience and ease out your problems. With multiple platforms available for logging into your favourite store, it becomes difficult for you as a store owner or a... By Deepa Ranganathan   On 18 Jun 2015  Viewed: 174