<style>
.student-details ul li label {
margin-left: 0 !important;
padding-left: 0 !important;
}
.student-details ul li div {
margin-left: 0 !important;
padding-left: 0 !important;
}
.student-offer{background:#fff;
border:1px solid #ccc;
border-radius:2px;
}
.student-details{
margin-top:20px;
margin-bottom:20px;
}
.terms-cdn{
margin-top:50px;
}
.terms-cdn p{
font-family:"open_sansregular"!important;
font-size:14px;
color:#333333
}
.terms-cdn span{
font-family:"open_sanslight"!important;
font-size:14px;
color:#333333
}
.sub-btn{
background: none repeat scroll 0 0 #3ab44a;
border: 1px solid #3ab44a;
border-radius: 4px;
box-shadow: 1px px 0 #3ab44a;
color: #fff;
height: 30px;
width: 137px;
float:right;
cursor:pointer;
font-size:14px;
}
.up-btn{ background: none repeat scroll 0 0 #575759;
border: 1px solid #575759;
border-radius: 4px;
box-shadow: 1px px 0 #575759;
color: #fff;
height: 30px;
width: 137px;
float:left;
text-align:center;
cursor:pointer;
font-size:14px;
}
.up-btn span{ vertical-align:middle; }
.upload { position:absolute; left:0; margin:0; padding:0;right:0; top:0;top: 0; opacity: 0;
z-index: 99999999;
width:40%;cursor:pointer;
font-size:14px;
}
lable.up_msg {
font-size: 11px;
float: left;
margin: 0!important;
padding: 0!important;
}
@media screen and (max-width: 768px) {.student-btn {margin-left: 3%;}}
@media screen and (max-width: 360px) {.student-btn {margin-left: 0!important;}
@media screen and (max-width: 320px) {.up-btn,.sub-btn{width:120px}}
@media screen and (max-width: 360px) {.student-offer{margin-left:15px;
}}
</style>
<?php
date_default_timezone_set("Asia/Bangkok");
ini_set('display_errors',1);
$username = "root";
$password = "";
$hostname = "localhost";
//$username = "shopnineteen";
//$password = "Sh0pN!nt33n19";
//$hostname = "masterdb";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) ;
//$selected = mysql_select_db("shopnine_live",$dbhandle);
$selected = mysql_select_db("shopnine_mar2015",$dbhandle);
require_once ("app/Mage.php");
$sql='';
if(isset($_POST["Import"]))
{
$filename=$_FILES["file_product"]["tmp_name"];
$type=$_FILES["file_product"]["type"];
//print_r($_FILES);
if($_FILES["file_product"]["size"] > 0)
{
$file = fopen($filename, "r");
while (($csvData = fgetcsv($file, 50000, ",")) !== FALSE)
{
if($csvData[0]!="")
{
$product_sku = mysql_escape_string(trim($csvData[1]));
$product_id = Mage::getModel("catalog/product")->getIdBySku( $product_sku );
$sql ="insert into catalog_category_product (category_id, product_id) values ('".mysql_escape_string(trim($csvData[0]))."','".$product_id."')";
$sql1 ="insert into catalog_category_product_index (category_id, product_id,position,is_parent,store_id,visibility) values ('".mysql_escape_string(trim($csvData[0]))."','".$product_id."','0','0','1','4')";
//echo $sql."<br>";
//echo $sql1."<br>";die;
mysql_query($sql);
mysql_query($sql1);
}
}
fclose($file);
echo "CSV File has been successfully Imported";
}
else
echo "Invalid File:Please Upload CSV File";
}
?>
<div class="detail_page">
<div class="container">
<div class="row">
<div class="about-title">
<strong><span>Auto Tagging</span></strong>
</div>
<div class="col-md-10 col-sm-10 col-xs-11 student-offer">
<form name="registration" method="post" enctype="multipart/form-data" class="student-details" >
<div class="fieldset">
<ul class="form-list form-horizontal np">
<li class="wide form-group">
<label class="col-md-4 col-sm-5 control-label ship-desc required" for="comment">Upload CSV<em>*</em></label>
<div class="col-md-5 col-sm-6 col-xs-12 student-btn" style=" border-top: none;">
<div class="up-btn">
<span>UPLOAD</span>
<input id="iCard" type="file" name="file_product" title="Upload a valid I card of your institute" required class="upload">
</div>
<button type="submit" name="Import" value="SUBMIT" title="Submit" class="sub-btn"><span><span>SUBMIT</span></span></button>
</div>
</li>
</ul>
</div>
</form>
</div>
</div>
</div>
.student-details ul li label {
margin-left: 0 !important;
padding-left: 0 !important;
}
.student-details ul li div {
margin-left: 0 !important;
padding-left: 0 !important;
}
.student-offer{background:#fff;
border:1px solid #ccc;
border-radius:2px;
}
.student-details{
margin-top:20px;
margin-bottom:20px;
}
.terms-cdn{
margin-top:50px;
}
.terms-cdn p{
font-family:"open_sansregular"!important;
font-size:14px;
color:#333333
}
.terms-cdn span{
font-family:"open_sanslight"!important;
font-size:14px;
color:#333333
}
.sub-btn{
background: none repeat scroll 0 0 #3ab44a;
border: 1px solid #3ab44a;
border-radius: 4px;
box-shadow: 1px px 0 #3ab44a;
color: #fff;
height: 30px;
width: 137px;
float:right;
cursor:pointer;
font-size:14px;
}
.up-btn{ background: none repeat scroll 0 0 #575759;
border: 1px solid #575759;
border-radius: 4px;
box-shadow: 1px px 0 #575759;
color: #fff;
height: 30px;
width: 137px;
float:left;
text-align:center;
cursor:pointer;
font-size:14px;
}
.up-btn span{ vertical-align:middle; }
.upload { position:absolute; left:0; margin:0; padding:0;right:0; top:0;top: 0; opacity: 0;
z-index: 99999999;
width:40%;cursor:pointer;
font-size:14px;
}
lable.up_msg {
font-size: 11px;
float: left;
margin: 0!important;
padding: 0!important;
}
@media screen and (max-width: 768px) {.student-btn {margin-left: 3%;}}
@media screen and (max-width: 360px) {.student-btn {margin-left: 0!important;}
@media screen and (max-width: 320px) {.up-btn,.sub-btn{width:120px}}
@media screen and (max-width: 360px) {.student-offer{margin-left:15px;
}}
</style>
<?php
date_default_timezone_set("Asia/Bangkok");
ini_set('display_errors',1);
$username = "root";
$password = "";
$hostname = "localhost";
//$username = "shopnineteen";
//$password = "Sh0pN!nt33n19";
//$hostname = "masterdb";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) ;
//$selected = mysql_select_db("shopnine_live",$dbhandle);
$selected = mysql_select_db("shopnine_mar2015",$dbhandle);
require_once ("app/Mage.php");
$sql='';
if(isset($_POST["Import"]))
{
$filename=$_FILES["file_product"]["tmp_name"];
$type=$_FILES["file_product"]["type"];
//print_r($_FILES);
if($_FILES["file_product"]["size"] > 0)
{
$file = fopen($filename, "r");
while (($csvData = fgetcsv($file, 50000, ",")) !== FALSE)
{
if($csvData[0]!="")
{
$product_sku = mysql_escape_string(trim($csvData[1]));
$product_id = Mage::getModel("catalog/product")->getIdBySku( $product_sku );
$sql ="insert into catalog_category_product (category_id, product_id) values ('".mysql_escape_string(trim($csvData[0]))."','".$product_id."')";
$sql1 ="insert into catalog_category_product_index (category_id, product_id,position,is_parent,store_id,visibility) values ('".mysql_escape_string(trim($csvData[0]))."','".$product_id."','0','0','1','4')";
//echo $sql."<br>";
//echo $sql1."<br>";die;
mysql_query($sql);
mysql_query($sql1);
}
}
fclose($file);
echo "CSV File has been successfully Imported";
}
else
echo "Invalid File:Please Upload CSV File";
}
?>
<div class="detail_page">
<div class="container">
<div class="row">
<div class="about-title">
<strong><span>Auto Tagging</span></strong>
</div>
<div class="col-md-10 col-sm-10 col-xs-11 student-offer">
<form name="registration" method="post" enctype="multipart/form-data" class="student-details" >
<div class="fieldset">
<ul class="form-list form-horizontal np">
<li class="wide form-group">
<label class="col-md-4 col-sm-5 control-label ship-desc required" for="comment">Upload CSV<em>*</em></label>
<div class="col-md-5 col-sm-6 col-xs-12 student-btn" style=" border-top: none;">
<div class="up-btn">
<span>UPLOAD</span>
<input id="iCard" type="file" name="file_product" title="Upload a valid I card of your institute" required class="upload">
</div>
<button type="submit" name="Import" value="SUBMIT" title="Submit" class="sub-btn"><span><span>SUBMIT</span></span></button>
</div>
</li>
</ul>
</div>
</form>
</div>
</div>
</div>
csv formate
category_id SKU
Comments
Post a Comment