Topic "FTP import products"

Author Message
graisbeck
[View user's profile]

Joined: 2017-03-10
Posts: 2
Location: Newcastle upon Tyne
Hi,
I have an Wordpress shop which uses Woocommerce. I purchased a 'WP All Import' plugin which uses a 'http://' url to import products. My problem is that my product supplier only issues details for ftp. The support from the plugin developer is next to useless, he sent me a template to edit, but gave no instruction on what to do with it! I'm hoping someone on here may be able to help. This is the code -

Code:
<?php
$ftp = array(
   'server' => 'ftp.example.com',
   'user' => 'yourusername',
   'pass' => 'yourpassword'
);

// Connect
$ftp_connection = ftp_connect( $ftp['server'] ) or die( 'Could not connect to $ftp[$server]' );

// Set passive mode
ftp_pasv( $ftp_connection, false );

if ( $login = ftp_login( $ftp_connection, $ftp['user'], $ftp['pass'] ) ) {

   // Login passed
   
   // Download data to this file.
   $local_file = 'datafeed.csv.';

   // Path and filename to open and read from.
   $server_file = 'public_html/ftpfiles/data-example-2.csv';

   // Download File
   if ( $file = ftp_get( $ftp_connection, $local_file, $server_file, FTP_ASCII ) ) {

      $handle = fopen( $local_file, "r" ) or die( "Couldn't get handle" );

      if ( $handle ) {

          while ( !feof( $handle ) ) {

             // Output data.
              $buffer = fgets( $handle, 4096 );
              echo $buffer;

          }

          fclose( $handle );

      } else {

         // $handle failed
         echo "Failed to get handle.";

      }

   } else {

      // ftp_get failed
      echo "Failed to download file.";

   }

} else {

   // Login failed
   echo "Failed to log in.";

}

// Disconnect
ftp_close( $ftp_connection );
?>
[/code]
Advertisements
Guest




Is the code you presented above from the your vendor guy or from the All Imports guy... Whom ever gave it to you should give you and example.. but looks pretty self explanatory in converting ftp to http. but there should be many ways to skin this cat...but will need lots more details.. also keep in mind that All Import are excellent on refunds if you cannot get it to work for you.. but I am sure the main reason you purchased the all import was not for the http downloading but for the fantastic data manipulation capability that it has.. maybe All Import can help so you dont have to return it.. some of the sharped folks here can probably tell you how to script WinScp to do what you want as this is a fantastic tool but I am still new to it..
graisbeck
[View user's profile]

Joined: 2017-03-10
Posts: 2
Location: Newcastle upon Tyne
I bought the plugin as I wanted to use importing via url with cron scheduled imports. The plugin works great when manually importing csv files. But, I wanted to automate the process. The above script came from the plugin vendor. I have the ftp ip address, user name and password, but not the path to the csv file I need to download.
tommytx
[View user's profile]

Joined: 2017-03-11
Posts: 3
Location: Virginia Beach, Virginia
The guest response above was me... musta forgot to sign in.. if one of these super smart folks don't jump in and tell you how to use this wonderful WinSCP to script what you need.. contact me via my profile and I will help you out.. I do major programming 24x7 for FREE.. and if I ever charge you a dime come back here and out me. Not much I can't program.. but will need to fully understand what you have and where you want to be.. So have a nice day...and to make you feel even more comfortable i will send you a list of 200 folks that yu can contact anyone of to ask if this is a scam.. most folks think FREE means Bait and Switch.
tommytx
[View user's profile]

Joined: 2017-03-11
Posts: 3
Location: Virginia Beach, Virginia
Just throwing out more ideas... if nothing else works WinScp is great for downloading a file with one cron and them it will be on your hard drive so pretty easy to point the importer to the file on yur hard drive with a second cron that would fire say 10 min later after the download.. as stated will need a little more info to give you the exact working details but man made it man can fix it.. LOL.
_________________
Have a small programming project you need help on.. love programming and its all FREE.. ..if I ever charge you a dime please return here and OUT me..tommytx@earthlink.net
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
Sorry, but this does not look like your question has anything to do with WinSCP.
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License