当前位置

网站首页> 程序设计 > 开源项目 > 程序开发 > 浏览文章

Magento XML cheatsheet

作者:小梦 来源: 网络 时间: 2024-08-02 阅读:

Event Observer

<config>  <frontend> [1]    <events>      <catalog_product_load_after> [2]      <observers>        <yourModule> [3]          <type>singleton</type> [4]<class>module/observer</class> [5]          <method>catalogProductLoadAfter</method> [6]        </yourModule>      </observers>      </catalog_product_load_after>    </events>  </frontend></config>

[1] Area: adminhtml, frontend, oder, global
[2] Event Code
[3] Must be unique within the event observer.
[4] "model" or "singleton"
[5] Your_Class_Name oder module/class
[6] The method to be called on the observer instance.

Rewrite Controllers

<config>  <frontend> [1]    <routers>      <checkout> [2]        <args>          <modules><yourModule          before="Mage_Checkout">Namespace_Module_Overwrite_Checkout</yourModule> [3]          </modules>        </args>      </checkout>    </routers>  </frontend></config>

[1] Depending on the controllers area "frontend" or "admin"
[2] Router node of the module to be overridden (look it up in the config.xml of that module)
[3] The tag <yourModule> can be anything, it must be unique within the <modules> node.
Your_Module_Overwrite_Checkout (is mapped to directory)
Your/Module/controllers/Overwrite/Checkout/

Register Module Controllers

<config>  <frontend> [1]    <routers>      <yourModule> [2]        <use>standard</use> [3]        <args>          <module>Namespace_Module</module> [4]          <frontName>yourmod</frontName> [5]        </args>      </yourModule>    </routers>  </frontend></config>

[1] Depending on the controllers area "frontend" or "admin"
[2] Must be unique
[3] "admin" for Adminhtml controllers, otherwise "standard"
[4] Namespace and Name of the Module as defined in the <config><modules> node
[5] The URL part to point to the controller directory (e.g. http://example.com/yourmod)
Magento will look in Namespace/Module/controllers/ for the called controller.

Rewrite a Model/Block/Helper

<config>  <global>    <models> [1]      <sales> [2]        <rewrite>          <order_item>Namespace_Module_Model_Sales_Order_Item</order_item> [3]        </rewrite>      </sales>    </models>  </global></config>

[1] Depending on object type "models", "helpers" or "blocks"
[2] Modul shorthand
[3] The tag is the class to override, the content is the full name of the replacement class.

Define a Model / Block / Helper module shorthand

<config>  <global>    <models> [1]      <yourModule> [2]        <class>Namespace_Module_Model</class> [3]      </yourModule>    </models>  </global></config>

[1] Depending on object type "models", "helpers" or "blocks"
[2] The module shorthand, must be unique for the module
[3] Classname prefix, will replace the shorthand [2] when resolving a class name.

热点阅读

网友最爱