Skip to content

Instantly share code, notes, and snippets.

@trabulium
Last active August 22, 2018 04:11
Show Gist options
  • Save trabulium/438b27d192d854185db6b4835a4bece5 to your computer and use it in GitHub Desktop.
Save trabulium/438b27d192d854185db6b4835a4bece5 to your computer and use it in GitHub Desktop.
Magento 1: Find orphaned simple products with no parent configurable
select
type_id,sku, cpev.value,
CASE when cpei2.value = 1 THEN "Enabled" ELSE "Disabled" END
from catalog_product_entity a
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
left join catalog_product_entity_int cpei on cpei.`entity_id` = a.entity_id AND cpei.attribute_id = '91' #visibility
left join catalog_product_entity_int cpei2 on cpei2.`entity_id` = a.entity_id AND cpei2.attribute_id = '84' #status
left join catalog_product_entity_varchar cpev on cpev.`entity_id` = a.entity_id AND cpev.attribute_id = '60' #name
where
cpr.parent_id is null
and a.type_id != 'configurable'
and cpei.value = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment