Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hughgrigg/69bb3702382a76bd79a4 to your computer and use it in GitHub Desktop.
Save hughgrigg/69bb3702382a76bd79a4 to your computer and use it in GitHub Desktop.
Removing invalid rows from Magento eav_attribute_option and catalog_product_entity_int
# Delete option rows pointing to non-existent attributes
DELETE `option`
FROM `eav_attribute_option` AS `option`
LEFT JOIN `eav_attribute`
ON `eav_attribute`.`attribute_id` = `option`.`attribute_id`
WHERE `eav_attribute`.`attribute_id` IS NULL;
# Delete product attribute int rows pointing to non-existent attributes
DELETE `entity_int`
FROM `catalog_product_entity_int` AS `entity_int`
LEFT JOIN `eav_attribute` AS `attribute`
ON (`attribute`.`attribute_id` = `entity_int`.`attribute_id`)
WHERE `attribute`.`attribute_id` IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment