Wednesday, November 21, 2012
magento:IP SPECIFIC LANGUAGE
First download currency switcher from
http://www.magentocommerce.com/magento-connect/auto-currency-switcher-8671.html
//CODE TO DISPLAY LANGUAGE ACCORDING TO IP ADDRESS
if(Mage::getConfig()->getModuleConfig('Chapagain_AutoCurrency')->is('active', 'true'))
{
$geoIp = Mage::helper('autocurrency')->loadGeoIp();
$ipAddress = Mage::helper('autocurrency')->getIpAddress();
// get country code from ip address
$countryCode = geoip_country_code_by_addr($geoIp, $ipAddress);
$germancountries=array('CH','DE');
if(!isset($_COOKIE['frontstoreloc']))
{
//$siteurl= $this->getUrl();
$siteurl= "http://".$_SERVER['SERVER_NAME'];
setcookie("frontstoreloc",session_id(),time()+60*60*24,"/","");
switch(trim($countryCode))
{
case 'CH':
$url = $siteurl . '?___store=german';
header( 'Location:' . $url);die;
break;
case 'DE':
$url = $siteurl . '?___store=german';
header( 'Location:' . $url);die;
break;
case 'IN':
$url = $siteurl . '?___store=english';
header( 'Location:' . $url);die;
break;
default:
$url = $siteurl . '?___store=usa';
header( 'Location:' . $url);die;
break;
}
}
}
MAGENTO GET STORE SPECIFIC ATTRIBUTE LABEL:
<?php echo $_product->getResource()->getAttribute($_attribute->getAttributeId())->getStoreLabel();?>
Magento invoice pdf : display custom options in one line
open default.php
at path:
app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice
//REPLACE THE LINES one that starts with if ($options) {
//foreach ($options as $option) { with the followin lines.
$options = $this->getItemOptions();
if ($options) {
foreach ($options as $option) {
if ($option['value']) {
$_printValue =
isset($option['print_value']) ? $option['print_value'] :
strip_tags($option['value']);
$values = explode(', ',
$_printValue);
foreach ($values as $value) {
$optlabel=
Mage::helper('core/string')->str_split(strip_tags($option['label']), 70,
true, true);
$optval =
Mage::helper('core/string')->str_split($value, 50, true, true);
$lines[][] = array(
'text' =>
htmlspecialchars_decode ($optlabel[0]." : ".$optval[0]),
'feed' =>35
);
}
}
}
}
Magento REMOVE CACHE INVALIDATION ERROR(THOUGH IT'S NOT A BUG ;))
YOU HAVE TO PUT CACHE CLEAR CODE SOME WHERE IN ADMIN PHTML FILE.
i put that code in head.phtml
file:
head.phtml
path:
app/design/adminhtml/default/default/template/page
<?php
try {
Mage::app()->getCacheInstance()->cleanType('block_html');
} catch (Exception $e) {
// do something
error_log($e->getMessage());
}
?>
Subscribe to:
Posts (Atom)