Jump to content

Edit History

yeye412

yeye412

I forgot to add some details on csv import script.

I'm trying to import only simple products (no combination) without images .

In attach php script.

if (!defined('_PS_ADMIN_DIR_'))
define('_PS_ADMIN_DIR_', __DIR__);
    require_once (_PS_ADMIN_DIR_.'/class.PSRequest.php');
    /* DB Config */
    $shopID = "1";
    $adminUrl = '...';
    $adminLoginEmail = '...';
    $adminLoginPass = '...';

    $request = new PSRequest();
    $request->setCookieFileLocation(__DIR__.'/PScookie.txt');
    $request->setPost(array("email" => $adminLoginEmail,"passwd" => $adminLoginPass, "submitLogin" => "Connexion")); 
    $request->call($adminUrl."/index.php?controller=AdminLogin");

    $request->call($adminUrl."/index.php?controller=AdminImport");
    list(,$response) = explode("\r\n\r\n", $request->_webpage, 2);
    preg_match("/token=([a-z0-9]+)/", $response, $matches);
    $token = $matches[1];

    $request->setPost(array(
                "controller" => "AdminImport",
                "token" => $token,
      	    	'skip' => '1',
				'csv' => 'prodotti.csv',
				'entity' => '1',
				'separator' => ';',
				'multiple_value_separator' => ',',
                'iso_lang' => 'it',
                'match_ref' => '1',
                'regenerate' => '0',
                'sendemail' => '1',
				"type_value" => array(								
				  0 => 'reference',
				  1 => 'name',
                  2 => 'price',
                  3 => 'quantity'
			    )
        )
    );

    $request->call($adminUrl."/index.php?controller=AdminImport&token=".$token);
        $request->call($adminUrl."index.php?ajax=1&action=import&tab=AdminImport&offset=0&limit=5&token=".$token);

        echo "called AdminImport and POST datas...";

//TEST PURPOSE 
//write response output on file
    $file = fopen("importProducts.log", "w");
    fwrite($file, $response);
    $request = null;

?>

 

 

I'm not php programmer and don't know Prestashop project structure, i'm studying php and prestashop for this reason need some help..  
I can understand most of online code,  and can reuse php scripts .. i think problem is that don't know very good php e prestashop, problem it's not money (i can pay anyone for doing this code) i want only support and  do it alone. 

 

If you can help me i'll thank you, if no it's ok .

 

Regards

yeye412

yeye412

I forgot to add some details on csv import script.

I'm trying to import only simple products (no combination) without images .

In attach php script.

if (!defined('_PS_ADMIN_DIR_'))
define('_PS_ADMIN_DIR_', __DIR__);
    require_once (_PS_ADMIN_DIR_.'/class.PSRequest.php');
    /* DB Config */
    $shopID = "1";
    $adminUrl = '...';
    $adminLoginEmail = '...';
    $adminLoginPass = '...';

    $request = new PSRequest();
    $request->setCookieFileLocation(__DIR__.'/PScookie.txt');
    $request->setPost(array("email" => $adminLoginEmail,"passwd" => $adminLoginPass, "submitLogin" => "Connexion")); 
    $request->call($adminUrl."/index.php?controller=AdminLogin");

    $request->call($adminUrl."/index.php?controller=AdminImport");
    list(,$response) = explode("\r\n\r\n", $request->_webpage, 2);
    preg_match("/token=([a-z0-9]+)/", $response, $matches);
    $token = $matches[1];

    $request->setPost(array(
                "controller" => "AdminImport",
                "token" => $token,
      	    	'skip' => '1',
				'csv' => 'prodotti.csv',
				'entity' => '1',
				'separator' => ';',
				'multiple_value_separator' => ',',
                'iso_lang' => 'it',
                'match_ref' => '1',
                'regenerate' => '0',
                'sendemail' => '1',
				"type_value" => array(								
				  0 => 'reference',
				  1 => 'name',
                  2 => 'price',
                  3 => 'quantity'
			    )
        )
    );

    $request->call($adminUrl."/index.php?controller=AdminImport&token=".$token);
        $request->call($adminUrl."index.php?ajax=1&action=import&tab=AdminImport&offset=0&limit=5&token=".$token);

        echo "called AdminImport and POST datas...";

//TEST PURPOSE 
//write response output on file
    $file = fopen("importProducts.log", "w");
    fwrite($file, $response);
    $request = null;

?>

 

 

I'm not php programmer and don't know Prestashop project structure, for this reason need some help.. 
I can understand most of online code,  and can reuse php scripts .. i think problem is that don't know very good php e prestashop.

 

If you can help me i'll thank you, if no it's ok .

 

Regards

×
×
  • Create New...