1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
CREATE TEMPORARY TABLE TMP
(
active TINYINT,
ref VARCHAR(255),
idfam INT,
desi VARCHAR(255),
ean DOUBLE,
poids DOUBLE,
prix DECIMAL(20,3),
quantité DOUBLE,
minqty INT,
idtva INT,
link_rewrite VARCHAR(255)
);
LOAD DATA LOCAL INFILE 'C:\\Users\\Gauthier\\Desktop\\maj_produits_from_wave.txt'
REPLACE
INTO TABLE TMP
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n' -- ou '\r\n' selon l'ordinateur et le programme utilisés pour créer le fichier
IGNORE 1 LINES (
active,
Ref,
idfam,
desi,
ean,
poids,
prix,
quantité,
minqty,
idtva,
link_rewrite
);
INSERT INTO pre5181_product (id_category_default, id_tax_rules_group, ean13, minimal_quantity, price, reference, weight, active, date_add, date_upd)
SELECT t.idfam, t.idtva, t.ean, t.minqty, t.prix, t.ref, t.poids, t.active, NOW(), NOW()
FROM TMP t
WHERE t.active = 1
ON DUPLICATE KEY UPDATE id_category_default = t.idfam, id_tax_rules_group = t.idtva, ean13 = t.ean, minimal_quantity = t.minqty, price = t.prix, reference = t.ref, weight = t.poids, active = t.active, date_upd = NOW() |
Partager