Skip to main content

Auto Tag Product in Category

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





csv formate

category_id SKU

Comments

Popular posts from this blog

Parsing Domain Name From URL In PHP

To get Domain name from the url, we can use parse_url() php function. This would filter the domain name from the given url. $domain = str_ireplace ( 'www.' , '' , parse_url ( $url , PHP_URL_HOST )); This would return the google.com for both http://google.com and http://www.google.com

Trick to get Vaccine slot in India

  This will allow users to find available slots for COVID-19 vaccines in the centers around them. Steps: You should see the Vaccine Finder option. Alternatively, Android mobile phone users can tap on ‘All’ –> followed by the COVID-19 Vaccination Appointment banner Enter your pincode / district and choose between 18+ and 45+ age groups Select on Check Availability to proceed All available slots details will appear on your screen If there are no available slots, you can click on ‘Notify me when slots are available’ option to get alerts for open slots

get directory paths, get Base URLs, get URLs in static block, get secure URL in Magento

1) Get Directory paths  Mage::getBaseDir()  //output : /var/www/html/magento Mage::getBaseDir('app')  //output : /var/www/html/magento/app Mage::getBaseDir('media') //output : /var/www/html/magento/media Mage::getBaseDir(‘design’) => Get design directory path Mage::getBaseDir(‘code’) => Gives code directory file path Mage::getBaseDir(‘lib’) => Gives lib directory file path Mage::getBaseDir(‘skin’) => Gives skin directory file path Mage::getBaseDir(‘var’) => Gives var directory file path Mage::getBaseDir(‘cache’) => Gives cache directory file path Mage::getBaseDir(‘log’) => Gives log directory file path       2) Get Base URL  Mage::getBaseUrl() => Get base url path e.g. http://yourwebsite.com/  Mage::getBaseUrl('media') => Get MEDIA folder path e.g. http://yourwebsite.com/media/  Mage::getBaseUrl('js') => Get JS folder path e.g. http://yourwebsite.com/js/  Mage::getBaseUrl('skin') => Get...