Simple Steps to Customize the Magento Site Core
Do you want to make some relevant changes to the core of Magento Installation? While it is possible, you will need to take extra care of what you are changing. You should ensure that no extra changes are made; else it will change the basics of your website.
Few basic things that you should check on before changing the core would be
1. You can make relevant changes later
2. Nothing can be overwritten
3 .You can customize your core once again whenever the need arises
The Configuration Files
Magento merges different XML files into one XML file which is both global and cached. With this you can easily edit all the core files manually and customize to your needs.
Below is the code using which two XML configuration files will be combined to form a single XML file which is both cached and global.
A. First Configuration File
<?xml version="1.0"?>
<config>
<node1>
<node1_1>Data1</node1_1>
</node1>
<node2>Data2</node2>
</config>
B. Second Configuration File
<?xml version="1.0"?>
<config>
<node1>
<node1_2>Data3</node1_2>
</node1>
<node2>Data4</node2>
<node3>Data5</node3>
</config>
C. Combination of the Two Configuration Files
<?xml version="1.0"?>
<config>
<node1>
<node1_1>Data1</node1_1>
<node1_2>Data3</node1_2>
</node1>
<node2>Data4</node2>
<node3>Data5</node3>
</config>
Files Used for Configuration
Before beginning with the configuration, initialize the system with init(). You can read about how to use this function by following this path: app/code/core/Mage/core/Model/Config.php
Let’s say config cache for Magento core is enabled, and it is loaded successfully to your system when you open it using the above mentioned path, then you can easily skip the below mentioned steps. Else you will need to manually load it to your system. Here are the steps you can use to manually load
1. First load app/etc/config.xml. If you want to successfully load all the elements present in the Magento core, you will need to make sure this file is loaded
2. Now merge all the files present in app/etc/modules/(app/etc/modules.xml till you reach 0.6.14100). if there are any modules declarations they are removed by the core or community or custom installations. They are then named using Package name (Mage_All.xml)
3. Once you have installed, it is time to merge them using Merge app/etc/local.xml. This file has all the settings for the local database along with installation date and the encryption key
4. In case you are unable to locate the local file, app/etc/distro.xml will get merged. This contains all the auto values needed for installation
5. Finally merge config.xml using the different modules declared earlier in app/etc/modules/*. The modules declared include: app/code/{codepool}/{companyName}/etc/config.xml
Defining the Model
Model is a set of specific classes that offer resource specific logic. It is important to know how to define or create a new model in Magento core
Let’s begin with Sample_module
<?xml version="1.0"?>
<config>
<modules>
<Sample_Module>
<codePool>local</codePool>
<active rel="nofollow" target="_blank">true</active>
</Sample_Module>
</modules>
</config>
Once you have defined the module, you will need to create the config file: app/code/local/Test/Module/etc/config.xml
Here’s the code that will help create the config xml
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<class>Sample_Module_Model</class>
</Sample_mod>
Using Mage function and the above code, you will be returned the value Sample Module
Mage::getModel('sample_mod/test_model')
The value returned will actually be located in the following path
app/code/local/Example/Module/Model/Test/Model.php
Along with test_model, example_module_model is able to generate the required class for customization
Customizing the Core
Customizing the core actually means changing the functionalities to suit your needs without really changing the basics of the file. A module sample_module has been created. Now let’s override this with sample_custom to understand how core files are customized without really disturbing the functionalities.
You will define the new model in the same way as you will define the sample_module
You need to ensure that the application does not break and for this, you will need to offer all classes within the original inside the custom module.
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<class>Example_Custom_Model</class>
</example_mod>
Overriding a single class to understand customization
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<rewrite>
<test_model>Example_Custom_Model_Test_Model</test_model>
</rewrite>
</example_mod>
The value returned would be
Example_Custom_Model_Test_Model which will include functionalities present with in Example_Module_Model_Test_Model along with some extended functionalities that were added
Setting up Helpers
Helpers are nothing but support classes. They help in manipulating the data and rendering them as you want
You can make the changes in *.phtml templates or *.xml files
Apart from manipulations you can also use helpers to cache your website
$this->helper('wishlist'); // wishlist module; data.php helper
$this->helper('catalog/image'); //catalog module; image.php helper
$this->helper(); //current module; data.php helper
Setting up Admin Menu
It is important to set up your admin menu when customizing the Magento core.
You will find the setup in app/code/core/Mage/Adminhtml/etc/config.xml
You can copy paste the xml file to this and then carry out customization. You can even add it to any other configuration file and merge the two files as mentioned earlier.
Author bio:
Deepa is a passionate blogger associated with Silver Touch Technologies., a leading Offshore Magento Development Company. She loves sharing information regarding Magento and Wordpress tips & tricks. If you are looking for Hire WordPress Developers or Magento Developers then just get in touch with her.
Few basic things that you should check on before changing the core would be
1. You can make relevant changes later
2. Nothing can be overwritten
3 .You can customize your core once again whenever the need arises
The Configuration Files
Magento merges different XML files into one XML file which is both global and cached. With this you can easily edit all the core files manually and customize to your needs.
Below is the code using which two XML configuration files will be combined to form a single XML file which is both cached and global.
A. First Configuration File
<?xml version="1.0"?>
<config>
<node1>
<node1_1>Data1</node1_1>
</node1>
<node2>Data2</node2>
</config>
B. Second Configuration File
<?xml version="1.0"?>
<config>
<node1>
<node1_2>Data3</node1_2>
</node1>
<node2>Data4</node2>
<node3>Data5</node3>
</config>
C. Combination of the Two Configuration Files
<?xml version="1.0"?>
<config>
<node1>
<node1_1>Data1</node1_1>
<node1_2>Data3</node1_2>
</node1>
<node2>Data4</node2>
<node3>Data5</node3>
</config>
Files Used for Configuration
Before beginning with the configuration, initialize the system with init(). You can read about how to use this function by following this path: app/code/core/Mage/core/Model/Config.php
Let’s say config cache for Magento core is enabled, and it is loaded successfully to your system when you open it using the above mentioned path, then you can easily skip the below mentioned steps. Else you will need to manually load it to your system. Here are the steps you can use to manually load
1. First load app/etc/config.xml. If you want to successfully load all the elements present in the Magento core, you will need to make sure this file is loaded
2. Now merge all the files present in app/etc/modules/(app/etc/modules.xml till you reach 0.6.14100). if there are any modules declarations they are removed by the core or community or custom installations. They are then named using Package name (Mage_All.xml)
3. Once you have installed, it is time to merge them using Merge app/etc/local.xml. This file has all the settings for the local database along with installation date and the encryption key
4. In case you are unable to locate the local file, app/etc/distro.xml will get merged. This contains all the auto values needed for installation
5. Finally merge config.xml using the different modules declared earlier in app/etc/modules/*. The modules declared include: app/code/{codepool}/{companyName}/etc/config.xml
Defining the Model
Model is a set of specific classes that offer resource specific logic. It is important to know how to define or create a new model in Magento core
Let’s begin with Sample_module
<?xml version="1.0"?>
<config>
<modules>
<Sample_Module>
<codePool>local</codePool>
<active rel="nofollow" target="_blank">true</active>
</Sample_Module>
</modules>
</config>
Once you have defined the module, you will need to create the config file: app/code/local/Test/Module/etc/config.xml
Here’s the code that will help create the config xml
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<class>Sample_Module_Model</class>
</Sample_mod>
Using Mage function and the above code, you will be returned the value Sample Module
Mage::getModel('sample_mod/test_model')
The value returned will actually be located in the following path
app/code/local/Example/Module/Model/Test/Model.php
Along with test_model, example_module_model is able to generate the required class for customization
Customizing the Core
Customizing the core actually means changing the functionalities to suit your needs without really changing the basics of the file. A module sample_module has been created. Now let’s override this with sample_custom to understand how core files are customized without really disturbing the functionalities.
You will define the new model in the same way as you will define the sample_module
You need to ensure that the application does not break and for this, you will need to offer all classes within the original inside the custom module.
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<class>Example_Custom_Model</class>
</example_mod>
Overriding a single class to understand customization
<?xml version="1.0"?>
<config>
<global>
<models>
<example_mod>
<rewrite>
<test_model>Example_Custom_Model_Test_Model</test_model>
</rewrite>
</example_mod>
Post customization, app/code/local/Example/Custom/Model/Test/Model.php will appear as follows
<?php
class Example_Custom_Model_Test_Model extends Example_Module_Model_Test_Model
{
public function exampleMethod()
{
return 'custom result';
}
}
Now in the code for $obj= Mage::getModel('example_mod/test_model')class Example_Custom_Model_Test_Model extends Example_Module_Model_Test_Model
{
public function exampleMethod()
{
return 'custom result';
}
}
The value returned would be
Example_Custom_Model_Test_Model which will include functionalities present with in Example_Module_Model_Test_Model along with some extended functionalities that were added
Setting up Helpers
Helpers are nothing but support classes. They help in manipulating the data and rendering them as you want
You can make the changes in *.phtml templates or *.xml files
Apart from manipulations you can also use helpers to cache your website
$this->helper('wishlist'); // wishlist module; data.php helper
$this->helper('catalog/image'); //catalog module; image.php helper
$this->helper(); //current module; data.php helper
Setting up Admin Menu
It is important to set up your admin menu when customizing the Magento core.
You will find the setup in app/code/core/Mage/Adminhtml/etc/config.xml
You can copy paste the xml file to this and then carry out customization. You can even add it to any other configuration file and merge the two files as mentioned earlier.
Author bio:
Deepa is a passionate blogger associated with Silver Touch Technologies., a leading Offshore Magento Development Company. She loves sharing information regarding Magento and Wordpress tips & tricks. If you are looking for Hire WordPress Developers or Magento Developers then just get in touch with her.
Advertise on APSense
This advertising space is available.
Post Your Ad Here
Post Your Ad Here
Comments