Magento change attribute scope in setup script

This code snippet shows how to change attribute scope in a setup script:

And the config.xml:


Force HTTPS for the whole store

Since Magento 1.9.1 you can force HTTPS for the whole shop by adding the following configuration-snipped to /app/etc/config.xml or any module config.xml (own module!!!):

After cleaning the config cache, Magento should generate secure URLs everywhere. That’s how to force secure URL’s in Magento.

Create your own Backend theme

When developing Magento Backend functionalities, sometimes you need to add own layout files or templates. In these cases it is a good idea to create a new Backend theme under adminhtml and to modify the Magento configuration to lookup layout files and templates in this new theme before searching in the default one. Therefore you have to create […]

Install attribute in entity main table

Sometimes it is useful to add some fields to the attribute main table (f.e.: IDs from external systems like a middleware or a PIM). In the following example you can see how to add ID-fields to the category entity. Therefore I created a setupscript as an instance of Mage_Catalog_Model_Resource_Setup. Setup-model declaration in config.xml:

Setup-script: […]

Rewrite exiting Magento models

To rewrite exiting Magento models, you can add the following snippet to your modules config.xml:

In this case Mage_Checkout_Model_Session and Mage_Checkout_Model_Type_Onepage are rewritten.

Translation files for custom modules

To register a translation file for your module:

As you can see, you can use the same file for frontend and backend.

Magento – Define default values in config.xml

You can define system config value defaults in your modules config.xml like that.

This sets the default value for all stores. If you want to set default values for a special store (scope), you can do it this way:

If you want to set default values on website scope, you can do it […]

Register helper class

To register a helper for your module, you can add the following snippet inside the global tag of your config.xml:

Event Observer

The following snippet have to be added to the config.xml under the frontend (for FE-events) – or the adminhtml (for BE-Events) – tag:


Automatically load custom product attribute with collection (every time)

You can do this with the following XML in your config.xml:

But ATTENTION: This can become a performance issue, because it loads the attribute every time the product collection is loaded! If you added too many attributes, the performance can get worse!