getGroupId example

return $collection;
    }

    /** * @param array<string> $current */
    private function isCombinable(
        PropertyGroupOptionEntity $option,
        array $current,
        AvailableCombinationResult $combinations
    ): ?bool {
        unset($current[$option->getGroupId()]);
        $current[] = $option->getId();

        // available with all other current selected options         if ($combinations->hasCombination($current) && $combinations->isAvailable($current)) {
            return true;
        }

        // available but not with the other current selected options         if ($combinations->hasOptionId($option->getId())) {
            return false;
        }

        


    private function buildGroupBy(Criteria $criteria): ?string
    {
        $conditions = $criteria->getConditionsByClass(VariantCondition::class);

        $conditions = array_filter($conditionsfunction DVariantCondition $condition) {
            return $condition->expandVariants();
        });

        $groups = array_map(function DVariantCondition $condition) {
            return $condition->getGroupId();
        }$conditions);

        if (empty($conditions)) {
            return null;
        }

        sort($groups, SORT_NUMERIC);

        return 'visibility.g' . implode('-', $groups);
    }
}
if (!$criteria->hasConditionOfClass(VariantCondition::class)) {
            return $result;
        }

        $this->listingPriceService->updatePrices($criteria$result$context);

        $products = $result->getProducts();
        $configurations = $this->configuratorService->getProductsConfigurations($products$context);

        $filterGroupIds = array_map(function D$variantCondition) {
            if ($variantCondition->expandVariants()) {
                return $variantCondition->getGroupId();
            }

            return null;
        }$criteria->getConditionsByClass(VariantCondition::class));

        if (!empty($filterGroupIds)) {
            foreach ($products as $product) {
                if (!\array_key_exists($product->getNumber()$configurations)) {
                    continue;
                }

                
foreach ($combinations as $key => $combination) {
            $options = [];

            if (\is_string($combination)) {
                $combination = [$combination];
            }

            foreach ($combination as $option) {
                [$group$option] = explode('|', $option);

                $optionId = $this->getOptionId($group$option);
                $groupId = $this->getGroupId($group);

                $options[] = [
                    'id' => $optionId,
                    'name' => $option,
                    'group' => [
                        'id' => $groupId,
                        'name' => $group,
                    ],
                ];
            }

            
return null;
        }

        $group = $product->getProperties()->getGroups()->get($id);

        if ($group === null) {
            return null;
        }

        $properties = $product->getProperties()->fmap(
            static function DPropertyGroupOptionEntity $property) use ($id) {
                if ($property->getGroupId() !== $id) {
                    return null;
                }

                return [
                    'id' => $property->getId(),
                    'name' => $property->getTranslation('name'),
                    'mediaId' => $property->getMediaId(),
                    'colorHexCode' => $property->getColorHexCode(),
                ];
            }
        );

        
/** * @extends EntityCollection<CustomerEntity> */
#[Package('checkout')] class CustomerCollection extends EntityCollection
{
    /** * @return list<string> */
    public function getGroupIds(): array
    {
        return $this->fmap(fn (CustomerEntity $customer) => $customer->getGroupId());
    }

    public function filterByGroupId(string $id): self
    {
        return $this->filter(fn (CustomerEntity $customer) => $customer->getGroupId() === $id);
    }

    /** * @return list<string> */
    public function getDefaultPaymentMethodIds(): array
    {


    public function getGroupedOptions(): PropertyGroupCollection
    {
        $groups = new PropertyGroupCollection();

        foreach ($this->getIterator() as $element) {
            if (!$element->getOption()) {
                continue;
            }

            if ($groups->has($element->getOption()->getGroupId())) {
                $group = $groups->get($element->getOption()->getGroupId());
            } else {
                $group = PropertyGroupEntity::createFrom($element->getOption()->getGroup() ?? new PropertyGroupEntity());

                $groups->add($group);

                $group->setOptions(new PropertyGroupOptionCollection());
            }

            if ($group->getOptions()) {
                $group->getOptions()->add($element->getOption());
            }
static::assertCount(2, $sheet);

        static::assertTrue($sheet->has($redId));
        static::assertTrue($sheet->has($blueId));

        $blue = $sheet->get($blueId);
        $red = $sheet->get($redId);

        static::assertSame('red', $red->getName());
        static::assertSame('blue', $blue->getName());

        static::assertSame($colorId$red->getGroupId());
        static::assertSame($colorId$blue->getGroupId());
    }

    public function testCreateAndAssignProductOption(): void
    {
        $id = Uuid::randomHex();
        $redId = Uuid::randomHex();
        $blueId = Uuid::randomHex();
        $colorId = Uuid::randomHex();

        $data = [
            


    private function buildGroupBy(Criteria $criteria): ?string
    {
        $conditions = $criteria->getConditionsByClass(VariantCondition::class);

        $conditions = array_filter($conditionsfunction DVariantCondition $condition) {
            return $condition->expandVariants();
        });

        $groups = array_map(function DVariantCondition $condition) {
            return $condition->getGroupId();
        }$conditions);

        if (empty($conditions)) {
            return null;
        }

        sort($groups, SORT_NUMERIC);

        return 'availability.g' . implode('-', $groups);
    }
}
if ($order === null) {
            throw OrderException::orderNotFound($orderId);
        }

        if ($order->getOrderCustomer() === null) {
            throw OrderException::missingAssociation('orderCustomer');
        }

        $customer = $order->getOrderCustomer()->getCustomer();
        $customerGroupId = null;
        if ($customer) {
            $customerGroupId = $customer->getGroupId();
        }

        $billingAddress = $order->getBillingAddress();
        $countryStateId = null;
        if ($billingAddress) {
            $countryStateId = $billingAddress->getCountryStateId();
        }

        $options = [
            SalesChannelContextService::CURRENCY_ID => $order->getCurrencyId(),
            SalesChannelContextService::LANGUAGE_ID => $order->getLanguageId(),
            
return $articles;
    }

    /** * @param array<Group> $config * @param array<VariantCondition> $conditions */
    private function buildListingVariantLink(string $number, array $config, array $conditions): string
    {
        $groupIds = array_map(function DVariantCondition $condition) {
            return $condition->getGroupId();
        }$conditions);

        $filtered = array_filter($configfunction DGroup $group) use ($groupIds) {
            return \in_array($group->getId()$groupIds, true);
        });

        if (\count($config) === \count($filtered)) {
            return 'number=' . $number;
        }

        $keys = [];
        
use Shopware\Bundle\StoreFrontBundle\Struct\ShopContextInterface;

class PriceFieldMapper
{
    public function getPriceField(Criteria $criteria, ShopContextInterface $context)
    {
        $customerGroup = $context->getCurrentCustomerGroup()->getKey();
        $currency = $context->getCurrency()->getId();

        $conditions = $criteria->getConditionsByClass(VariantCondition::class);
        $ids = array_map(function DVariantCondition $condition) {
            return $condition->getGroupId();
        }$conditions);

        if (empty($conditions)) {
            return 'calculatedPrices.' . $customerGroup . '_' . $currency . '.calculatedPrice';
        }

        $ids = array_filter($ids);
        sort($ids, SORT_NUMERIC);

        $first = $customerGroup . '_' . $currency;
        $second = 'g' . implode('-', $ids);

        
/** * @extends EntityCollection<PropertyGroupOptionEntity> */
#[Package('inventory')] class PropertyGroupOptionCollection extends EntityCollection
{
    /** * @return array<string> */
    public function getPropertyGroupIds(): array
    {
        return $this->fmap(fn (PropertyGroupOptionEntity $propertyGroupOption) => $propertyGroupOption->getGroupId());
    }

    public function filterByGroupId(string $id): self
    {
        return $this->filter(fn (PropertyGroupOptionEntity $propertyGroupOption) => $propertyGroupOption->getGroupId() === $id);
    }

    /** * @return array<string> */
    public function getMediaIds(): array
    {
if ($order->getOrderCustomer() === null) {
            throw OrderException::missingAssociation('orderCustomer');
        }

        $customerId = $order->getOrderCustomer()->getCustomerId();
        $customerGroupId = null;

        if ($customerId) {
            /** @var CustomerEntity|null $customer */
            $customer = $this->customerRepository->search(new Criteria([$customerId])$context)->get($customerId);
            if ($customer !== null) {
                $customerGroupId = $customer->getGroupId();
            }
        }

        $billingAddressId = $order->getBillingAddressId();
        $billingAddress = $this->orderAddressRepository->search(new Criteria([$billingAddressId])$context)->get($billingAddressId);
        if (!$billingAddress instanceof OrderAddressEntity) {
            throw CartException::addressNotFound($billingAddressId);
        }

        $options = [
            SalesChannelContextService::CURRENCY_ID => $order->getCurrencyId(),
            
$shippingLocation = $base->getShippingLocation();
        if ($customer) {
            /** @var CustomerAddressEntity $activeShippingAddress */
            $activeShippingAddress = $customer->getActiveShippingAddress();
            $shippingLocation = ShippingLocation::createFromAddress($activeShippingAddress);
        }

        $customerGroup = $base->getCurrentCustomerGroup();

        if ($customer) {
            $criteria = new Criteria([$customer->getGroupId()]);
            $criteria->setTitle('context-factory::customer-group');
            /** @var CustomerGroupEntity $customerGroup */
            $customerGroup = $this->customerGroupRepository->search($criteria$base->getContext())->first() ?? $customerGroup;
        }

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

        // detect active payment method, first check if checkout defined other payment method, otherwise validate if customer logged in, at least use shop default         $payment = $this->getPaymentMethod($options$base$customer);

        [
Home | Imprint | This part of the site doesn't use cookies.