{{block type=”cms/block” block_id=”block-id”}}
Monthly Archives: December 2012
Add Static Block to CMS Page Magento
{{block type=”cms/block” block_id=”block-id”}}
Magento Custom Query Modify Category Page Layout
Run the below given script . It will set the value “’three_columns’” to the field “Page Layout” of all categories .
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$updateQry = “UPDATE catalog_category_entity_varchar SET value=’three_columns’ WHERE attribute_id=’61’ “;
$write->query($updateQry);
Magento Custom Query Insert Data
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$insertQry = “INSERT INTO customer_entity_int (entity_type_id, attribute_id) VALUES(1, 224)”;
$write->query($insertQry);
Magento Custom Query Update Data
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$updateQry = “UPDATE catalog_category_entity_varchar SET value=’three_columns’ WHERE attribute_id=’61’ “;
$write->query($updateQry);
Magento Custom Query Select Data
$read = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);;
$selectQry = “SELECT * FROM catalog_category_entity”;
$write->query($selectQry);
How to write a Custom SQL Query Magento
To select the data
$read = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);;
$selectQry = “SELECT * FROM catalog_category_entity”;
$write->query($selectQry);
To add/modify data
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$updateQry = “UPDATE catalog_category_entity_varchar SET value=’three_columns’ WHERE attribute_id=’61’ “;
$write->query($updateQry);
Magento Custom Query
To select the data
$read = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);;
$selectQry = “SELECT * FROM catalog_category_entity”;
$write->query($selectQry);
To add/modify data
$write = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
$updateQry = “UPDATE catalog_category_entity_varchar SET value=’three_columns’ WHERE attribute_id=’61’ “;
$write->query($updateQry);
Magento Observer Events
Magento uses a fantastic event hooking system, following the Observer Design Pattern, allowing additional functionality to be plugged in and out without modifying the core code.
This list of events is automagically extracted directly from the Magento codebase. It’s pretty unlikely that anything was missed but if you do notice something, get in touch.
Get latitude and longitude from address PHP
<?php
$country = “IN”;
$state = “Kerala”;
$city = “Kochi”;
$zipcode = “682030”;
$address = “PHPCodez”;
$query_string = “$country+$state+$city+$zipcode+$address”;
$address_encode = urlencode($query_string);
$geocode = ‘http://maps.google.com/maps/geo?q=’.$address_encode.’&output=json&sensor=false’;
$data = file_get_contents($geocode);
$output= json_decode($data);
if($output->Status->code == ‘620’){
sleep(2);
$geocode = ‘http://maps.google.com/maps/geo?q=’.$address_encode.’&output=json&sensor=false’;
$data = file_get_contents($geocode);
$output= json_decode($data);
} elseif ($output->Status->code == ‘602’){
$query_string = “$country+$state”;
$address_encode = urlencode($query_string);
$geocode = ‘http://maps.google.com/maps/geo?q=’.$address_encode.’&output=json&sensor=false’;
$data = file_get_contents($geocode);
$output= json_decode($data);
$longitude_long = $output->Placemark[0]->Point->coordinates[0];
$latitude_lat = $output->Placemark[0]->Point->coordinates[1];
if(($longitude_long == ”) && ($latitude_lat == ”)) {
$query_string = “$country”;
$address_encode = urlencode($query_string);
$geocode = ‘http://maps.google.com/maps/geo?q=’.$address_encode.’&output=json&sensor=false’;
$data = file_get_contents($geocode);
$output= json_decode($data);
}
}
echo $longitude = isset($output->Placemark[0]->Point->coordinates[0])?$output->Placemark[0]->Point->coordinates[0]:”;
echo $latitude = isset($output->Placemark[0]->Point->coordinates[1])?$output->Placemark[0]->Point->coordinates[1]:”;
?>