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

How to create Guest Wishlist For Magento

Add to wishlist without customer login Add three tables CREATE TABLE `wishlist` ( `wishlist_id` INT(11) NOT NULL AUTO_INCREMENT, `customer_id` INT(11) NULL DEFAULT NULL, `shared` INT(11) NULL DEFAULT NULL, `sharing_code` VARCHAR(50) NULL DEFAULT NULL, `updated_at` TIMESTAMP NULL DEFAULT NULL, `cookie` VARCHAR(255) NULL DEFAULT NULL, PRIMARY KEY (`wishlist_id`) ) COLLATE='latin1_swedish_ci' ENGINE=InnoDB AUTO_INCREMENT=0 ; CREATE TABLE `wishlist_item` ( `wishlist_item_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Wishlist item ID', `wishlist_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Wishlist ID', `product_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Product ID', `store_id` SMALLINT(5) UNSIGNED NULL DEFAULT NULL COMMENT 'Store ID', `added_at` TIMESTAMP NULL DEFAULT NULL COMMENT 'Add date and time', `description` TEXT NULL COMMENT '...

Help & Support System Against COVID-19 Virus.

 Help & Support System Against COVID-19 Virus. UP Police-112 - http://112.up.gov.in/hi/Pages/complaint.aspx Corona Helpline: 18001805145 / 1075  GB Nagar CCRoom: 18004192211. Delhi CC Room: 011-23490311 Gurugram: 0124-2316100 Haryana: 0172-2570070 *For Plasma*- Noida Police: https://docs.google.com/forms/d/e/1FAIpQLSfKhjiQG80eIbcr78VGUeIA4e1W