update inventory automatically

I want to create a script to automatically update the inventory of all products. The suppliers has a CSV file with product numbers and stock information. Not all products are located in webshop yet.

Althought the programming logic is not that difficult I am not sure what the best way is.[list]

[]update the stock values directly in DB?

]convert supplier CSV to CS-Cart CSV and call CS-Cart product import functionality?


Hope the developers here can inform me about the these options (or others) and there consequences.

Thanks in advance.

Depends on whether you are using option combinations or not. If not, then just update the 'amount' column for the product_id in the cscart_products table. If you are using option combinations, the find the product_id/product_code row in the cscart_product_options_inventory table and update the 'amount' column in that table.

You could just use the product_code and amount columns in a product import but do note if the product_code does not exist, it will be created.

Doing direct update to the database would not cause any issues. Only program logic based on product amount will be skipped. For example “back in stock” notification to customers.

Thx for the advice. The update of the inventory is working correctly. I did notice CS-Cart has wrapper function for DB management. The script I wrote has direct calls to the mysqli library. Is it wise to use the CS-Cart wrapper functions instead?

Technically it's not required. But their wrapper makes many things a lot easier. I.e. it will apply sub-sets of data to INSERT or UPDATE requests, provides for IN clauses, etc.

Yes technically no difference wrapper just makes things easier.

Oke thx, will look into it in some more detail than