getProductBoxLayout example



    private function prepareListing(ProductSearchResult $result): void
    {
        $categoryId = (int) $this->Request()->getParam('sCategory');

        if ($this->Request()->has('productBoxLayout')) {
            $boxLayout = $this->Request()->get('productBoxLayout');
        } else {
            $boxLayout = $this->container->get(Shopware_Components_Config::class)->get('searchProductBoxLayout');
            if ($categoryId) {
                $boxLayout = $this->container->get('modules')->Categories()->getProductBoxLayout($categoryId);
            }
        }

        $products = $this->convertProductsResult($result$categoryId);

        $this->loadThemeConfig();

        $this->View()->assign([
            'sArticles' => $products,
            'pageIndex' => (int) $this->Request()->getParam('sPage'),
            'productBoxLayout' => $boxLayout,
            

    public function getProductBoxLayout($categoryId)
    {
        $category = $this->repository->find($categoryId);

        if (!$category instanceof CategoryModel) {
            return 'basic';
        }

        if ($category->getProductBoxLayout() !== 'extend' && $category->getProductBoxLayout() !== null) {
            return $category->getProductBoxLayout();
        }

        while (null !== $parent = $category->getParent()) {
            $category = $parent;

            if ($category->getProductBoxLayout() !== 'extend' && $category->getProductBoxLayout() !== null) {
                return $category->getProductBoxLayout();
            }
        }

        
'id' => $category->getId(),
            'parentId' => $category->getParentId(),
            'name' => $category->getName(),
            'position' => $category->getPosition(),
            'metaTitle' => $category->getMetaTitle(),
            'metaKeywords' => $category->getMetaKeywords(),
            'metaDescription' => $category->getMetaDescription(),
            'cmsHeadline' => $category->getCmsHeadline(),
            'cmsText' => $category->getCmsText(),
            'active' => true,
            'template' => $category->getTemplate(),
            'productBoxLayout' => $this->getProductBoxLayout($category),
            'blog' => $category->isBlog(),
            'path' => $categoryPath,
            'external' => $category->getExternalLink(),
            'externalTarget' => $category->getExternalTarget(),
            'hideFilter' => !$category->displayFacets(),
            'hideTop' => !$category->displayInNavigation(),
            'changed' => null,
            'added' => null,
            'attribute' => $attribute,
            'attributes' => $category->getAttributes(),
            'media' => $media,
            
Home | Imprint | This part of the site doesn't use cookies.