Skip to content

Instantly share code, notes, and snippets.

@vasilii-b
Created May 13, 2024 10:57
Show Gist options
  • Save vasilii-b/067e82e570933791191e1380f0e3cc33 to your computer and use it in GitHub Desktop.
Save vasilii-b/067e82e570933791191e1380f0e3cc33 to your computer and use it in GitHub Desktop.
Magento 2 - get grouped products child count number
select cpe_parent.entity_id as 'Parent ID', cpe_parent.sku as 'Parent Sku', count(cpe_child.entity_id) as 'Child #', cpe_child.sku as 'Child Sku'
from catalog_product_entity cpe_parent
join catalog_product_link cpl on cpe_parent.type_id = 'grouped' and cpl.link_type_id = 3 and cpe_parent.row_id = cpl.product_id
left join catalog_product_entity cpe_child on cpl.linked_product_id = cpe_child.entity_id
group by cpe_parent.sku
order by 'Child #' DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment