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

Is covid virus really airborne?

  If airborne transmission is a significant factor in the pandemic, especially in crowded spaces with poor ventilation, the consequences for containment will be significant. How did the experts reach this conclusion? Reviewing existing research, the six experts from the UK, US and Canada identified 10 streams of evidence that collectively support the hypothesis that SARS-CoV-2 primarily transmits through the airborne route. 1. Super-spreading events account for substantial SARS-CoV-2 transmission. Indeed, the authors wrote, such events may be the  pandemic ’s primary drivers. Detailed analyses of human behaviours and other variables in concerts, cruise ships etc have shown patterns “consistent with airborne spread of SARS-CoV-2 that cannot be adequately explained by droplets or fomites”, they wrote. 2. Long-range transmission of SARS-CoV-2 between people in adjacent rooms has been documented in quarantine hotels, but never in each other’s presence. 3. Asymptomatic or pre-sympt...

How to display Image in grid

Write this code in Grid.php:- $this->addColumn("data", array( "header" => Mage::helper("userdesign")->__("Design"), "index" => "image", 'align'     =>'center', 'renderer'  => 'userdesign/Adminhtml_Userdesign_Renderer_Image' )); Then make a "Renderer" folder in module( location - Grid.php) In Renderer Make a PHP file , Named Image.php and put this code <?php class Userdesign_Userdesign_Block_Adminhtml_Userdesign_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{           public function render(Varien_Object $row)     { $designUrl=Mage::getBaseUrl('web').'design/designs/';         $html = '<img width="75" height="75" ';          $value = $row->getData('designId');       $html.= 'src="' . Mage::getBaseUrl('web')....