Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Clear has_parameters flag
- UPDATE shopcenter_products
- SET has_parameters = 0
- WHERE has_parameters = 1;
- # SET NEW proper has_parameters flag
- UPDATE shopcenter_products
- SET has_parameters = 1
- WHERE products_id IN (
- SELECT DISTINCT products_id
- FROM products_has_params_values
- );
- # DELETE ALL products WITH no parameters, NOT CREATE BY companies AND NOT edited BY admin
- DELETE
- FROM shopcenter_products
- WHERE has_parameters = 0
- AND is_edited_by_admin = 0
- AND companies_id IS NULL
- AND products_id NOT IN (
- SELECT DISTINCT products_id
- FROM shopcenter_products_has_shopcenter_xml_feeds
- WHERE feeds_id = 1
- );
- # DELETE ALL xml_products that has been deleted IN pevious step
- DELETE FROM shopcenter_products_has_shopcenter_xml_feeds
- WHERE products_id NOT IN (
- SELECT DISTINCT products_id
- FROM products_has_params_values
- );
- # CREATE VIEW OF products that have been linked together FROM wrong reson (name = "")
- CREATE VIEW _tmp_debug AS (
- SELECT products_id
- FROM shopcenter_products_has_shopcenter_xml_feeds AS x
- LEFT JOIN shopcenter_products AS s
- USING(products_id)
- GROUP BY product_name_override, categories_id_main
- HAVING COUNT(products_id) > 1
- AND products_id NOT IN (
- # Product groups groupped BY name (has been linekd together OR should have been)
- SELECT DISTINCT products_id
- FROM shopcenter_products_has_shopcenter_xml_feeds AS x
- LEFT JOIN shopcenter_products AS s
- USING(products_id)
- GROUP BY products_id, categories_id_main
- HAVING COUNT(products_id) > 1
- )
- );
- # DELETE products FROM VIEW we have created ina previous step
- DELETE FROM shopcenter_products_has_shopcenter_xml_feeds
- WHERE products_id IN (
- SELECT products_id FROM _tmp_debug
- )
- # Creal ALL traces
- DROP VIEW _tmp_debug;
- # CREATE VIEW OF products that have been linked together FROM wrong reson (code = "")
- CREATE VIEW _tmp_debug AS (
- SELECT products_id
- FROM shopcenter_products_has_shopcenter_xml_feeds AS x
- LEFT JOIN shopcenter_products AS s
- USING(products_id)
- GROUP BY product_code_override, categories_id_main
- HAVING COUNT(products_id) > 1
- AND products_id NOT IN (
- # Product groups groupped BY code (has been linekd together OR should have been)
- SELECT DISTINCT products_id
- FROM shopcenter_products_has_shopcenter_xml_feeds AS x
- LEFT JOIN shopcenter_products AS s
- USING(products_id)
- GROUP BY products_id, categories_id_main
- HAVING COUNT(products_id) > 1
- )
- );
- # DELETE products FROM VIEW we have created ina previous step
- DELETE FROM shopcenter_products_has_shopcenter_xml_feeds
- WHERE products_id IN (
- SELECT products_id FROM _tmp_debug
- )
- # Creal ALL traces
- DROP VIEW _tmp_debug;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement