CategoryNotFoundException example


        $page = $this->genericLoader->load($request$context);
        $page = NavigationPage::createFrom($page);

        $navigationId = $request->get('navigationId', $context->getSalesChannel()->getNavigationCategoryId());

        $category = $this->cmsPageRoute
            ->load($navigationId$request$context)
            ->getCategory();

        if (!$category->getActive()) {
            throw new CategoryNotFoundException($category->getId());
        }

        $this->loadMetaData($category$page$context->getSalesChannel());
        $page->setNavigationId($category->getId());

        if ($category->getCmsPage()) {
            $page->setCmsPage($category->getCmsPage());
        }

        $this->eventDispatcher->dispatch(
            new NavigationPageLoadedEvent($page$context$request)
        );
'/store-api/category/home',
            [
            ]
        );

        $this->assertCmsPage($this->ids->get('home-category')$this->ids->get('cms-page'));
    }

    private function assertError(string $categoryId): void
    {
        $response = json_decode($this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        $error = new CategoryNotFoundException($categoryId);
        $expectedError = [
            'status' => (string) $error->getStatusCode(),
            'message' => $error->getMessage(),
        ];

        static::assertSame($expectedError['status']$response['errors'][0]['status']);
        static::assertSame($expectedError['message']$response['errors'][0]['detail']);
    }

    private function assertCmsPage(string $categoryId, string $cmsPageId): void
    {
        
public const FOOTER_CATEGORY_NOT_FOUND = 'CHECKOUT__FOOTER_CATEGORY_NOT_FOUND';
    public const AFTER_CATEGORY_NOT_FOUND = 'CONTENT__AFTER_CATEGORY_NOT_FOUND';

    public static function pageNotFound(string $pageId): ShopwareHttpException
    {
        return new PageNotFoundException($pageId);
    }

    public static function categoryNotFound(string $id): ShopwareHttpException
    {
        return new CategoryNotFoundException($id);
    }

    public static function serviceCategoryNotFoundForSalesChannel(string $salesChannelName): self
    {
        return new self(
            Response::HTTP_BAD_REQUEST,
            self::SERVICE_CATEGORY_NOT_FOUND,
            'Service category, for sales channel {{ salesChannelName }}, is not set',
            ['salesChannelName' => $salesChannelName]
        );
    }

    
Home | Imprint | This part of the site doesn't use cookies.