Magento PHP Security

Magento : How to apply SUPEE-5344 and SUPEE-1533 from the Magento Community Edition

Urgent: Immediately install Magento critical security patches.

It is critical for you to download and install 2 previously-released security patches (SUPEE-5344 and SUPEE-1533) from the Magento Community Edition download page (

1. Go to and download the right version of patches.

2. Upload your files into Magento root directory. It is important to place patch files directly into Magento root directory and execute it also directly in Magento root directory.

3. Run the patches like this
# bash ./
Checking if patch can be applied/reverted successfully…
Patch was applied/reverted successfully.

# bash ./
Checking if patch can be applied/reverted successfully…
Patch was applied/reverted successfully.

4. Verify if the patch is added successfully
Test that your store is working fine. Login to admin and clear all the cache from cache management and flush other PHP opcode caches(APC/XCache/eAccelerator) if you are using, otherwise code will continue to run from caches.

Verify that your store have green SAFE status at

Please read below if you get errors while running the above bash command.

Note – While running the bash commands mentioned in step 3, if you get errors like below-:
Error! Some required system tools, that are utilized in this sh script, are not installed:
Tool(s) “patch” is(are) missed, please install it(them).
Then you need to first install patch like this

# yum install patch

4. Once you install the patch then follow the step 3.


If you are using a shared hosting or don’t have ssh access to install the security patches then please follow this link – How to apply SUPEE-5344 and SUPEE-1533 without SSH

Magento PHP

Magento : How to Convert Price from Current Currency to Base Currency

If in some case you want to convert the price to base corrency in Magento then there is a very simple function available ‘currencyConvert()’ but this function is NOT WORKING in magento community 1.7 version.

$from 		= 'USD';
$to 		= 'NPR';
$price 		= 10;
$newPrice 	= Mage::helper('directory')->currencyConvert($price, $from, $to);


magento convert price in base currency
I tried another way to solve this. You can use the below working code to get the price in base currency.

//	Convert price to base currency from current currency
$totals 	= 	Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
$subtotal 	= 	$totals["subtotal"]->getValue();
// Base Currency
$baseCurrencyCode 		= 	Mage::app()->getStore()->getBaseCurrencyCode();
// Current Currency
$currentCurrencyCode 	= 	Mage::app()->getStore()->getCurrentCurrencyCode();
if( $baseCurrencyCode != $currentCurrencyCode ){
	// Allowed currencies
	$allowedCurrencies 	= 	Mage::getModel('directory/currency')->getConfigAllowCurrencies();
	$rates 				= 	Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
	$convertedSubtotal	=	$subtotal / $rates[$currentCurrencyCode];	
	$convertedSubtotal	=	$subtotal;