Jump to content

Import csv file with cron


iartusi87

Recommended Posts

I try this (https://coderwall.com/p/2q5lcw/prestashop-background-cron-csv-products-import):

<?php
    require_once ('class.PSRequest.php'); //see class source code below
    /* START Configuration */
    $shopID = "1";
    $adminUrl = 'http://127.0.0.1/prestashop/admin923dnt0oz/';
    $adminLoginEmail = '[email protected]';
    $adminLoginPass = 'testtest';
    /* END Configuration */
    $request = new PSRequest();
    $request->setPost(array("email" => $adminLoginEmail,"passwd" => $adminLoginPass, "submitLogin" => "Connexion")); // you must be a super admin 
    $request->call($adminUrl."index.php?controller=AdminLogin");
    list(,$response) = explode(PHP_EOL.PHP_EOL, $request->_webpage, 2);
    preg_match("/AdminImport&token=([a-z0-9]+)/", $response, $matches);
    $token = $matches[1];
    unset($request);
    
    $request = new PSRequest();
    $request->setPost(array(
        "controller"               => "AdminImport",
        "token"                    => $token,
        "skip"                     => 1,
        "csv"                      => "http://127.0.0.1/prestashop/admin923dnt0oz/import/products_import.csv",
        "convert"                  => '',
        "regenerate"               => '',
        "entity"                   => 1, //1 is for products import
        "iso_lang"                 => "it",
        "truncate"                 => 1,
        "forceIDs"                 => 1,
        "match_ref"                => 0,
        "separator"                => ";",
        "multiple_value_separator" => ",",
        "import"                   => 1,
        "type_value" => array( 0 => 'Name')
        )
    );
    $request->call($adminUrl."index.php?controller=AdminImport&token=".$token);
    echo $request;

Login OK -> Token OK -> Upload KO Nobody can help me?

Edited by iartusi87 (see edit history)
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...