简体   繁体   中英

how to get the orders from the amazon vendor center

Is there a way to get the orders with the help of EDI. I have tried to connect it with the SFTP and getting one file.

AmazonConnectivityTest file. but dont know how to work with EDI.

Can anyone please tell whats the step to work with the EDI. without using third party software.

It all depends on your own software. EDI (X12) is targeted for machine to machine use, the document you will receive on the SFTP is not comfortably human readable. So you will need software to 1. fetch the file on the SFTP, 2. interpret it, and 3. push it into your ERP.

If your ERP can't do that and you don't have software you can adapt in house then you might indeed need a third party to fetch it, or translate it to your own formats, or push it into your ERP.

i have wretten a function. it read and download amazon file from server and you can use data to change it in your order format:

public function execute(Arguments $args, ConsoleIo $io)
{
    $conn = ssh2_connect('sftp-eu.amazonsedi.com', 2222);
    if (ssh2_auth_pubkey_file(
        $conn,
        '<your secret>',
       'address to id_rsa.pub',//same as you uploaded in amazon
        'address to  id_rsa'
    )) {
        echo "Public Key Authentication Successful\n";
        $sftp = ssh2_sftp($conn);

        if (!$dir = opendir("ssh2.sftp://$sftp"."/download/")) {
            die('Failed to open the directory.');
        }
        echo "dir open";
        $files = array();


        while (($file = readdir($dir)) !== false) {
            $files[]=$file;
        }
        closedir($dir);
        foreach ($files as $file) {
            echo "Copying file: TMP.AMAZON\n";
            if (!$remote = fopen("ssh2.sftp://$sftp/download/$file", 'r')) {
                echo "Failed to open remote file: $file\n";
                continue;
            }
            if (!$local = fopen(TMP."amazon/" . $file, 'w')) {
                echo "Failed to create local file: $file\n";
                continue;
            }
            $read = 0;
            $filesize = filesize("ssh2.sftp://$sftp/download/$file");
            while (($read < $filesize) && ($buffer = fread($remote, $filesize - $read))) {
                $read += strlen($buffer);
                if (fwrite($local, $buffer) === false) {
                    echo "Failed to write to local file: $file\n";
                    break;
                }
            }
            fclose($local);
            fclose($remote);
        }
    } else {
        die('Public Key Authentication Failed');
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM