Categories
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 (https://www.magentocommerce.com/products/downloads/magento/).

1. Go to https://www.magentocommerce.com/products/downloads/magento/ 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 ./PATCH_SUPEE-1533_EE_1.12.x_v1-2015-02-10-08-19-16.sh
Checking if patch can be applied/reverted successfully…
Patch was applied/reverted successfully.

# bash ./PATCH_SUPEE-5345_CE_1.7.0.2_v1-2015-02-10-08-11-22.sh
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 https://shoplift.byte.nl

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.

Source

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

Categories
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.

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

Source

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.

<?php
//	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];	
}else{
	$convertedSubtotal	=	$subtotal;
}
?>

Source