getMax example

$intField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(IntField::class$intField);
        static::assertEquals('test_int_field', $intField->getName());
        static::assertEquals([
            'en-GB' => 'Test int field',
            'de-DE' => 'Test Ganzzahlenfeld',
        ]$intField->getLabel());
        static::assertEquals(['en-GB' => 'This is an int field.']$intField->getHelpText());
        static::assertEquals(1, $intField->getPosition());
        static::assertEquals(2, $intField->getSteps());
        static::assertEquals(0, $intField->getMin());
        static::assertEquals(1, $intField->getMax());
        static::assertEquals(['en-GB' => 'Enter an int...']$intField->getPlaceholder());
        static::assertTrue($intField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $intField = $this->importCustomField(__DIR__ . '/_fixtures/int-field.xml');

        static::assertEquals('test_int_field', $intField->getName());
        static::assertEquals('int', $intField->getType());
        static::assertTrue($intField->isActive());
        
$latest = new \DateTimeImmutable($latest->format(Defaults::STORAGE_DATE_TIME_FORMAT));

        $this->earliest = $earliest->setTime(16, 0);
        $this->latest = $latest->setTime(16, 0);
    }

    public static function createFromDeliveryTime(DeliveryTime $deliveryTime): self
    {
        return match ($deliveryTime->getUnit()) {
            DeliveryTimeEntity::DELIVERY_TIME_HOUR => new self(
                self::create('PT' . $deliveryTime->getMin() . 'H'),
                self::create('PT' . $deliveryTime->getMax() . 'H')
            ),
            DeliveryTimeEntity::DELIVERY_TIME_DAY => new self(
                self::create('P' . $deliveryTime->getMin() . 'D'),
                self::create('P' . $deliveryTime->getMax() . 'D')
            ),
            DeliveryTimeEntity::DELIVERY_TIME_WEEK => new self(
                self::create('P' . $deliveryTime->getMin() . 'W'),
                self::create('P' . $deliveryTime->getMax() . 'W')
            ),
            DeliveryTimeEntity::DELIVERY_TIME_MONTH => new self(
                self::create('P' . $deliveryTime->getMin() . 'M'),
                
$floatField = $customFieldSet->getFields()[0];
        static::assertInstanceOf(FloatField::class$floatField);
        static::assertEquals('test_float_field', $floatField->getName());
        static::assertEquals([
            'en-GB' => 'Test float field',
            'de-DE' => 'Test Kommazahlenfeld',
        ]$floatField->getLabel());
        static::assertEquals(['en-GB' => 'This is an float field.']$floatField->getHelpText());
        static::assertEquals(2, $floatField->getPosition());
        static::assertEquals(2.2, $floatField->getSteps());
        static::assertEquals(0.5, $floatField->getMin());
        static::assertEquals(1.6, $floatField->getMax());
        static::assertEquals(['en-GB' => 'Enter an float...']$floatField->getPlaceholder());
        static::assertFalse($floatField->getRequired());
    }

    public function testToEntityArray(): void
    {
        $floatField = $this->importCustomField(__DIR__ . '/_fixtures/float-field.xml');

        static::assertEquals('test_float_field', $floatField->getName());
        static::assertEquals('float', $floatField->getType());
        static::assertTrue($floatField->isActive());
        
switch ($criteriaPart->getMode()) {
                case ProductAttributeFacet::MODE_VALUE_LIST_RESULT:
                case ProductAttributeFacet::MODE_RADIO_LIST_RESULT:
                    $criteriaPartResult = $this->createItemListResult($criteriaPart$aggregations[$key]$criteria);
                    break;
                case ProductAttributeFacet::MODE_BOOLEAN_RESULT:
                    $criteriaPartResult = $this->createBooleanResult($criteriaPart$aggregations[$key]$criteria);
                    break;
                case ProductAttributeFacet::MODE_RANGE_RESULT:
                    $criteriaPartResult = $this->createRangeResult($criteriaPart$aggregations[$key]$criteria);

                    if ($criteriaPartResult->getMax() === $criteriaPartResult->getMin()) {
                        $criteriaPartResult = null;
                    }

                    break;
                default:
                    break;
            }
            if ($criteriaPartResult === null) {
                continue;
            }

            
$criteria->addAggregation(new MaxAggregation('max-stock', 'product.stock'));

            $aggregations = $aggregator->aggregate($this->productDefinition, $criteria$this->context);

            static::assertCount(1, $aggregations);

            static::assertTrue($aggregations->has('max-stock'));

            $result = $aggregations->get('max-stock');
            static::assertInstanceOf(MaxResult::class$result);

            static::assertEquals(350, $result->getMax());
        } catch (\Exception $e) {
            static::tearDown();

            throw $e;
        }
    }

    /** * @depends testIndexing */
    public function testMaxAggregationWithTermsAggregation(IdsCollection $data): void
    {
/** * @var string */
    protected $unit;

    public static function createFromEntity(DeliveryTimeEntity $entity): self
    {
        $self = new self();
        $self->setName((string) $entity->getTranslation('name'));
        $self->setUnit($entity->getUnit());
        $self->setMax($entity->getMax());
        $self->setMin($entity->getMin());

        return $self;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): void
    {
$criteria->addAggregation(
            new MaxAggregation('max-price', 'product.price')
        );

        $result = $this->aggregator->aggregate($this->definition, $criteria$context);

        static::assertTrue($result->has('max-price'));

        $max = $result->get('max-price');
        static::assertInstanceOf(MaxResult::class$max);

        static::assertEquals(250, $max->getMax());
    }

    public function testMaxAggregationWithTermsAggregation(): void
    {
        $context = Context::createDefaultContext();

        $criteria = new Criteria(
            $this->ids->getList(['p-1', 'p-2', 'p-3', 'p-4', 'p-5'])
        );

        $criteria->addAggregation(
            
$cases = $this->providerAggregation();
            foreach ($cases as $message => $case) {
                $context->setRuleIds($ids->getList($case['rules']));

                $result = $this->getContainer()->get('sales_channel.product.repository')
                    ->aggregate($criteria$context);

                $aggregation = $result->get('price');

                static::assertInstanceOf(StatsResult::class$aggregation);
                static::assertEquals($case['min']$aggregation->getMin()sprintf('Case `%s` failed', $message));
                static::assertEquals($case['max']$aggregation->getMax()sprintf('Case `%s` failed', $message));
            }
        } catch (\Exception $e) {
            static::tearDown();

            throw $e;
        }
    }

    /** * @return iterable<string, array{ids: array<string>, rules: array<string>}> */
    
Home | Imprint | This part of the site doesn't use cookies.