ProductSerializer example

protected function setUp(): void
    {
        parent::setUp();
        $this->visibilityRepository = $this->getContainer()->get('product_visibility.repository');
        $this->salesChannelRepository = $this->getContainer()->get('sales_channel.repository');
        $this->productMediaRepository = $this->getContainer()->get('product_media.repository');
        $this->productConfiguratorSettingRepository = $this->getContainer()->get('product_configurator_setting.repository');
    }

    public function testOnlySupportsProduct(): void
    {
        $serializer = new ProductSerializer(
            $this->visibilityRepository,
            $this->salesChannelRepository,
            $this->productMediaRepository,
            $this->productConfiguratorSettingRepository
        );

        static::assertTrue($serializer->supports('product'), 'should support product');

        $definitionRegistry = $this->getContainer()->get(DefinitionInstanceRegistry::class);
        foreach ($definitionRegistry->getDefinitions() as $definition) {
            $entity = $definition->getEntityName();
            
Home | Imprint | This part of the site doesn't use cookies.