dev Posted August 14, 2008 Posted August 14, 2008 hi all I need some help here!! okkkk here we go .. I download a csv file and import it into msql , but the program create a new catagory in mysql with table and products and it's call yumdrop now I need to know how can I add that to the catalog catagory as a link I am going to have more of them like that meaning new catagory's. I am not sure if this is all the info anyone need I am still trying to figure it out ty but let me know if anyone can help thanks dev.
dev Posted August 14, 2008 Author Posted August 14, 2008 ok everyone here is the script I use to import the file into mysql.. <? $ftp_server = "datafeeds.shareasale.com"; // Do not change this $ftp_user_name = "xxxxxx"; // Replace user_name with your SAS login name $ftp_user_pass = "xxxxxx"; // Replace user_pass with your SAS password $source_file = "/xxxx/xxx.txt"; // Replace both number with the merchant ID $destination_file = "xxx.txt"; // Replace number with the Mechant ID $sasid = "xxxxxxx"; // Replace sas_id with your SAS ID; Can be found at the top of any SAS page // The following variables make the connection to your database $dbuser = "xxxxxxxx"; // Replace db_user with the username used to connect to your database $dbpass = "xxxxxxxxxx"; // Replace db_pass with the password used to connect to your database $database = "xxxxxxxxx"; // Replace database with the name of your database // The following two variables will be the names of the table(s) in your database // MAKE SURE THE NAMES YOU CHOOSE DO NOT ALREADY EXIST. THEY WILL BE DROPPED. $temptable = "yumdrop_temp"; // Replace merchant_name (ie: naturehills_temp) $maintable = "yumdrop"; // Replace merchant_name (ie: naturehills) $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed to $ftp_server as $ftp_user_name.<br />"; exit; } else { echo "Connected to $ftp_server successfully as $ftp_user_name.<br />"; } $download = ftp_get($conn_id, $destination_file, $source_file, FTP_ASCII); if (!$download) { echo "FTP download has failed!"; } else { echo "Downloaded $source_file from $ftp_server as $destination_file"; } ftp_close($conn_id); $datafeed = file_get_contents($destination_file); $fp = fopen($destination_file, "w"); $replace = str_replace("xxxxxx",$sasid,$datafeed); fwrite($fp, $replace); fclose($fp); mysql_pconnect("xxxxxxxxxxxxxx",$dbuser,$dbpass); mysql_select_db($database); $FeedFile = $destination_file; mysql_query("drop table $temptable"); mysql_query("CREATE TABLE $temptable (ProductID int(11) NOT NULL default '0',Name varchar(255) NOT NULL default '',MerchantID varchar(50) NOT NULL default '',Merchant varchar(50) NOT NULL default '',Link text NOT NULL,Thumbnail text NOT NULL,BigImage text NOT NULL,Price varchar(50) NOT NULL default '',RetailPrice varchar(50) NOT NULL default '',Category varchar(50) NOT NULL default '',SubCategory varchar(50) NOT NULL default '',Description longtext NOT NULL,Custom1 text NOT NULL,Custom2 text NOT NULL,Custom3 text NOT NULL,Custom4 text NOT NULL,Custom5 text NOT NULL,LastUpdated varchar(100) NOT NULL default '',status varchar(50) NOT NULL default '', PRIMARY KEY (ProductID))") or die(mysql_error()); $feed = fopen($FeedFile, 'r'); $rowNum = 0; while($data = fgetcsv($feed, 50000, "|")){ $ProductID = addslashes($data[0]); $Name = addslashes($data[1]); $MerchantID = addslashes($data[2]); $Merchant = addslashes($data[3]); $Link = addslashes($data[4]); $Thumbnail = addslashes($data[5]); $BigImage = addslashes($data[6]); $Price = addslashes($data[7]); $RetailPrice = addslashes($data[8]); $Category = addslashes($data[9]); $SubCategory = addslashes($data[10]); $Description = addslashes($data[11]); $Custom1 = addslashes($data[12]); $Custom2 = addslashes($data[13]); $Custom3 = addslashes($data[14]); $Custom4 = addslashes($data[15]); $Custom5 = addslashes($data[16]); $LastUpdated = addslashes($data[17]); $status = addslashes($data[18]); $manufacturer = addslashes($data[19]); $partNumber = addslashes($data[20]); $merchantCategory = addslashes($data[21]); $merchantSubcategory = addslashes($data[22]); $shortDescription = addslashes($data[23]); $ISBN = addslashes($data[24]); $UPC = addslashes($data[25]); $sql = mysql_query("insert into $temptable (ProductID, Name, MerchantID, Merchant, Link, Thumbnail, BigImage, Price, RetailPrice, Category, SubCategory, Description, Custom1, Custom2, Custom3, Custom4, Custom5, LastUpdated, status) values ('$ProductID', '$Name', '$MerchantID', '$Merchant', '$Link', '$Thumbnail', '$BigImage', '$Price', '$RetailPrice', '$Category', '$SubCategory', '$Description', '$Custom1', '$Custom2', '$Custom3', '$Custom4', '$Custom5', '$LastUpdated', '$status')") or die(mysql_error()); $rowNum++; } mysql_query("drop table $maintable"); mysql_query("ALTER TABLE $temptable RENAME $maintable") or die(mysql_error()); fclose($feed); ?> where it says : $temptable = "yumdrop_temp"; // Replace merchant_name (ie: naturehills_temp) $maintable = "yumdrop"; // Replace merchant_name (ie: naturehills) this file create a compelete different category call yumdrop and create it own table structure and what I want to do here is to call yumdrop under catalog .. I am very lost with that right now not sure how to go about doing it I have search the froum and I am running out of brain room :) please someone give me some help here also I will be adding more products the same way but as far as I know this program will delete the table structure and I don't want to do that I want to see if I can get the yumdrop structure in the catalog if I can do that then it will be easy for me to add the other products in other categorys .......... thanks dev..
dev Posted August 16, 2008 Author Posted August 16, 2008 hmm and here I taught you people was helpful dang o well have a nice day
Recommended Posts
Archived
This topic is now archived and is closed to further replies.