How to get Grouped Product id from child product id in Magento 2?

Using Magento 2, You can fetch Parent product Ids as an array from the child id of the product.

To Retrieve the Parent product id, You need Child Item Id associated with Grouped Product. Using Magento\GroupedProduct\Model\Product\Type\Grouped Magento Core class you can fetch the parent product Id.

For More Knowledge check the article, You can fetch All the children’s items by Grouped Product SKU.

Used function getParentIdsByChild($childProductId)

You need to pass the first parameter as $childProductId for getting the parent product ID of the child item id.

$childIds = 33;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$parentId = $objectManager->create('Magento\GroupedProduct\Model\Product\Type\Grouped')->getParentIdsByChild($childIds);
echo "<pre>";print_r($parentId);

You can call Grouped Class in your Block __construct function, Create Block class,

public function __construct(
        \Magento\GroupedProduct\Model\Product\Type\Grouped $groupedProduct
    ) {
        $this->groupedProduct = $groupedProduct;
 * $childId Child Item id
public function getGroupedProductId($childId) {

Call from a template file,

$childrenItemID = 33;
echo $block->getGroupedProductId($childrenItemID);