loaded example

$productEntity = $this->getContainer()
            ->get('sales_channel.product.repository')
            ->search($criteria$salesChannelContext)
            ->first();

        $subscriber = $this->getContainer()->get(ProductSubscriber::class);
        $productLoadedEvent = new EntityLoadedEvent(
            $this->getContainer()->get(ProductDefinition::class),
            [$productEntity],
            Context::createDefaultContext()
        );
        $subscriber->loaded($productLoadedEvent);

        $sortedPropertiesCollection = $productEntity->getSortedProperties();

        static::assertInstanceOf(PropertyGroupCollection::class$sortedPropertiesCollection);

        $sortedProperties = $sortedPropertiesCollection->getElements();

        foreach ($expected as $expectedGroupKey => $expectedGroup) {
            $optionElementsCollection = $sortedProperties[$expectedGroupKey]->getOptions();

            static::assertInstanceOf(PropertyGroupOptionCollection::class$optionElementsCollection);
            
$this->createMock(ProductMaxPurchaseCalculator::class),
            $this->createMock(IsNewDetector::class),
            $config,
        );

        $event = new EntityLoadedEvent(
            $this->createMock(ProductDefinition::class),
            [$entity],
            Context::createDefaultContext()
        );

        $subscriber->loaded($event);

        static::assertSame($expected$entity->get('cmsPageId'));
    }

    /** * @dataProvider resolveCmsPageIdProviderWithSalesChannelLoadedEventProvider */
    public function testResolveCmsPageIdProviderWithSalesChannelLoadedEvent(Entity $entity, SystemConfigService $config, ?string $expected): void
    {
        $subscriber = new ProductSubscriber(
            $this->createMock(ProductVariationBuilder::class),
            
Home | Imprint | This part of the site doesn't use cookies.