0% found this document useful (0 votes)
2K views

Magento Cheatsheet

Magento Cheat Sheet extensionprogrammer.com Event-Observer singleton module / observer catalogProductLoadAfter Area:,,adminhtml",,,frontend" oder,,global" Event Code Must be unique within the event observer.,,model" or,,singleton" Rewrite Controllers Namespace_Module_Overwrite_Checkout Router node of the module to be overridden (look it up in the config.xm

Uploaded by

Julien Vasseur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Magento Cheatsheet

Magento Cheat Sheet extensionprogrammer.com Event-Observer singleton module / observer catalogProductLoadAfter Area:,,adminhtml",,,frontend" oder,,global" Event Code Must be unique within the event observer.,,model" or,,singleton" Rewrite Controllers Namespace_Module_Overwrite_Checkout Router node of the module to be overridden (look it up in the config.xm

Uploaded by

Julien Vasseur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Event-Observer Rewrite Controllers

Magento Cheat Sheet extensionprogrammer.com <config>


<frontend> [1]
<config>
<frontend> [1]
<events> <routers>
<catalog_product_load_after> [2] <checkout> [2]
<observers> <args>
<yourModule> [3] <modules>
<type>singleton</type> [4] <yourModule
<class>module/observer</class> [5] before=“Mage_Checkout“>Namespace_Module_Overwrite_Checkout</yourModule> [3]
<method>catalogProductLoadAfter</method> [6] </modules>
</yourModule> </args>
</observers> </checkout>
</catalog_product_load_after> </routers>
</events> </frontend>
</frontend> </config>
</config> [1] Depending on the controllers area „frontend“ or „admin“

© der-modulprogrammierer.de, Vinai Kopp


[1] Area: „adminhtml“, „frontend“ oder „global“. [2] Router node of the module to be overridden (look it up in the config.xml of that module)
[2] Event Code [3] The tag <yourModule> can be anything, it must be unique within the <modules> node.
[3] Must be unique within the event observer. Your_Module_Overwrite_Checkout (is mapped to directory)
[4] „model“ or „singleton“ Your/Module/controllers/Overwrite/Checkout/
[5] Your_Class_Name oder module/class
[6] The method to be called on the observer instance.
Rewrite a Model/Block/Helper
Register Module Controllers <config>
<global>
<config> <models> [1]
<frontend> [1] <sales> [2]
<routers> <rewrite>
<yourModule> [2] <order_item>Namespace_Module_Model_Sales_Order_Item</order_item> [3]

Magento Developer Cheatsheet (v1.2 2010-04-21) Präsentiert von ecommerce-schulungen.de


<use>standard</use> [3] </rewrite>
<args> </sales>
<module>Namespace_Module</module> [4] </models>
<frontName>yourmod</frontName> [5] </global>
</args> </config>
</yourModule> [1] Depending on object type „models“, „helpers“ or „blocks“
</routers> [2] Modul shorthand
</frontend> [3] The tag is the class to override, the content is the full name of the replacement class.
</config>
[1] Depending on the controllers area „frontend“ or „admin“
[2] Must be unique Define a Model / Block / Helper module shorthand
[3] „admin“ for Adminhtml controllers, otherwise „standard“
<config>
[4] Namespace and Name of the Module as defined in the <config><modules> node
<global>
[5] The URL part to point to the controller directory (e.g. http://example.com/yourmod) <models> [1]
Magento will look in Namespace/Module/controllers/ for the called controller. <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.
The most common layout XML Questions & Answers
Magento Cheat Sheet extensionprogrammer.com Update Handles:
How do I get the Magento Home URL?
<default> Always applied Mage::getBaseUrl();
<[module]_[controller]_[action]> Applied when the matching action is
called, e.g.: catalog_product_view when a
How do I get the Magento Home Directory?
Mage::getBaseDir();
customer views a product detail page.
<customer_account> Applied on all pages of the customer account. How do I get the URL of a file in the skin directory?
<catalog_category_default> Applied on all category pages without the $this->getSkinUrl(‘images/myfile.png’); // in a template or Block
Mage::getDesign()->getSkinUrl(‘images/myfile.png’); // from anywhere
layered navigation (Is Anchor = No).
<catalog_category_layered> Applied on all category pages with active How do I format a price value?
layered navigation (Is Anchor = Yes). Mage::helper(‘core’)->formatPrice($amount);

Tags: How do I get the display value of a (multi-)select product attribute?

© der-modulprogrammierer.de, Vinai Kopp


<block type=“module/class“ Creates an instance of the specified type. The echo $product->getAttributeText(‘manufacturer’);
name=“name_in_layout“ as=“alias“ name_in_layout must be unique. The alias
template=“path/to/the/template.phtml“/> How do I create an object instance in magento?
must be unique within the parent block.
Mage::getModel(‘module/class’); // for models
<reference name=“name_in_layout“> Applies the contained layout updates to the Mage::helper(‘module/class’);
// for helpers
block specified in <reference name=“...“>. Mage::app()->getLayout()->createBlock(‘module/class’, ‘name_in_layout’); // for blocks

<update handle=“update_handle_name“/> Applies the layout updates specified in the How do I get at GET/POST parameters?
update handle „update_handle_name“. Mage::app()->getRequest()->getParam(‘param_name’); // single parameter
<remove name=“name_in_layout/> Unsets the block with the Mage::app()->getRequest()->getParams(); // all parameters
name „name_in_layout“.
How do I get the Id of the curent store view?
<action method=“nameOfTheMethod“/> Using the <action> tag any public method Mage::app()->getStore()->getId();

Magento Developer Cheatsheet (v1.2 2010-04-21) Präsentiert von ecommerce-schulungen.de


can be called on Block Instances. Strings can
be passed as arguments (see next example), How do I get all Store Views?
or the return value of a helper method can Mage::app()->getStores(); // pass true to include the admin store view, too
be used to pass complex values (e.g. <url
helper=“customer/getAccountUrl“/>). How do I get the configurable/grouped/bundled
product a simple product belongs to?
<action method=“unsetChild“> Removes the block with the specified alias
<name>alias</name> $simpleProduct->loadParentProductIds();
from the list of sub-blocks from the containing $parentProductIds = $simpleProduct->getParentProductIds();
</action>
block. The parent must be specified using
<reference>. The removed block instance How do I get the simple products assigned to a configurable product?
still exists and can be assigned to a different $configProduct->getTypeInstance()->getUsedProductCollection($configProduct);
block using <insert> (see next example).
How do I get an instance of an attribute?
<action method=“insert“> Inserts the block with the name „name_
Mage::getSingleton(‘eav/config’)->getAttribute($entityType, $attributeCode)
<name>name_in_layout</name> in_layout“ as a sub-block to the current
</action>
block specified with <reference>.
<action method=“setTemplate“> Set the template for the current block.
<template>path/template.phtml</template>
</action>
<action method=“addLink“> Only usable on block types page/template_
links and customer/account_navigation, but be
careful: the parameters for both classes differ.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy