S
S
ssrdop2015-12-02 08:55:55
PHP
ssrdop, 2015-12-02 08:55:55

How to update the table of goods in an online store?

Hello. There is an online store on self-written cms (php + mysql + js). Every day, respectively, the number of goods changes, the price may change, and so on. Those. There is a need to update the product table once a day. I get a csv file, which then must be processed and uploaded to the database. My suggestion was that each time you update the product table, do not update it, but first clear all fields, and only then insert the data obtained from the csv file. I was offered not to delete anything, but to compare the existing fields with the newly received data. What is the fastest way you use? In which direction to look, can you advise some library?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2015-12-02
@ssrdop

exactly 2 MySQL
LOAD DATA INFILE commands - into a temporary table, then
INSERT INTO ON DUPLICATE KEY UPDATE into the required one.
if the CSV format is 1-in-1 with a table, you can generally get by with the first one, with the REPLACE parameter

P
Puma Thailand, 2015-12-02
@opium

The one that the customer asks for
All methods are fast
Wouldn't use code libraries twenty forty lines would be

T
trevoga_su, 2015-12-02
@trevoga_su

My suggestion was that each time you update the product table, do not update it, but first clear all fields
thereby killing goods with zero balance? Man, this is bad for SEO. There, on ozon.ru, for example, there is a book that has not been published for 10 years and will not be published 100% again, but the book is not removed from the site. Guess why?
can you recommend any library
shield? here works on 10 lines of code.
CSV for a billion records or what? What is the problem in general?
We read the file line by line by cron at 4 am and update the sql database, by article or other ID that you have there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question