-- CATEGORY
REPLACE INTO `oc_category_to_layout` (`category_id`, `store_id`, `layout_id`)
SELECT
`t1`.`category_id`,
`s`.`store_id`,
`t1`.`layout_id`
FROM `oc_store` AS `s`
LEFT JOIN `oc_category_to_layout` AS `t1`
ON (1)
LEFT JOIN `oc_category_to_layout` AS `t2`
ON (`t2`.`store_id` = `s`.`store_id`
AND `t2`.`category_id` = `t1`.`category_id`)
WHERE `t1`.`store_id` = 0
AND IFNULL(`t2`.`layout_id`, 0) = 0;
-- INFORMATION
REPLACE INTO `oc_information_to_layout` (`information_id`, `store_id`, `layout_id`)
SELECT
`t1`.`information_id`,
`s`.`store_id`,
`t1`.`layout_id`
FROM `oc_store` AS `s`
LEFT JOIN `oc_information_to_layout` AS `t1`
ON (1)
LEFT JOIN `oc_information_to_layout` AS `t2`
ON (`t2`.`store_id` = `s`.`store_id`
AND `t2`.`information_id` = `t1`.`information_id`)
WHERE `t1`.`store_id` = 0
AND IFNULL(`t2`.`layout_id`, 0) = 0;
-- MANUFACTURER
REPLACE INTO `oc_manufacturer_to_layout` (`manufacturer_id`, `store_id`, `layout_id`)
SELECT
`t1`.`manufacturer_id`,
`s`.`store_id`,
`t1`.`layout_id`
FROM `oc_store` AS `s`
LEFT JOIN `oc_manufacturer_to_layout` AS `t1`
ON (1)
LEFT JOIN `oc_manufacturer_to_layout` AS `t2`
ON (`t2`.`store_id` = `s`.`store_id`
AND `t2`.`manufacturer_id` = `t1`.`manufacturer_id`)
WHERE `t1`.`store_id` = 0
AND IFNULL(`t2`.`layout_id`, 0) = 0;
-- PRODUCT
REPLACE INTO `oc_product_to_layout` (`product_id`, `store_id`, `layout_id`)
SELECT
`t1`.`product_id`,
`s`.`store_id`,
`t1`.`layout_id`
FROM `oc_store` AS `s`
LEFT JOIN `oc_product_to_layout` AS `t1`
ON (1)
LEFT JOIN `oc_product_to_layout` AS `t2`
ON (`t2`.`store_id` = `s`.`store_id`
AND `t2`.`product_id` = `t1`.`product_id`)
WHERE `t1`.`store_id` = 0
AND IFNULL(`t2`.`layout_id`, 0) = 0;