visibility example



    private function addProducts(Cart $cart, IdsCollection $ids): Cart
    {
        $taxIds = $this->salesChannelContext->getTaxRules()->getIds();
        $ids->set('t1', (string) array_pop($taxIds));

        $this->productRepository->create([
            (new ProductBuilder($ids, 'product'))
                ->price(100)
                ->tax('t1')
                ->visibility()
                ->add('height', 3)
                ->add('width', 3)
                ->add('length', 3)
                ->build(),
        ]$this->salesChannelContext->getContext());

        return $this->addProductToCart($ids->get('product'), 1, $cart$this->cartService, $this->salesChannelContext);
    }

    private function changeTransactionStateToPaid(string $orderId): void
    {
        
return $payload;
    }

    private function prepareTestDataWithInheritedAndVersionized(): Context
    {
        $context = Context::createDefaultContext();

        $products = [
            (new ProductBuilder($this->ids, 'p1'))
                ->price(100)
                ->visibility()
                ->build(),
            (new ProductBuilder($this->ids, 'p2'))
                ->price(100)
                ->variant(
                    (new ProductBuilder($this->ids, 'v2.1'))
                        ->option('red', 'color')
                        ->build()
                )
                ->variant(
                    (new ProductBuilder($this->ids, 'v2.2'))
                        ->option('green', 'color')
                        
$fs->write('a.txt', 'test');
        static::assertSame(4, $fs->fileSize('a.txt'));

        static::expectException(UnableToRetrieveMetadata::class);
        $fs->fileSize('bla');
    }

    public function testVisibility(): void
    {
        $fs = new Filesystem(new MemoryFilesystemAdapter());
        $fs->write('a.txt', 'test');
        static::assertSame(Visibility::PUBLIC$fs->visibility('a.txt'));

        static::expectException(UnableToRetrieveMetadata::class);
        $fs->visibility('bla');
    }

    public function testSetVisibility(): void
    {
        $fs = new Filesystem(new MemoryFilesystemAdapter());
        $fs->write('a.txt', 'test');
        static::assertSame(Visibility::PUBLIC$fs->visibility('a.txt'));
        $fs->setVisibility('a.txt', Visibility::PRIVATE);
        
class Main extends BaseScript
{
    public function run()
    {
        $ids = new IdsCollection();

        $this->getContainer()->get(Connection::class)
            ->executeStatement('DELETE FROM product WHERE product_number = :number', ['number' => 'p1']);

        $product = (new ProductBuilder($ids, 'p1'))
            ->price(100)
            ->visibility()
            ->build();

        $this->getContainer()->get('product.repository')
            ->create([$product], Context::createDefaultContext());

        // all services are public in script mode         $service = $this->getContainer()->get(CartService::class);

        $context = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create($ids->get('token'), TestDefaults::SALES_CHANNEL);

        
$ids,
            function DIdsCollection $ids, SalesChannelContext $context): void {
            },
            1,
        ];

        yield 'Test assign a new product to the category as listing product' => [
            $ids,
            function DIdsCollection $ids, SalesChannelContext $context, ContainerInterface $container): void {
                $product = (new ProductBuilder($ids, 'test-assign'))
                    ->price(100)
                    ->visibility()
                    ->category('navigation')
                    ->build();

                $container->get('product.repository')
                    ->create([$product]$context->getContext());
            },
            2,
        ];

        yield 'Test update a product which is assigned as listing product' => [
            $ids,
            
static::assertSame(15, $response['total']);
        static::assertSame('product', $response['elements'][0]['apiAlias']);
        static::assertArrayHasKey('id', $response['elements'][0]);
        static::assertArrayHasKey('apiAlias', $response['elements'][0]);
        static::assertArrayNotHasKey('name', $response['elements'][0]);
    }

    public function testListingProductsIncludesOnlyPublicReviews(): void
    {
        $product = (new ProductBuilder($this->ids, 'p1'))
            ->visibility($this->ids->get('sales-channel'))
            ->price(10)
            ->review('test public review', 'this is a public review', 3, $this->ids->get('sales-channel'))
            ->review('test hidden review', 'this is a hidden review', 0, $this->ids->get('sales-channel'), Defaults::LANGUAGE_SYSTEM, false)
            ->build();

        $this->getContainer()->get('product.repository')
            ->upsert([$product], Context::createDefaultContext());

        $this->browser->request(
            'POST',
            '/store-api/product',
            [


    public function testCheapestPriceOnSalesChannelProductEntity(): void
    {
        $ids = new IdsCollection();

        $this->getContainer()->get('product.repository')
            ->create([
                (new ProductBuilder($ids, 'p.1'))
                    ->price(130)
                    ->prices('rule-a', 150)
                    ->visibility()
                    ->build(),
            ], Context::createDefaultContext());

        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);
        /** @var SalesChannelProductEntity $productEntity */
        $productEntity = $this->getContainer()
            ->get('sales_channel.product.repository')
            ->search(new Criteria([$ids->get('p.1')])$salesChannelContext)
            ->first();

        
shuffle($keywords);
            $name = ucfirst(implode(' ', $keywords) . ' product');

            $number = Uuid::randomHex();

            $product = (new ProductBuilder($ids$number))
                ->price($price)
                ->name($name)
                ->active(true)
                ->tax('test-' . Uuid::randomHex()$tax)
                ->visibility()
                ->build();

            $products[] = $product;

            $lineItems[] = $factory->create(['id' => $ids->get($number), 'referencedId' => $ids->get($number)]$this->salesChannelContext);
            $this->addTaxDataToSalesChannel($this->salesChannelContext, $product['tax']);
        }

        $this->productRepository->create($products, Context::createDefaultContext());

        return $this->cartService->add($cart$lineItems$this->salesChannelContext);
    }
static::assertNotContains('v.2.1', $names);
        static::assertNotContains('v.2.2', $names);
    }

    private function prepareTestData(): void
    {
        $products = [
            (new ProductBuilder($this->ids, 'p.1'))
                ->price(900)
                ->property('rot', 'Farbe')
                ->property('grün', 'Farbe')
                ->visibility(TestDefaults::SALES_CHANNEL)
                ->prices('rule-a', 220, 'default', null, 3, true)
                ->variant(
                    (new ProductBuilder($this->ids, 'v.1.1'))
                        ->build()
                )
                ->variant(
                    (new ProductBuilder($this->ids, 'v.1.2'))
                        ->prices('rule-a', 210, 'default', null, 3, true)
                        ->prices('rule-b', 501, 'default', null, 3, true)
                        ->build()
                )
                
static::assertEquals($value$actual[$key]sprintf('Value for key %s not matching', $current));
        }
    }

    private function createData(): void
    {
        $products = [
            (new ProductBuilder($this->ids, 'product'))
                ->price(15)
                ->manufacturer('m1')
                ->visibility($this->ids->get('sales-channel'))
                ->build(),

            // regression test for: NEXT-17603             (new ProductBuilder($this->ids, 'with-layout'))
                ->price(100)
                ->media('m1', 1)
                ->media('m2', 2)
                ->media('m3', 3)
                ->review('Test', 'test')
                ->manufacturer('m1')
                ->crossSelling('selling', 'stream-1')
                


    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        $options->specificContent(new ShareContentShare($notification->getSubject()));

        if ($notification->getContent()) {
            $options->specificContent(new ShareContentShare($notification->getContent()));
        }

        $options->visibility(new VisibilityShare());
        $options->lifecycleState(new LifecycleStateShare());

        return $options;
    }

    /** * @return $this */
    public function contentCertificationRecord(string $contentCertificationRecord)static
    {
        $this->options['contentCertificationRecord'] = $contentCertificationRecord;

        


    public function testRepositoryCall(): void
    {
        $this->loadAppsFromDir(__DIR__ . '/_fixtures');

        $ids = new IdsCollection();

        $salesChannelId = $this->browser->getServerParameter('test-sales-channel-id');

        $products = [
            (new ProductBuilder($ids, 'p1'))->visibility($salesChannelId)->price(100)->build(),
            (new ProductBuilder($ids, 'p2'))->visibility($salesChannelId)->price(200)->build(),
        ];

        $this->getContainer()->get('product.repository')->create($products, Context::createDefaultContext());

        $criteria = [
            'filter' => [
                ['type' => 'equals', 'field' => 'productNumber', 'value' => 'p1'],
            ],
            'includes' => [
                'dal_entity_search_result' => ['elements'],
                
bool $blue,
        bool $green,
        bool $red,
        bool $l,
        bool $xl,
        bool $shouldThrowException = false
    ): void {
        $products = (new ProductBuilder($this->ids, 'a.0'))
            ->manufacturer('m1')
            ->name('test')
            ->price(10)
            ->visibility()
            ->configuratorSetting('red', 'color')
            ->configuratorSetting('green', 'color')
            ->configuratorSetting('blue', 'color')
            ->configuratorSetting('l', 'size')
            ->configuratorSetting('xl', 'size')
            ->configuratorSetting('m', 'size')
            ->stock(10)
            ->closeout()
            ->variant(
                (new ProductBuilder($this->ids, 'a.1'))
                    ->option('red', 'color')
                    
/** * @dataProvider invalidationProvider */
    public function testInvalidation(IdsCollection $ids, \Closure $before, \Closure $after, int $calls): void
    {
        $this->getContainer()->get('cache.object')
            ->invalidateTags([CachedProductReviewRoute::ALL_TAG]);

        $products = [
            (new ProductBuilder($ids, 'product'))
                ->price(100)
                ->visibility()
                ->review('Super', 'Amazing product!!!!', 3, TestDefaults::SALES_CHANNEL, DEFAULTS::LANGUAGE_SYSTEM, false)
                ->build(),

            (new ProductBuilder($ids, 'other-product'))
                ->price(100)
                ->visibility()
                ->review('other-product', 'Amazing other-product!!!!')
                ->build(),
        ];

        $this->getContainer()->get('product.repository')
            
'shortName' => 'TE',
                'name' => 'Test',
            ];
            $this->getContainer()->get('currency.repository')
                ->create([$currency], Context::createDefaultContext());

            $products = [
                // no rule = 70€                 (new ProductBuilder($ids, 'p.1'))
                    ->price(70, null, 'default', 77)
                    ->price(99, null, 'currency')
                    ->visibility(TestDefaults::SALES_CHANNEL)
                    ->build(),

                // no rule = 79€                 (new ProductBuilder($ids, 'p.2'))
                    ->active(false)
                    ->price(80)
                    ->visibility(TestDefaults::SALES_CHANNEL)
                    ->variant(
                        (new ProductBuilder($ids, 'v.2.1'))
                            ->build()
                    )
                    
Home | Imprint | This part of the site doesn't use cookies.