Skip to content

Instantly share code, notes, and snippets.

@nkajic
Last active August 16, 2023 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkajic/80e497eb69dc78f3dd77abcbdd3e49ec to your computer and use it in GitHub Desktop.
Save nkajic/80e497eb69dc78f3dd77abcbdd3e49ec to your computer and use it in GitHub Desktop.
Delete Magento 2 duplicates on store vs global view catalog product
-- catalog_product_entity_datetime
SELECT * -- DELETE attribute_value_store
FROM catalog_product_entity_datetime attribute_value_store
JOIN catalog_product_entity_datetime attribute_value_global
ON attribute_value_global.store_id = 0
AND attribute_value_global.attribute_id = attribute_value_store.attribute_id
AND attribute_value_global.entity_id = attribute_value_store.entity_id
AND attribute_value_global.value = attribute_value_store.value
WHERE attribute_value_store.store_id > 0
;
-- catalog_product_entity_decimal
SELECT * -- DELETE attribute_value_store
FROM catalog_product_entity_decimal attribute_value_store
JOIN catalog_product_entity_decimal attribute_value_global
ON attribute_value_global.store_id = 0
AND attribute_value_global.attribute_id = attribute_value_store.attribute_id
AND attribute_value_global.entity_id = attribute_value_store.entity_id
AND attribute_value_global.value = attribute_value_store.value
WHERE attribute_value_store.store_id > 0
;
-- catalog_product_entity_int
SELECT * -- DELETE attribute_value_store
FROM catalog_product_entity_int attribute_value_store
JOIN catalog_product_entity_int attribute_value_global
ON attribute_value_global.store_id = 0
AND attribute_value_global.attribute_id = attribute_value_store.attribute_id
AND attribute_value_global.entity_id = attribute_value_store.entity_id
AND attribute_value_global.value = attribute_value_store.value
WHERE attribute_value_store.store_id > 0
;
-- catalog_product_entity_text
SELECT * -- DELETE attribute_value_store
FROM catalog_product_entity_text attribute_value_store
JOIN catalog_product_entity_text attribute_value_global
ON attribute_value_global.store_id = 0
AND attribute_value_global.attribute_id = attribute_value_store.attribute_id
AND attribute_value_global.entity_id = attribute_value_store.entity_id
AND attribute_value_global.value = attribute_value_store.value
WHERE attribute_value_store.store_id > 0
;
-- catalog_product_entity_varchar
SELECT * -- DELETE attribute_value_store
FROM catalog_product_entity_varchar attribute_value_store
JOIN catalog_product_entity_varchar attribute_value_global
ON attribute_value_global.store_id = 0
AND attribute_value_global.attribute_id = attribute_value_store.attribute_id
AND attribute_value_global.entity_id = attribute_value_store.entity_id
AND attribute_value_global.value = attribute_value_store.value
WHERE attribute_value_store.store_id > 0
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment