getRuleIdsByAreas example

public static function buildStreamTag(string $id): string
    {
        return 'product-stream-' . $id;
    }

    /** * @param string[] $areas */
    public function getSalesChannelContextHash(SalesChannelContext $context, array $areas = []): string
    {
        $ruleIds = $context->getRuleIdsByAreas($areas);

        return md5((string) json_encode([
            $context->getSalesChannelId(),
            $context->getDomainId(),
            $context->getLanguageIdChain(),
            $context->getVersionId(),
            $context->getCurrencyId(),
            $context->getTaxState(),
            $context->getItemRounding(),
            $ruleIds,
        ], \JSON_THROW_ON_ERROR));
    }
$areaRuleIds = [
            'a' => [$idA$idB],
            'b' => [$idA$idC$idD],
            'c' => [$idB],
            'd' => [$idC],
        ];

        $salesChannelContext->setAreaRuleIds($areaRuleIds);

        static::assertEquals($areaRuleIds$salesChannelContext->getAreaRuleIds());

        static::assertEquals([$idA$idB]$salesChannelContext->getRuleIdsByAreas(['a']));
        static::assertEquals([$idA$idB$idC$idD]$salesChannelContext->getRuleIdsByAreas(['a', 'b']));
        static::assertEquals([$idA$idB]$salesChannelContext->getRuleIdsByAreas(['a', 'c']));
        static::assertEquals([$idC]$salesChannelContext->getRuleIdsByAreas(['d']));
        static::assertEquals([]$salesChannelContext->getRuleIdsByAreas(['f']));
    }

    private function getSalesChannelContext(): SalesChannelContext
    {
        return new SalesChannelContext(
            Context::createDefaultContext(),
            'foo',
            
Home | Imprint | This part of the site doesn't use cookies.