getCategoryRepository example

->setParameter('articleId', $articleId);

        $result = $builder->getQuery()->getArrayResult();
        if (empty($result)) {
            return [];
        }

        $categories = [];
        foreach ($result as $item) {
            $categories[] = [
                'id' => $item['id'],
                'name' => $this->getCategoryRepository()->getPathById($item['id'], 'name', '>'),
            ];
        }

        return $categories;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Used for the product backend module to load the product data into * the module. This function selects only some fragments for the whole product * data. The full product data stack is defined in the * Shopware_Controller_Backend_Article::getArticle function * * @param int $articleId * * @return array */
public function indexAction()
    {
        $categoryId = (int) $this->Request()->getQuery('sCategory');
        $page = (int) $this->request->getParam('sPage', 1);
        $page = $page >= 1 ? $page : 1;
        $filterDate = urldecode($this->Request()->getParam('sFilterDate', ''));
        $filterAuthor = urldecode($this->Request()->getParam('sFilterAuthor', ''));
        $filterTags = urldecode($this->Request()->getParam('sFilterTags', ''));

        // Redirect if blog's category is not a child of the current shop's category         $shopCategory = $this->get('shop')->getCategory();
        $category = $this->getCategoryRepository()->findOneBy(['id' => $categoryId, 'active' => true]);
        $isChild = ($shopCategory && $category instanceof Category) ? $category->isChildOf($shopCategory) : false;
        if (!$isChild) {
            throw new Enlight_Controller_Exception('Blog category missing, non-existent or invalid for the current shop', 404);
        }

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

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

        // Start for Limit         $limitStart = ($page - 1) * $perPage;
        
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();

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