Product Code

Hello,

I have changed the product code for products I already have and sold.

Now, The new orders are shown with the correct code but in old orders, the product code still remains the same as the old one. Is there anyway to have it changed?

Thanks in advance.

Hi again,

I checked cscart_order_details table and found the products in each order. Is there any bad impact or corruption if I change the product code to the new one? Will it get corrected the way I want? How I change these codes (more than 1000 orders) in one command?

I found this but I am not sure if it will work correctly:

UPDATE table_name
SET field_name = replace(same_field_name, 'unwanted_text', 'wanted_text')

Regards,

Hazim

Selected way will not brake anything. Try the following command

UPDATE cscart_order_details SET product_code = 'NEW_CODE' WHERE product_code = 'OLD_CODE';

Selected way will not brake anything. Try the following command

UPDATE cscart_order_details SET product_code = 'NEW_CODE' WHERE product_code = 'OLD_CODE';

It worked perfectly. Thank you so much

You are welcome!

Hello .. One more question. Is it possible to change a value of a column based on another column in the same table?

Hello .. One more question. Is it possible to change a value of a column based on another column in the same table?

Sure, please give more details about your task. E.g.

UPDATE cscart_products SET product_code = product_id * 1000;

Sure, please give more details about your task. E.g.

UPDATE cscart_products SET product_code = product_id * 1000;

Hello,

In cscart_order_details, I need to change the product code based on the product ID.

For example, I have 4 products, all of them has no product code. I need to give them a code but it will be depending of the Product ID. So I want to give the code XYZ to the product ABC which has an ID# 12345 and so on.

I used the product ID because it is the only common thing between the products in that table.

Try something like

UPDATE cscart_order_details a JOIN cscart_products b ON a.product_id = b.product_id SET a.product_code = b.product_code;

(!) Not tested, make a backup