if(isset($_FILES['import_file']['name']) && $_FILES['import_file']['name'] != '')
{
$uploaderFile = new Varien_File_Uploader('import_file');
$uploaderFile->setAllowedExtensions(array());
$uploaderFile->setAllowRenameFiles(false);
$uploaderFile->setFilesDispersion(false);
$uploaderFilepath = Mage::getBaseDir('media') . DS . 'importcsv' . DS ;
$uploaderFile->save($uploaderFilepath, $_FILES['import_file']['name'] );
$file = $_FILES['import_file']['name'];
$filepath = $uploaderFilepath.$file;
$i = 0;
if(($handle = fopen("$filepath", "r")) !== FALSE) {
while(($data = fgetcsv($handle, 1000, ",")) !== FALSE){
if($i>0 && count($data)>1){
updateData($data);
}
$i++;
}
}
else{
Mage::getSingleton('adminhtml/session')->addError("There is some Error");
$this->_redirect('*/*/index');
}
}
function updateData($data)
{
//Write your code here and Update it to magento tables
}
Thứ Sáu, 16 tháng 9, 2011
How to upload and read csv file in magento
Thứ Ba, 30 tháng 8, 2011
How to get contact us email address in magento
Here’s the code to get Contacts email:
<?php echo Mage::getStoreConfig('contacts/email/recipient_email');?>
Or you can change it from admin -> System-> Configuration. From the left tab select Contacts then On the right side you will see Email Options Tab. From that tab you can see there is a field for send Emails To.Change th evalue to your require email address
Thứ Năm, 4 tháng 8, 2011
How to uncheck Radio button by jquery
Write the Below code to Unchecked Radio Button by Jquery
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function(){
$('input[name="rd"][type="radio"]:checked').each(function(){
$(this).attr("checked", false);
});
});
});
</script>
<form action="" name="aa" method="post">
<input type="radio" name="rd" value="1"/>
<input type="radio" name="rd" value="2"/>
<input type="radio" name="rd" value="3"/>
<input type="button" id="btn" value="Click" />
</form>
How to change value and fetch value of Minimum Order Amounts of free shipping in magento
First of all to make Minimum Order Amounts of Free Shipping to [STORE VIEW] instead of [WEBSITE] then Go to app->code->core->Mage->Shipping->etc->System.xml
then change the value of <show_in_store> to 1 under carriers -> groups -> freeshipping ->free_shipping_subtotal.
Now to fetch the value of the Minimum Order Amount according to store view write the below code
<?php echo Mage::getStoreConfig('carriers/freeshipping/free_shipping_subtotal'); ?>
Thứ Sáu, 29 tháng 7, 2011
How to remove validation on zip code in magento checkout page
In the World some of the country has no zip code like Ireland, But magento has default zip code validation to make that optional for specific country magento has added a new feature in admin panel. To make Zip code optional please follow the following steps.
Login to your your magento admin panel then go to System -> Configuration->General. From Country option tab you can see there is an option " Postal code is optional for the following countries " Select the country which you want to Optional/Not validate . then click on save config to save your settings. To be more clear on this please see the below screenshot.
Thứ Bảy, 16 tháng 7, 2011
How to change default quantity on Magento Product Page
By default magento shows zero in the place of quantity text field in product details page, if you wish to change then just login to your admin panel go to System->Configuration->Catalog->inventory.
There, add your minimal quantity from Minimum Qty Allowed in Shopping Cart
See the below screenshot to make it more clear
Thứ Năm, 16 tháng 6, 2011
How to change css padding property using javascript dynamically
Using Javascript we can change css value. Here I have written how to change the value of padding top, padding bottom, padding left, padding right differently.
var ab = 20;
//To change Padding-top value write
document.getElementById("div_Id").style.paddingTop = ab.toString()+"px"
//To change Padding-left value write
document.getElementById("div_Id").style.paddingLeft = ab.toString()+"px"
//To change Padding-right value write
document.getElementById("div_Id").style.paddingRight = ab.toString()+"px"
//To change Padding-bottom value write
document.getElementById("div_Id").style.paddingBottom = ab.toString()+"px"