Post by ideep13 » Wed Feb 03, 2021 4:21 pm

Hi,

Can please someone help me with DATABASE code?
I have combined two stores into 1, so I have now multiple manufacturers and different products are assigned to them from each store. Before I can delete the duplicates, I need to assign the right id to right products. So..

If manufacturer id is 11
And the same manufacturer is 57

How can I assign a right manufacturer to a products that have 57 id, but needs to be 11 now.
Can you send me the right code so I can run in SQL?
Last edited by ideep13 on Wed Feb 03, 2021 7:53 pm, edited 1 time in total.

User avatar
Active Member

Posts

Joined
Mon Jun 18, 2012 2:47 am

Post by paulfeakins » Wed Feb 03, 2021 6:40 pm

First check that you're selecting the right products:

Code: Select all

SELECT * FROM `ocuy_product` 
WHERE manufacturer_id = 5 
Then AFTER BACKING UP YOUR DATABASE, you can add an update in there:

Code: Select all

UPDATE * FROM `ocuy_product` 
SET manufacturer_id = 11
WHERE manufacturer_id = 5 
Sometimes to be safe you can add LIMIT 1 to the end so even worst case it only affects one row.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by ideep13 » Wed Feb 03, 2021 6:51 pm

is there any other way? selecting products manually is taking a lot of time.

isn't there a magical command where you can replace id 11 with 57?

User avatar
Active Member

Posts

Joined
Mon Jun 18, 2012 2:47 am

Post by ideep13 » Wed Feb 03, 2021 7:05 pm

OK.If anyone needs this - this is the command and back up the DB before you are doing this

Code: Select all

UPDATE  `oc_product` SET manufacturer_id = 255 WHERE manufacturer_id = 5
255 is the new, or existing manufacturer_id which you need to assign to the product and 5 is the manufacturer_id which you later will delete/remove

Got help from stackoverflow

User avatar
Active Member

Posts

Joined
Mon Jun 18, 2012 2:47 am

Post by paulfeakins » Thu Feb 04, 2021 5:56 pm

ideep13 wrote:
Wed Feb 03, 2021 7:05 pm
OK.If anyone needs this - this is the command and back up the DB before you are doing this

Code: Select all

UPDATE  `oc_product` SET manufacturer_id = 255 WHERE manufacturer_id = 5
255 is the new, or existing manufacturer_id which you need to assign to the product and 5 is the manufacturer_id which you later will delete/remove

Got help from stackoverflow
What are you talking about, this is the answer I gave you above :crazy:

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom
Who is online

Users browsing this forum: No registered users and 42 guests