Magento Usefull code

Find out what modules we used in our Magento:

Basically, once magento website is developed with the help of magento modules and custom module (our own module), we can find out the what and all module we had used in our magento website, simply we can use with below code. Below code will return our magento module (which we used) name with array format.
Ex:
$modules = array_keys((array)Mage::getConfig()->getNode(‘modules’)->children());
Output:
Array
(
[0] => Mage_Core
[1] => Mage_Eav
[2] => Mage_Page
[3] => Mage_Install
[4] => Mage_Admin
…..
….
)

How to check out module is Enabled (or) Disabled in Magento:
whenever going to use our own custom moudle (not only custom, core modules also we can use) simply dont call your functionality code any where in the magento files, before your code please add below condition and write your code. Below code will helpful when your module is disabled. This code will return, your module is currently enabled or disabled state. If enabled , there is no issue with your code (wherever you may write) it will continue with our error. But if module is an disabled then you will get the error message. For resolving those issues use below line and check the condition
Ex:
Namespace_Modulename => Jute_Custommodule
$myModuleEnableDisable = Mage::getConfig()->getModuleConfig(‘Namespace_Modulename’)->is(‘active’, ‘true’)
if($myModuleEnableDisable){
echo “Yes,Jute_Custommodule module is Enabled”;
}else{
echo “Jute_Custommodule module is Disabled”;
}

Find out Class name is magento:
In magento simply we will call like ” Mage::getModel(‘catalog/product’)->load(ID);”. But how can i find, for this class name ?

Ex:
$product = Mage::getModel(‘catalog/product’);
echo get_class($product);

Leave a Reply