Why wouldn't you just create an index in the products table to make product_code unique? Cs-cart might even generate an error when it can't update the product because of a unique index violation... Or it should be in the logs for database.
Why wouldn't you just create an index in the products table to make product_code unique? Cs-cart might even generate an error when it can't update the product because of a unique index violation... Or it should be in the logs for database.
Product ID is not know yet. So you should add product with duplicated sku. Then get product ID and change product code
Thank you everybody for your replies.
I did try this:
if (empty($product_id)) {
$pid = db_get_field("SELECT MAX(product_id) FROM ?:products");
$new_pid= $pid +1;
$product_data['product_code'] = $new_pid;
}
However, the above didn't work when adding new product after deleting one.
I am thinking of having a static value for the product code when creating a product. Then, getting the product id for that specific sku and change the value of the sku to the product id.
Old post but I have some issues related to duplicate products, when I start the import from feed and select 'update only" it will created new product with exact same product code even if I select on import map only product code and images (to import only images for existing products). I thought that in such case it will search and find the existing product code on feed file and update images or whatever field I select beside product code. Why is this happening and how to fix it ?