Skip to content

Instantly share code, notes, and snippets.

View mrwadson's full-sized avatar
:shipit:
So Working Hard..

Vadim Danilov mrwadson

:shipit:
So Working Hard..
View GitHub Profile
@mrwadson
mrwadson / 1_product_queries.sql
Last active January 27, 2020 17:40 — forked from DanielSousa/1_product_queries.sql
Magento 2 - Remove duplicate store view-specific product and category data
#
# These queries check attributes values at the none-global store view scopes.
#
-- catalog_product_entity_datetime
SELECT a.*
FROM (SELECT * FROM catalog_product_entity_datetime) AS a
-- This inner join finds all store view-specific rows that exactly match the global scope value. The b.store_id = 0 conditional is key as it targets the global row
INNER JOIN (SELECT * FROM catalog_product_entity_datetime) AS b ON a.attribute_id = b.attribute_id AND a.entity_id = b.entity_id AND a.value = b.value AND b.store_id = 0
WHERE a.store_id <> 0
GROUP BY a.attribute_id, a.entity_id, a.value, a.store_id;