How to develop custom Module for magento

          Magento is the most powerful e-commerce solution around and has gained popularity in a short period of time. You can create and manage online stores using the extensive suite of powerful tools it offers. However, because of its powerful features, developing with Magento can be easier said than done.

          Magento is a new and powerful eCommerce system offering rich customization possibilities by extensions and modules. Magento is built on a fully modular model that influences an unlimited scalability and flexibility for your store. Part of customizing Magento is, creating Magento custom Modules. These allow you to inject functionality anywhere, whether in a "static" block fashion that's more than static, or a shipping/payment module, or large module to do something as large as integrating a 3rd party system (or multiple systems).

          Basically, magento module is an extension which extends the features and functionality of Magento. Some concrete examples of modules are additional payment gateway integrations, or a featured items promotional tool. With Magneto’s fully object-oriented programming, all modules are immediately accessible via templates tags from any template files. And because Magento is feature-rich right out of the box, you’ll never again have to be dependent on a programmer to finish the simplest tasks for you. Magento also thrives on an extensive network of knowledgeable community members (including the official Magento Team), so you will never need to think twice about where to get guidance should you need it along the way.

          Part of customizing Magento is, of course, creating custom Modules. These allow you to inject functionality anywhere, whether in a "static" block fashion that's more than static, or a shipping/payment module, or large module to do something as large as integrating a 3rd party system (or multiple systems).

          Creating a magento module involve several steps. This article describes the steps that need to be followed to create a new module.

1) Create directory app/code/local/mymodulepack. Here ‘mymodulepack’ will be the new directory folder where you can create modules.

2) Create module named ‘My Module’ in above defined directory path. This will be your module directory which will contain required files like models, blocks, controllers etc.

3) Now add your new module xml file in app/etc/modules/mymodulepack _All.xml. Consider that _All.xml will be used to add all new module definitions to the same file instead of cluttering the etc/modules folder with many files.

4) Following defined code is used to inform Magento that there is an active module (you can turn it off from here by setting ‘active’ to false). Also that it is located in the ‘local’ code pool.

<?xml version=”1.0??>

<config>

<modules>

< Mymodulepack _MyModule>

<active>true</active>

<codePool>local</codePool>

</ Mymodulepack _MyModule>

</modules>

</config>

5) Now you can enable or disable this module at Admin -> System -> Advanced. Here you can see your new module ‘Mymodulepack_MyModule’ listed there with status enable.

6) And now create the block php class file at app/code/local/Schogini/Example/Block/Myview.php which contains a function that returns the string ‘Hello World’.

class Mymodulepack_MyModule_Block_Myview extends Mage_Core_Block_Template {

public function myFunction(){

return “Hello World!“;

}

}

?>

7) Now  make a config.xml file in app/code/local/Mymodulepack/MyModule/etc directory. This is done to enter configuration information for the module.

<?xml version=”1.0? ?>
<config>
<modules>
<Mymodulepack_MyModule>
<version>0.1.0</version>
</Mymodulepack_MyModule>
</modules>
<global>
<blocks>
<mymodule>
<class>Mymodulepack_MyModule_Block</class>
</mymodule>
</blocks>
</global>
</config>

8) Now we need to create a template file which uses the View Block Class to display the message “Hello World”. Create a template (phtml) called myview.phtml in the following directory: appdesignfrontenddefaultdefaulttemplatemymodulemyview.phtml.

9)The module is now ready for use. You can view the output by two ways.

1) {{block type=”mymodulepack_mymodule/view”  template=”mymodule/myview.phtml” }}

2) <reference name=”right”>
<block type=”mymodule/view” name=”mymodule”        template=”mymodule/myview.phtml”/>
</reference>

At Biztech Consultancy - India based website development Company, we offer an efficient Magento Development & Magento customization services for ecommerce website development at competitive price. Our Magento developer helps in Magento Themes development, Magento Design Integration, Magento module development, magento custom module development, Magento Custom Development, etc.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值