getRootCategoryId example

'name' => $name,
            'typeId' => $typeId,
            'accessKey' => AccessKeyHelper::generateAccessKey('sales-channel'),

            // default selection             'languageId' => $languageId,
            'currencyId' => $currencyId,
            'paymentMethodId' => $paymentMethodId,
            'shippingMethodId' => $shippingMethodId,
            'countryId' => $countryId,
            'customerGroupId' => $customerGroupId ?? $this->getCustomerGroupId(),
            'navigationCategoryId' => $navigationCategoryId ?? $this->getRootCategoryId(),

            // available mappings             'currencies' => $currencies,
            'languages' => $languages,
            'shippingMethods' => $shippingMethods,
            'paymentMethods' => $paymentMethods,
            'countries' => $countries,
        ];

        $data = array_replace_recursive($data$overwrites);

        
static::assertNull($seoUrl);
    }

    private function createCategoryWithoutSeoUrl(): string
    {
        $id = Uuid::randomHex();

        $data = [
            'id' => $id,
            'name' => Uuid::randomHex(),
            'parentId' => $this->getRootCategoryId(),
        ];

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

        $this->getContainer()->get(Connection::class)->executeStatement(
            'DELETE FROM seo_url WHERE path_info = :pathInfo',
            ['pathInfo' => sprintf('/navigation/%s', $id)]
        );

        return $id;
    }

    
 {
    }

    public function getDefinition(): string
    {
        return CategoryDefinition::class;
    }

    public function generate(int $numberOfItems, DemodataContext $context, array $options = []): void
    {
        $this->faker = $context->getFaker();
        $rootCategoryId = $this->getRootCategoryId($context->getContext());
        $pageIds = $this->getCmsPageIds($context->getContext());
        $tags = $this->getIds('tag');

        $payload = [];
        $lastId = null;
        for ($i = 0; $i < $numberOfItems; ++$i) {
            $cat = $this->createCategory($context$pageIds$tags$rootCategoryId$lastIdrandom_int(3, 5), 1);
            $payload[] = $cat;
            $lastId = $cat['id'];
        }

        

        );
        $statement->executeStatement([
            $newId,
            $typeId,
            AccessKeyHelper::generateAccessKey('sales-channel'),
            $this->getRootCategoryId($connection), Defaults::LIVE_VERSION,
            $languageId,
            $currencyId,
            $paymentMethod,
            $shippingMethod,
            $countryId,
            $this->getCustomerGroupId($connection),
            (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
        ]);

        $statement = $connection->prepare(
            'INSERT INTO sales_channel_translation (sales_channel_id, language_id, `name`, created_at) VALUES (?, UNHEX(?), ?, ?)'
Home | Imprint | This part of the site doesn't use cookies.