protected function validateTypeCategoryGroup()
    {
        $field = 'type';

        if ($this->isExcluded($field) || $this->isError('store_id')) {
            return null;
        }

        $type = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($type)) {
            return null;
        }

        $store_id = $this->getSubmitted('store_id');

        if (!isset($store_id)) {
            $this->setErrorRequired($field, $this->translation->text('Store'));
            return false;
        }

        $label = $this->translation->text('Type');

        if (empty($type)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        $types = $this->category_group->getTypes();

        if (!isset($types[$type])) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        $updating = $this->getUpdating();
        $list = $this->category_group->getList(array('type' => $type, 'store_id' => $store_id));

        if (isset($updating['category_group_id'])) {
            unset($list[$updating['category_group_id']]);
        }

        if (empty($list)) {
            return true;
        }

        $error = $this->translation->text('Category group of this type already exists for this store');
        $this->setError('type', $error);
        return false;
    }