Adding A CSS Class To The Body Tag
To add a class via layout XML:
<reference name="root">
<action method="addBodyClass"><classname>whatever</classname></action>
</reference>
Or to add via code, from a controller or block
if ($root = $this->getLayout()->getBlock('root')) {
$root->addBodyClass('whatever');
}
Related cards:
Add A Tab To The Admin Product Screen
Declare an admin layout XML file for your module in your config.xml
:
<config>
<adminhtml>
<layout>
<updates>
<your_module>
<file>your-module.xml</file>
...
Add A Tab To The Admin Product Screen
Adding A Tab To The Product Screen
-
Declare an admin layout XML file for your module in your config.xml:
...
Adding A Column to a Flat Table
Handy to add attributes to sales_flat_order:
$installer->getConnection()->addColumn(
$this->getTable('sales/order'),
'some_attribute',
[
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
'length' => ...
Adding A Layout Handle From A Controller
Doing this is a slight pain, to quote what Alan Storm said on StackOverflow:
- If you add your handle before you call $this->loadLayout() from a controll...
Adding Attributes To Other Entities With getDefaultEntities()
Don't do it!! I did the below:
public function getDefaultEntities()
{
return array(
'catalog_product' => array(
'attributes' => array(
'size_guide_id' => array(
...
Adding Attribute To Category List Product Collection
Only a core set of attributes are added to the product collection (for the list page) by default. This bit of XML will allow you to add additional attributes to that collection:
<config>
<frontend>
<product>
...
Using Design Exceptions To Serve a Mobile Theme
In order to serve a different package, or any element of a theme (translations, templates, skin or layout) you can use design exceptions, which allow you to specify different values for each of the design-related settings by using user-agent strin...
Creating a Datetime attribute that stores time
Magento has a Datetime backend model but formats a Zend_Date
object without the time. So if you want to store datetime (actually with time) you will need to setup your own backend model.
Here is how i've done it:
class Namespace_Module_Mod...
Converting A Quote Attribute To An Order
<config>
<global>
<fieldsets>
<sales_convert_quote>
<some_attribute>
<to_order>*</to_order>
</some_attribute>
</sales_convert_q...
Cause FPC To Cache A Route
<config>
<frontend>
<cache>
<requests>
<frontname>
<controller>
<action>enterprise_pagecache/processor_category</action>
...