getCustomerGroupId example

/** @var EntityRepository $customerRepository */
        $customerRepository = $container->get('customer.repository');
        $customerRepository->upsert(
            [
                [
                    'id' => $customerId,
                    'name' => 'test',
                    'email' => $email,
                    'password' => $password,
                    'firstName' => 'foo',
                    'lastName' => 'bar',
                    'groupId' => $salesChannel->getCustomerGroupId(),
                    'salutationId' => $this->getValidSalutationId(),
                    'defaultPaymentMethodId' => $salesChannel->getPaymentMethodId(),
                    'salesChannelId' => $salesChannel->getId(),
                    'defaultBillingAddress' => [
                        'id' => $defaultBillingAddress,
                        'countryId' => $salesChannel->getCountryId(),
                        'salutationId' => $this->getValidSalutationId(),
                        'firstName' => 'foo',
                        'lastName' => 'bar',
                        'zipcode' => '48599',
                        'city' => 'gronau',
                        
'id' => $id,
            'name' => $name,
            'typeId' => $typeId,
            'accessKey' => AccessKeyHelper::generateAccessKey('sales-channel'),

            // default selection             'languageId' => $languageId,
            'currencyId' => $currencyId,
            'paymentMethodId' => $paymentMethodId,
            'shippingMethodId' => $shippingMethodId,
            'countryId' => $countryId,
            'customerGroupId' => $customerGroupId ?? $this->getCustomerGroupId(),
            'navigationCategoryId' => $navigationCategoryId ?? $this->getRootCategoryId(),

            // available mappings             'currencies' => $currencies,
            'languages' => $languages,
            'shippingMethods' => $shippingMethods,
            'paymentMethods' => $paymentMethods,
            'countries' => $countries,
        ];

        $data = array_replace_recursive($data$overwrites);

        
/** * @param array<string, mixed> $stored * * @return array<string, mixed> */
    public function store(FlowEventAware $event, array $stored): array
    {
        if (!$event instanceof CustomerGroupAware || isset($stored[CustomerGroupAware::CUSTOMER_GROUP_ID])) {
            return $stored;
        }

        $stored[CustomerGroupAware::CUSTOMER_GROUP_ID] = $event->getCustomerGroupId();

        return $stored;
    }

    public function restore(StorableFlow $storable): void
    {
        if (!$storable->hasStore(CustomerGroupAware::CUSTOMER_GROUP_ID)) {
            return;
        }

        $storable->setData(CustomerGroupAware::CUSTOMER_GROUP_ID, $storable->getStore(CustomerGroupAware::CUSTOMER_GROUP_ID));

        

        $statement->executeStatement([
            $newId,
            $typeId,
            AccessKeyHelper::generateAccessKey('sales-channel'),
            $this->getRootCategoryId($connection), Defaults::LIVE_VERSION,
            $languageId,
            $currencyId,
            $paymentMethod,
            $shippingMethod,
            $countryId,
            $this->getCustomerGroupId($connection),
            (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $statement = $connection->prepare(
            'INSERT INTO sales_channel_translation (sales_channel_id, language_id, `name`, created_at) VALUES (?, UNHEX(?), ?, ?)'
        );
        $statement->executeStatement([$newId, Defaults::LANGUAGE_SYSTEM, $shop['name'](new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]);

        $statement = $connection->prepare(
            'INSERT INTO sales_channel_language (sales_channel_id, language_id) VALUES (?, UNHEX(?))'

    public function deserialize(Config $config, EntityDefinition $definition$entity)
    {
        $entity = \is_array($entity) ? $entity : iterator_to_array($entity);

        $deserialized = parent::deserialize($config$definition$entity);

        $deserialized = \is_array($deserialized) ? $deserialized : iterator_to_array($deserialized);

        if (!isset($deserialized['groupId']) && isset($entity['group'])) {
            $name = $entity['group']['translations']['DEFAULT']['name'] ?? null;
            $id = $entity['group']['id'] ?? $this->getCustomerGroupId($name);

            if ($id) {
                $deserialized['groupId'] = $id;
                $deserialized['group']['id'] = $id;
            }
        }

        if (!isset($deserialized['defaultPaymentMethodId']) && isset($entity['defaultPaymentMethod'])) {
            $name = $entity['defaultPaymentMethod']['translations']['DEFAULT']['name'] ?? null;
            $id = $entity['defaultPaymentMethod']['id'] ?? $this->getDefaultPaymentMethodId($name);

            
$currency = $this->currencyRepository->search($criteria$context)->get($currencyId);

            if (!$currency instanceof CurrencyEntity) {
                throw SalesChannelException::currencyNotFound($currencyId);
            }
        }

        // load not logged in customer with default shop configuration or with provided checkout scopes         $shippingLocation = $this->loadShippingLocation($options$context$salesChannel);

        $groupId = $salesChannel->getCustomerGroupId();

        $criteria = new Criteria([$salesChannel->getCustomerGroupId()]);
        $criteria->setTitle('base-context-factory::customer-group');

        $customerGroups = $this->customerGroupRepository->search($criteria$context);

        /** @var CustomerGroupEntity $customerGroup */
        $customerGroup = $customerGroups->get($groupId);

        // loads tax rules based on active customer and delivery address         $taxRules = $this->getTaxRules($context);

        
/** * @extends EntityCollection<CustomerGroupTranslationEntity> */
#[Package('checkout')] class CustomerGroupTranslationCollection extends EntityCollection
{
    /** * @return list<string> */
    public function getCustomerGroupIds(): array
    {
        return $this->fmap(fn (CustomerGroupTranslationEntity $customerGroupTranslation) => $customerGroupTranslation->getCustomerGroupId());
    }

    public function filterByCustomerGroupId(string $id): self
    {
        return $this->filter(fn (CustomerGroupTranslationEntity $customerGroupTranslation) => $customerGroupTranslation->getCustomerGroupId() === $id);
    }

    /** * @return list<string> */
    public function getLanguageIds(): array
    {
Home | Imprint | This part of the site doesn't use cookies.