public function cgetAction(Request $request, $parentId)
    {
        if ($request->get('flat') == 'true') {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $listBuilder = $factory->create(self::$entityName);

            $fieldDescriptors = $this->getProductVariantManager()->retrieveFieldDescriptors($this->getLocale($request));

            $restHelper->initializeListBuilder(
                $listBuilder,
                $fieldDescriptors
            );

            $listBuilder->where($fieldDescriptors['parent'], $parentId);
            $listBuilder->addGroupBy($fieldDescriptors['id']);

            // Only add group by id if categories are processed.
            $fieldsParam = $request->get('fields');
            $fields = explode(',', $fieldsParam);
            if (isset($filter['categories'])
                || !$fieldsParam
                || array_search('categories', $fields) !== false
            ) {
                $listBuilder->addGroupBy($fieldDescriptors['id']);
            }

            $list = new ListRepresentation(
                $listBuilder->execute(),
                self::$entityKey,
                'get_product_variants',
                array_merge(
                    $request->query->all(),
                    [
                        'parentId' => $parentId,
                    ]
                ),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
        } else {
            $list = new CollectionRepresentation(
                $this->getProductManager()->findAllByLocale($this->getLocale($request)),
                self::$entityKey
            );
        }

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }