Add custom Javascript in Magento admin form


Magento is flexible enough to insert your custom JavaScript code snippets in forms created by your very own Magento modules & extensions.

Continue reading


How to render custom html in tabs block


Remove _prepareForm() function from your Tab block and add constructor as shown below

class Company_Module_Block_Adminhtml_CustomSettings_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form

    public function __construct()


Create a view.phtml file at design/adminhtml/default/default/template/MODULE_NAME/customsettings

Get custom attribute value in Magento


Simplest way:

echo $_product->getAttributeText('custom_attribute_code');


You will get a fetal error if the attribute is not already registered.

Fatal error: Call to a member function getSource() on a non-object in D:\..\app\code\core\Mage\Catalog\Model\Product.php on line 1389


$attribute = $_product->getResource()->getAttribute('custom_attribute_code');
if ($attribute)
	echo $attribute_value = $attribute ->getFrontend()->getValue($_product);

This code will first check if the attribute code exists and gets its value if its there. integration with Magento


1- Create a test account on (

2- On successful signup you will see following info, save them at safe place.

  1. API Login ID
  2. Transaction Key

3- Login to your Magento Admin panel and navigate to

  1. System -> Configuration -> Payment Methods
  2. Expand
  3. Insert “API Login ID” and “Transaction Key” into this form and make other settings as shown below

6. Save Configuration and you are DONE!

Magento Admin: 404 Error Page not found.


mag-admin-404Let’s suppose you are logged in to Magento admin panel and you are installing a new extension that adds some new sections to Magento Configurations.
You activate your new extension and it adds some new tabs/sections but when you click on newly added tab you see a 404 error, don’t worry!

Solution :

Just logout from admin panel and login again. Cheers!!!

Get Magento root category id

public function getRootCategoryId()
    $categories = Mage::getModel('catalog/category')->getCollection();
    $categ_ids = $categories->getAllIds();
    foreach ($categ_ids as $k => $cat_id)
        $category = Mage::getModel('catalog/category')->load($cat_id);
        if ($category->name)
            return $cat_id;

Set Magento website template, skin and layout programmatically

$groups['theme']['fields']['template']['value'] = 'template_name';
$groups['theme']['fields']['skin']['value'] = 'skin_name';
$groups['theme']['fields']['layout']['value'] = 'layout_name';
$groups['theme']['fields']['default']['value'] = 'template_name';

Alternate method:

$installer->setConfigData('design/theme/template', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/skin', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/layout', 'facebook', 'stores', $store->getId());
$installer->setConfigData('design/theme/default', 'facebook', 'stores', $store->getId());