Get Attribute label easily on Magento

Posted on Updated on

 private static function getAttributeLabel($attributeCode)
$query = “SELECT frontend_label FROM eav_attribute WHERE attribute_code = ‘”.$attributeCode.”‘;”;
$data = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’)->fetchOne($query);
return $data;


Get Category by Product and Store – Magento with direct SQL

Posted on Updated on

  private static function getCategoryByProductAndStore($productId, $storeId, $isParent = 0)
$query = ‘SELECT category_id FROM `catalog_category_product_index` WHERE product_id = ‘ . $productId
. ‘ AND store_id=’ . $storeId . ‘ AND is_parent=’ . $isParent . ‘;’;
$data = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’)->fetchAll($query);
return $data;

Calling to functions of Magento

Posted on Updated on

On your Config.xml

<?xml version=”1.0″?>



Calling Model

calling Helper

How to build a Network with Virtual Box

Posted on Updated on

For developers, sometimes we need to work on several Operating systems with Virtual Machines. Oracle Virtual Box is free and a better solution for virtual machines. When you need to create a small network with Active directory, you have to install the virtual machine as following settings. This worked for me.

Virtual Box for AD Settings

After setting above you can add your host machine to the AD of the server you have setup on the virtual machine.

On windows 8 it is very convenient to switch between the two different systems.

ereg_replace deprecated

Posted on

$hex = ereg_replace(“#”, “”, $hex);


$hex = preg_replace(‘/#/’, ”, $hex);

Remove trailling slashes on Magento

Posted on Updated on

Tailing slash can be removed using followings on .htaccess file with rewrite module

Options +FollowSymLinks
RewriteEngine on

RewriteBase /
RewriteCond %{REQUEST_URI} !^/checkout.*$
RewriteCond %{REQUEST_URI} !^/index.php\/admin.*$
RewriteRule ^(.+)/$ /$1 [L,R=301]

How to fix one cent of additional price added on total as tax and rounding on Magento

Posted on Updated on

Go to System->Configuration->SALES->Tax->Calculation Settings

Set the Calculation Method Based On Row Total.

Row total will calculate based on each item total. Sot it will be accurate than calculating tax on Total. This will fix the issue of one cent hat could be shown as a rounding issue.

The setting can be used as the rules and lows of taxation on relevant country but here if there is no restriction, issue will be fixed.

Magento Tax on Row