Websites, Stores, Store Views

Here is what can be set at each level:

Default Web Site Store Store View
Product attributes X X
Product prices X X
Product tax class X X
Base currency X X
(Default) display currency X X
Category settings X X
System configuration settings X X X
Root category configuration X
Orders X
Customer sharing X X

Thanks to F...

View Status of EE Mview Changelog Tables

This SQL:

select emm.view_name,
    emm.version_id as metadata_version,
    cl_max_versions.max_version as cl_version,
    (cl_max_versions.max_version - emm.version_id) as behind
from enterprise_mview_metadata emm
left join (
    select 'enterprise_url_rewrite_redirect' as view_name, max(version_id) as max_version from enterprise_url_rewrite_redirect_cl union
    select 'cataloginventory_stock_status_view' as view_name, max(version_id) as max_version from cataloginventory_stock_status_cl union
    select 'enterprise_url...

Security problem: {block} has not been whitelisted

This is introduced by either SUPEE-6788, or Magento See the link.


The XMLRPC API parameters always confuse me, they're below:


<?xml version="1.0"?>

Order list:

<?xml version="1.0"?>

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_Model_Entity_Attribute_Backend_Datetime extends Mage_Eav_Model_Entity_Attribute_Backend_Datetime

     * Prepare date for save in DB
     * @param   string | int $date
     * @return  string
    public function formatDate($dat...

Admin Grids - Filtering A Joined Column

Often, you'll want to add a column to a collection used in a grid, and to do so you'd use _prepareCollection():

protected function _prepareCollection()
    $collection = Mage::getResourceModel($this->_getCollectionClass());

           array('table_alias' => 'some_long_table_name'),
           'main_table.something = table_alias.something',
           array('some_column' => 'table_alias.some_column')


Adding A Column to a Flat Table

Handy to add attributes to sales_flat_order:

        'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
        'length' => 1,
        'comment'=> 'Comment'

UK Tax / VAT Setup Script

This script sets up everything for UK VAT from a default install.

/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;

 * Define VAT band names
define('VAT_STANDARD', 'VAT Standard');
define('VAT_REDUCED', 'VAT Reduced');
define('VAT_ZERO', 'VAT Zero');

 * Remove current rules, rates and product classes
$taxCalculation = Mage::getModel('tax/calculation');
foreach (Mage::getModel('tax/calculation_rule')->g...

Generate Test Products

I took this script from somewhere (sorry I forgot where!) but it didn't work for, so I fixed it up. Really basic, but useful, I used it to test pagination:

require 'app/Mage.php';
for ($i = 0; $i < 100; $i++) {

Get Value of Product Attribute

This resolves the value of the attribute, so rather than supplying you with a value ID, it will supply you with the associated value, via the source model:


Non-Required Category Attribute Not Set in Global Scope

When a category is created whilst in a store scope, and a value is set against an attribute which has is_required set to false, and has a scope more specific than global, then a value is not set against the global scope, resulting in the store scope having a value, but the global scope having no value. This also has the effect of causing the flat category table for the store in question to have a null value for the attribute, even in the store scope that it is set in.

On this install, the attribute in question is display_as_link:


Magento Extension Companies

A work-in-progress, this is a list of companies and thoughts about each.

Company Type Comments
AheadWorks General
Mageworx General
Amasty General
Aitoc General
Magestore General
Xtento General
WebShopApps Shipping
Wyomind General
Fooman General ...

Get Methods of Class

Yes, very dirty, but it works a treat! Save this file in your Magento root directory, then fire up a command line and run whatever.php Mage_Core_Model_App (or some other class) and you should see the output.

Output looks like below:

$ ./classmethods.php Varien_Db_Adapter_Pdo_Mysql
__construct                      Zend_Db_Adapter_Abstract      lib/Zend/Db/Adapter/Abstract.php:43
__destruct                       Varien_Db_Adapter_Pdo_Mysql   lib/Varien/Db/Adapter/Pdo/Mysql.php:30
__sleep                          Zend_Db_Ada...

Getting the Theme In Use

How to get the theme for each component, works on the active store:


Layout Loading and Misc Notes

Layout XML files are loaded here via this stack - here we are loading the layout update for the rwd/default design package, for the CMS home page. I've put a dashed line on the demarcation between layout code and other code:


Magento PHP & HTTPD Timeouts









Resetting File & Folder Permissions

You might want to do this on media or elsewhere, handy cut-and-paste job:

find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;

Or with an xargs version (which should be faster):

find media -type d -print0 | xargs -0 chmod 0755
find media -type f -print0 | xargs -0 chmod 0644

Reloading Varnish Config Without a Restart

vcl.load reload01 /etc/varnish/default.vcl
vcl.use reload01

If you do more than one reload, you'll need to use reload02, reload03, etc.

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(
                    'group'                      => 'General',
                    'label'                      => 'Size Guide',
                    'type'                       => 'int',
                    'input'                      => 'select',
                    'source_model'               =>...

Many to Many Resource Model Mapping

This is some boilerplate code to facilitate the use of many-to-many relationship tables in Magento. I found myself rewriting this code often, so this saves some time. This example links a sizeguide entity to attribute sets. Obviously you'll need to make the entity table and the relationship table first, and you'll need to change the code to match your column names, but this gets you most of the way:

Resource Model - Loading and Saving

 * Load the attribute set relations onto an object
 * This is public as we need...

Creating an EAV Entity


A overview for those familiar with making flat models:

  • Your config is standard, your table name takes the form of the base (entity) table
  • You name your resource models as normal (so by class name, you can't tell the difference between flat and EAV)
  • You make your domain model as normal
  • Your resource model extends a different class and has different _construct() code
  • Your resource collection model extends a different class, but is otherwise the same
  • You make your entity and value tables using setup DDL as you would...

Show All Indexes On a DB

Again, not Magento. Very handy though!

WHERE TABLE_SCHEMA = 'your_schema';

Then you can use show indexes from table_name to see more info about the index.

Cross-Border Tax

This one was very confusing. Lets say you have two stores - one in the US, and one in Japan. You can obviously ship to Japan from the Japanese store (same with the US), but you can also ship to Japan from the US store, and vice versa.

You only have Retail Customer as a group (default), and you've got a list of product tax classes which are shared between the US and Japanese store. So off you go on your merry way setting up US and Japanese tax rates and rules to set the tax - great so far, US customers to the US sare charged correctly, same ...