How to get all children items of grouped product Magento 2?

Magento Get All the Child Products associated with Grouped Product Programmatically.

While you working with the Grouped product-related functionality, You need to fetch all the children’s items available with the grouped products.

You have to fetch the first product object, Based on that, You can retrieve all the children’s items from it and loop over items to get the associated child products individually.

You can check the article if you want to Get Grouped Product ID from their child’s product.

<?php
declare(strict_types=1);

namespace Rbj\Product\Model;

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;

class GroupedProductChildrenItem
{
    public function __construct(
        private ProductRepositoryInterface $productRepository
    ) {
    }

    public function getChildItemsFromGroupedProduct(string $sku): array
    {
        try {
            $product = $this->productRepository->get($sku);
        } catch (NoSuchEntityException $noEntityException) {
            throw new LocalizedException(
                __('Please correct the product SKU.'),
                $noEntityException
            );
        }

        return $product->getTypeInstance()->getAssociatedProducts($product);
    }
}

From the Above Model class, you need to call the function and check each individual item by looping over it,

$sku = 'GROUPED_SKU';
$childProductsData = $this->getChildItemsFromGroupedProduct($sku);
foreach ($childProductsData as $childProduct) {
    $childItems = $childProduct;
}

If Grouped Product has associated items, You can fetch all the items by the above code.