Created
February 3, 2015 09:13
-
-
Save borriglione/318f094bcba7b25a5938 to your computer and use it in GitHub Desktop.
Magento Database - Duplicate key checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Duplicate Checks | |
================ | |
http://www.albertomariarossi.it/howto-solve-url-rewrite-indexing-errors-in-magento/ | |
1- Check for duplicate SKUs | |
--------------------------- | |
SELECT | |
DISTINCT(`sku`) as `sku`, | |
COUNT(`sku`) as `skuCount`, `entity_id` FROM `catalog_product_entity` | |
GROUP BY `sku` HAVING `skuCount` > 1; | |
2- Check for duplicate URL keys | |
------------------------------- | |
SELECT url_key, | |
COUNT(url_key) AS NumOccurrences | |
FROM catalog_product_flat_1 | |
GROUP BY url_key HAVING ( COUNT(url_key) > 1 ); | |
3- Check for dupes in products names | |
------------------------------------- | |
SELECT name, | |
COUNT(name) AS NumOccurrences | |
FROM catalog_product_flat_1 | |
GROUP BY name HAVING ( COUNT(name) > 1 ); | |
4 - Check for dupes in customer_entity_varchar | |
----------------------------------------------- | |
SELECT entity_id, attribut_id | |
COUNT(entity_id) AS NumOccurrences | |
FROM customer_entity_varchar | |
GROUP BY name HAVING ( COUNT(name) > 1 ); | |
select entity_id, | |
attribut_id, | |
count(*) | |
from customer_entity_varchar | |
group by entity_id, | |
attribut_id | |
having count(*) > 1 | |
SELECT cp.category_id | |
FROM catalog_category_product cp | |
LEFT JOIN catalog_category_entity c ON cp.category_id = c.entity_id | |
WHERE ISNULL( c.entity_id ) | |
SELECT DISTINCT(cp.product_id) | |
FROM `catalog_category_product` cp | |
LEFT JOIN catalog_product_entity p ON cp.product_id = p.entity_id | |
WHERE ISNULL( p.entity_id ) | |
Fix Category Index | |
================== | |
DELETE | |
FROM `catalog_category_entity_datetime` | |
WHERE `catalog_category_entity_datetime`.`attribute_id` NOT IN ( | |
SELECT `eav_attribute`.attribute_id FROM `eav_entity_type` | |
INNER JOIN `eav_attribute` ON eav_attribute.entity_type_id = eav_entity_type.entity_type_id | |
WHERE (eav_entity_type.entity_type_code='catalog_category') | |
); | |
DELETE | |
FROM `catalog_category_entity_decimal` | |
WHERE `catalog_category_entity_decimal`.`attribute_id` NOT IN ( | |
SELECT `eav_attribute`.attribute_id FROM `eav_entity_type` | |
INNER JOIN `eav_attribute` ON eav_attribute.entity_type_id = eav_entity_type.entity_type_id | |
WHERE (eav_entity_type.entity_type_code='catalog_category') | |
); | |
DELETE | |
FROM `catalog_category_entity_int` | |
WHERE `catalog_category_entity_int`.`attribute_id` NOT IN ( | |
SELECT `eav_attribute`.attribute_id FROM `eav_entity_type` | |
INNER JOIN `eav_attribute` ON eav_attribute.entity_type_id = eav_entity_type.entity_type_id | |
WHERE (eav_entity_type.entity_type_code='catalog_category') | |
); | |
DELETE | |
FROM `catalog_category_entity_text` | |
WHERE `catalog_category_entity_text`.`attribute_id` NOT IN ( | |
SELECT `eav_attribute`.attribute_id FROM `eav_entity_type` | |
INNER JOIN `eav_attribute` ON eav_attribute.entity_type_id = eav_entity_type.entity_type_id | |
WHERE (eav_entity_type.entity_type_code='catalog_category') | |
); | |
DELETE | |
FROM `catalog_category_entity_varchar` | |
WHERE `catalog_category_entity_varchar`.`attribute_id` NOT IN ( | |
SELECT `eav_attribute`.attribute_id FROM `eav_entity_type` | |
INNER JOIN `eav_attribute` ON eav_attribute.entity_type_id = eav_entity_type.entity_type_id | |
WHERE (eav_entity_type.entity_type_code='catalog_category') | |
); | |
http://www.avs-webentwicklung.de/nc/blog/artikel/magento-fehler-beim-index-aufbau-sofortmassnahmen.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment