Skip to content

Instantly share code, notes, and snippets.

@bkozora
Created April 5, 2016 15:25
Show Gist options
  • Save bkozora/2105376448b3fc0707e68caecaaedda1 to your computer and use it in GitHub Desktop.
Save bkozora/2105376448b3fc0707e68caecaaedda1 to your computer and use it in GitHub Desktop.
Magento - Grab Orphaned Enabled Products
SELECT
*
FROM
catalog_product_entity a
LEFT JOIN
catalog_product_entity_int ei ON ei.entity_id = a.entity_id
LEFT JOIN
catalog_category_product cp ON cp.`product_id` = a.entity_id
LEFT JOIN
catalog_product_relation cpr ON cpr.child_id = a.entity_id
WHERE
cp.product_id IS NULL
AND cpr.parent_id IS NULL
AND a.type_id != 'configurable'
AND ei.attribute_id = 89
AND ei.value = 1
/*
AND attribute_id = (SELECT
attribute_id
FROM
`eav_attribute`
WHERE
`attribute_code` LIKE 'status')
AND `ei`.`value` = 1
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment