getProductsRule example

$item2->setReferencedId($item2->getId());
        $item3->setReferencedId($item3->getId());

        $item1->setQuantity(10);
        $item2->setQuantity(10);
        $item3->setQuantity(10);

        $cart->addLineItems(new LineItemCollection([$item1$item2$item3]));

        $rules = new AndRule(
            [
                $this->getProductsRule([$item1->getReferencedId()$item2->getReferencedId()]),
            ]
        );

        $ruleEntity = new RuleEntity();
        $ruleEntity->setId(Uuid::randomHex());
        $ruleEntity->setPayload($rules);

        $group = $this->buildGroup(
            self::KEY_PACKAGER_COUNT,
            5,
            self::KEY_SORTER_PRICE_DESC,
            
public function testMatching(bool $withRules, bool $diffrentId, bool $expected): void
    {
        $lineItem = $this->createProductItem(50, 10);
        $lineItem->setReferencedId($lineItem->getId());

        $ruleCollection = new RuleCollection();

        if ($withRules === true) {
            $matchId = $diffrentId === true ? Uuid::randomHex() : $lineItem->getId();

            $ruleCollection->add($this->buildRuleEntity(
                $this->getProductsRule([$matchId])
            ));
        }

        $group = new LineItemGroupDefinition('test', 'COUNT', 1, 'PRICE_ASC', $ruleCollection);

        static::assertEquals($expected$this->matcher->isMatching($group$lineItem$this->context));
    }

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