getBlogCategoriesByParentQuery example


    public function getUrls(Context $routingContext, ShopContextInterface $shopContext)
    {
        if ($this->allExported) {
            return [];
        }

        $shopId = $shopContext->getShop()->getId();
        $parentId = $shopContext->getShop()->getCategory()->getId();

        $query = $this->modelManager->getRepository(Category::class)->getBlogCategoriesByParentQuery($parentId);
        $blogCategories = $query->getArrayResult();

        $blogIds = [];

        foreach ($blogCategories as $blogCategory) {
            $blogIds[] = (int) $blogCategory['id'];
        }

        if (\count($blogIds) === 0) {
            return [];
        }

        
/** * Create rewrite rules for blog articles * Used in multiple locations * * @param int|null $offset * @param int|null $limit */
    public function sCreateRewriteTableBlog($offset = null, $limit = null, ?ShopContextInterface $context = null)
    {
        $query = $this->modelManager->getRepository(Category::class)
            ->getBlogCategoriesByParentQuery(Shopware()->Shop()->get('parentID'));
        $blogCategories = $query->getArrayResult();

        // get all blog category ids         $blogCategoryIds = [];
        foreach ($blogCategories as $blogCategory) {
            $blogCategoryIds[] = $blogCategory['id'];
        }

        if ($context === null) {
            $context = $this->contextService->getShopContext();
        }

        

    private function readBlogUrls($parentId)
    {
        $blogs = [];

        $categoryRepository = $this->em->getRepository(\Shopware\Models\Category\Category::class);
        $query = $categoryRepository->getBlogCategoriesByParentQuery($parentId);
        $blogCategories = $query->getArrayResult();

        $blogIds = [];
        foreach ($blogCategories as $blogCategory) {
            $blogIds[] = $blogCategory['id'];
        }
        if (empty($blogIds)) {
            return $blogs;
        }

        $sql = ' SELECT id, category_id, DATE(display_date) as changed FROM s_blog WHERE active = 1 AND category_id IN(?) ';

    public function countBlogs($shopId)
    {
        $this->registerShop($shopId);

        // Get blog categories         $query = Shopware()->Models()->getRepository(Category::class)->getBlogCategoriesByParentQuery(Shopware()->Shop()->get('parentID'));
        $blogCategories = $query->getArrayResult();

        // Get list of blogCategory ids         $blogCategoryIds = [];
        foreach ($blogCategories as $blogCategory) {
            $blogCategoryIds[] = $blogCategory['id'];
        }

        // Count total number of associated blog articles         $builder = Shopware()->Models()->getRepository(Blog::class)->getListQueryBuilder(
            $blogCategoryIds,
            []
try {
            $limit = (int) $this->Request()->limit;
            $offset = (int) $this->Request()->start;
            $categoryId = ((int) $this->Request()->categoryId == 0) ? 1 : (int) $this->Request()->categoryId;

            // Order data             $order = (array) $this->Request()->getParam('sort', []);

            /** @var array $filter */
            $filter = $this->Request()->getParam('filter', []);

            $query = $this->getCategoryRepository()->getBlogCategoriesByParentQuery($categoryId);
            $blogCategories = $query->getArrayResult();

            $blogCategoryIds = $this->getBlogCategoryListIds($blogCategories);
            $blogCategoryIds[] = $categoryId;

            $repository = $this->getRepository();
            $dataQuery = $repository->getBackendListQuery($blogCategoryIds$filter$order$offset$limit);

            $totalCount = $this->getManager()->getQueryCount($dataQuery);
            $data = $dataQuery->getArrayResult();

            


        $perPage = $this->getPerPage($this->Request()$this->container->get('session'));

        $filter = $this->createFilter($filterDate$filterAuthor$filterTags);

        // Start for Limit         $limitStart = ($page - 1) * $perPage;
        $limitEnd = $perPage;

        // Get all blog articles         $query = $this->getCategoryRepository()->getBlogCategoriesByParentQuery($categoryId);
        $blogCategoryIds = array_column($query->getArrayResult(), 'id');
        $blogCategoryIds[] = $categoryId;
        $shopId = (int) $this->get('shop')->getId();
        $blogArticlesQuery = $this->getRepository()->getListQuery($blogCategoryIds$limitStart$limitEnd$filter$shopId);
        $blogArticlesQuery->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);

        $paginator = $this->get('models')->createPaginator($blogArticlesQuery);

        // Returns the total count of the query         $totalResult = $paginator->count();

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