Page 1 of 1

New store, quickly associate all your products, categories..

Posted: Sat Dec 15, 2012 11:08 pm
by opencart-templates
Assuming you have created a new store and want to assign everything to your new store quickly run the following SQL queries via PHPMYADMIN.

WARNING backup your database before running this.

1. Update the "1" to match your new store ID.
2. Optional - update the "0" to match the store ID you are copying from.

Code: Select all

INSERT INTO category_to_store (category_id, store_id)
SELECT category_id, 1 FROM category_to_store WHERE store_id = 0;

INSERT INTO information_to_store (information_id, store_id)
SELECT information_id, 1 FROM information_to_store WHERE store_id = 0;

INSERT INTO layout_route (layout_id , store_id, route)
SELECT layout_id , 1, route FROM layout_route WHERE store_id = 0;

INSERT INTO manufacturer_to_store (manufacturer_id, store_id)
SELECT manufacturer_id, 1 FROM manufacturer_to_store WHERE store_id = 0;

INSERT INTO product_to_store (product_id, store_id)
SELECT product_id, 1 FROM product_to_store WHERE store_id = 0;

Re: New store, quickly associate all your products, categori

Posted: Fri May 24, 2013 11:20 pm
by Shopson.se
Thanks a lot!

Re: New store, quickly associate all your products, categori

Posted: Mon Sep 02, 2013 12:37 am
by crispylettuce
Thanks also for this. Saved me a lot of messing around and time! :)

Re: New store, quickly associate all your products, categori

Posted: Sat Jan 25, 2014 7:22 pm
by jane.stix
There are SQL if you need to add recently added categories, products etc to ather store (please note that additional store id is not necessary 1 if you have more then one and create/remove then few times. You can found store_id in table store)
INSERT INTO category_to_store (category_id, store_id)
SELECT category_id, 1 FROM category_to_store S1 WHERE S1.store_id = 0 and
not exists(select * from category_to_store S2 where S2.category_id=S1.category_id and S2.store_id=1);

INSERT INTO information_to_store (information_id, store_id)
SELECT information_id, 1 FROM information_to_store S1 WHERE S1.store_id = 0 and
not exists(select * from information_to_store S2 where S2.information_id=S1.information_id and S2.store_id=1);

INSERT INTO layout_route (layout_id , store_id, route)
SELECT layout_id , 1, route FROM layout_route S1 WHERE S1.store_id = 0 and
not exists(select * from layout_route S2 where S2.layout_id=S1.layout_id and S2.route=S1.route and S2.store_id=1);

INSERT INTO manufacturer_to_store (manufacturer_id, store_id)
SELECT manufacturer_id,1 FROM manufacturer_to_store S1 WHERE S1.store_id = 0 and
not exists(select * from manufacturer_to_store S2 where S2.manufacturer_id=S1.manufacturer_id and S2.store_id=1);

INSERT INTO product_to_store (product_id, store_id)
SELECT product_id, 1 FROM product_to_store S1 WHERE S1.store_id = 0 and
not exists(select * from product_to_store S2 where S2.product_id=S1.product_id and S2.store_id=1);

Re: New store, quickly associate all your products, categori

Posted: Thu Jul 31, 2014 6:44 pm
by tjsystems
Thanks saved me al lot of time.
Wish OpenCart would build-in something like this.