Jump to content

php: send "delete_existing_images" during import


Recommended Posts

Dear,

 

prestashop: 1.6

 

I use the following code to do my import:

 

the header:

# init les fct + script
ob_flush();
flush();
define('_PS_ADMIN_DIR_', getcwd());
include(_PS_ADMIN_DIR_.'/../config/config.inc.php');
include(_PS_ADMIN_DIR_.'/functions.php');
include_once '../controllers/admin/AdminImportController.php';

 

my call:

($fichier and $langue are set before)

loadProductsPost($fichier, $langue);
$import->productImport();

 

 

function loadProductsPost($fichier, $langue) {
$_POST = array (
'truncate' => 'off',

'delete_existing_images' = '1'
'tab' => 'AdminImport',
'skip' => '1',
'csv' => $fichier,
'convert' => '1',
'regenerate' => '0',
'entity' => '1',
'separator' => ';',
'multiple_value_separator' => ',',
'forceIDs' => '1',
'import' => 'import',
'iso_lang' => $langue,
'type_value' =>
array (
0 => 'id',
1 => 'reference',
2 => 'category',
3 => 'description',
4 => 'active',
5 => 'meta_description',
6 => 'name',
7 => 'price',
8 => 'quantity',
9 => 'description_short',
10 => 'ean13',
11 => 'upc',
12 => 'image',
13 => 'url_rewrite',
),
);
}

 

I try to include the "delete_existing_images" but without any success so I need some help

 

Regards,

 

Yves

 

 

Link to comment
Share on other sites

Dear,

 

The quick and dirty hack is to add: $product->deleteImages();

to the AdminImportController.php line: 1811

 

But I dislike this king of doing.

 

So until I got a better answer or a more elegant method I will use this one.

 

Regards,

 

Yves

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

[RESOLVED]

 

Dear,

 

I finally understand something about prestashop: 

- do not touch any code

- just add a column in your csv file as:

header: delete_existing_images

row: 0|1

 

and map the column number in your php code as:

 

...

12 => 'image',
13 => 'url_rewrite',

14 => 'delete_existing_images',
),

 

Run import :)

 

Regards,

 

Yves

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...