Categories example

$templatePath = 'newsletter/index/' . $mailing['template'];

        if (!empty($mailing['plaintext'])) {
            $templatePath = 'newsletter/alt/' . $mailing['template'];
        }

        if (!$template->isCached($templatePath)) {
            $template->assign('sMailing', $mailing);
            $template->assign('sStart', ($shop->getSecure() ? 'https://' : 'http://') . $shop->getHost() . $shop->getBaseUrl());
            $template->assign('sUserGroup', Shopware()->System()->sUSERGROUP);
            $template->assign('sUserGroupData', Shopware()->System()->sUSERGROUPDATA);
            $template->assign('sMainCategories', Shopware()->Modules()->Categories()->sGetMainCategories());
        }

        return $template;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Returns mailing data using the mailing id. * * @param int $id * * @return array */

    public function sGetArticleCategoryPath($articleID$separator = ' > ', $categoryID = null, $field = 'name')
    {
        if (empty($categoryID)) {
            $categoryID = $this->sSettings['categoryID'];
        }

        $productCategoryId = $this->sSYSTEM->sMODULES['sCategories']->sGetCategoryIdByArticleId($articleID$categoryID);
        $breadcrumb = array_reverse(Shopware()->Modules()->Categories()->sGetCategoriesByParent($productCategoryId));
        $breadcrumbs = [];

        foreach ($breadcrumb as $breadcrumbObj) {
            $breadcrumbs[] = $field === 'link' ? Shopware()->Modules()->Core()->sRewriteLink($breadcrumbObj[$field]) : $breadcrumbObj[$field];
        }

        return htmlspecialchars_decode(implode($separator$breadcrumbs));
    }

    /** * @param int|string $country * * @return array|false */
return;
        }

        /** @var ShopContextInterface $context */
        $context = Shopware()->Container()->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->getShopContext();
        $categoryId = $context->getShop()->getCategory()->getId();

        /** @var StoreFrontEmotionDeviceConfiguration $service */
        $service = $this->get(\Shopware\Bundle\EmotionBundle\Service\StoreFrontEmotionDeviceConfigurationInterface::class);
        $emotions = $service->getCategoryConfiguration($categoryId$context);

        $categoryContent = Shopware()->Modules()->Categories()->sGetCategoryContent($categoryId);

        $this->View()->assign([
            'hasCustomerStreamEmotion' => $this->container->get(\Shopware\Models\CustomerStream\CustomerStreamRepositoryInterface::class)->hasCustomerStreamEmotions($categoryId),
            'emotions' => $emotions,
            'hasEmotion' => !empty($emotions),
            'sCategoryContent' => $categoryContent,
            'sBanner' => Shopware()->Modules()->Marketing()->sBanner($categoryId),
        ]);
    }

    /** * Handle theme preview hash * * @return bool */
$this->SeoIndex()->registerShop($shops[0]);
        $this->RewriteTable()->sCreateRewriteTableCleanup();

        foreach ($shops as $shopId) {
            $repository = Shopware()->Models()->getRepository(Shop::class);
            $shop = $repository->getActiveById($shopId);
            if ($shop === null) {
                throw new Exception('No valid shop id passed');
            }

            $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);
            Shopware()->Modules()->Categories()->baseId = $shop->getCategory()->getId();

            [$elementId$shopId] = $this->SeoIndex()->getCachedTime();
            $this->SeoIndex()->setCachedTime($currentTime->format('Y-m-d H:i:s')$elementId$shopId);

            $this->RewriteTable()->baseSetup();

            $limit = 10000;
            $lastId = null;
            $lastUpdateVal = '0000-00-00 00:00:00';

            do {
                
$output->writeln('Rebuilding SEO index for shop ' . $shopId);

            $repository = $this->modelManager->getRepository(Shop::class);
            $shop = $repository->getActiveById($shopId);

            if ($shop === null) {
                throw new ModelNotFoundException(Shop::class$shopId);
            }

            $this->container->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

            $this->modules->Categories()->baseId = $shop->getCategory()->getId();

            [$elementId$shopId] = $this->seoIndex->getCachedTime();

            $this->seoIndex->setCachedTime($currentTime->format('Y-m-d H:i:s')$elementId$shopId);
            $this->rewriteTable->baseSetup();

            $limit = 10000;
            $lastId = null;
            $lastUpdateVal = '0000-00-00 00:00:00';

            do {
                

    private function sCategoryPathByProductId($productId$parentId = null)
    {
        $categoryId = $this->moduleManager->Categories()->sGetCategoryIdByArticleId(
            $productId,
            $parentId
        );

        return empty($categoryId) ? null : $this->sCategoryPath($categoryId);
    }

    /** * Generates and inserts the form seo urls * * @param int $offset * @param int $limit * * @throws Exception */


    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,
            


    /** * @return void */
    public function layoutAction(Request $request)
    {
        $this->View()->loadTemplate('frontend/listing/customer_stream/layout.tpl');

        $categoryId = (int) $request->getParam('sCategory');

        $categoryContent = Shopware()->Modules()->Categories()->sGetCategoryContent($categoryId);

        $config = $this->getEmotionConfiguration($categoryId, true, $categoryContent['streamId'] ?? null);

        $config = array_merge($config[
            'sBanner' => Shopware()->Modules()->Marketing()->sBanner($categoryId),
            'sCategoryContent' => $categoryContent,
            'Controller' => 'listing',
            'params' => $this->Request()->getParams(),
        ]);

        $this->View()->assign($config);
    }
$categoryTree = array_merge($categoryTree$additionalTrees);
        $this->View()->assign('sCategoryTree', $categoryTree);
    }

    private function getCategoryTree(): array
    {
        $shop = $this->container->get('shop');
        if (!$shop instanceof Shop) {
            throw new RuntimeException('Shop is not initialized correctly in DI container');
        }
        $categoryTree = $this->container->get('modules')->Categories()->sGetWholeCategoryTree(null, null, $shop->getId());

        $categoryTranslations = $this->fetchTranslations('category', $this->getTranslationKeys(
            $categoryTree,
            'id',
            'sub'
        ));

        return $this->translateCategoryTree($categoryTree$categoryTranslations);
    }

    private function translateCategoryTree(array $categoryTree, array $translations): array
    {


    /** * Return current categories * * @param int $parentId * * @return array */
    public function getCategories($parentId)
    {
        return Shopware()->Modules()->Categories()->sGetCategories($parentId);
    }

    /** * Return cms menu items * * @param int|null $shopId * @param int|null $activePageId * * @return array */
    public function getMenu($shopId = null, $activePageId = null)
    {

            if ($providedNumber && $providedNumber == $productNumber && empty($selection) || $type === 0) {
                $selection = $product->getSelectedOptions();
            }
        }

        $categoryId = (int) $sCategoryID;
        if (empty($categoryId) || $categoryId == Shopware()->Shop()->getId()) {
            $categoryId = Shopware()->Modules()->Categories()->sGetCategoryIdByArticleId($id);
        }

        return $this->getLegacyProduct(
            $product,
            $categoryId,
            $selection
        );
    }

    /** * calculates the reference price with the base price data * * @param string|float $price | the final price which will be shown * @param string|float $purchaseUnit * @param string|float $referenceUnit * * @return float */
if (!empty($this->container->get(Config::class)->get('InquiryID'))) {
            $view->assign('sInquiry', $this->Front()->ensureRouter()->assemble([
                'sViewport' => 'support',
                'sFid' => $this->container->get(Config::class)->get('InquiryID'),
                'sInquiry' => 'detail',
                'sOrdernumber' => $product['ordernumber'],
            ]));
        }

        if (!empty($product['categoryID'])) {
            $breadcrumb = array_reverse($this->container->get('modules')->Categories()->sGetCategoriesByParent($product['categoryID']));
            $categoryInfo = end($breadcrumb);
        } else {
            $breadcrumb = [];
            $categoryInfo = null;
        }

        $view->assign('sBreadcrumb', $breadcrumb);
        $view->assign('sCategoryInfo', $categoryInfo);
        $view->assign('sArticle', $product);
        $view->assign('rand', Random::getAlphanumericString(32));
    }

    
$blogArticles[$key]['media'] = $media;
        }

        // RSS and ATOM Feed part         if ($this->Request()->getParam('sRss') || $this->Request()->getParam('sAtom')) {
            $this->Response()->headers->set('content-type', 'text/xml');
            $type = $this->Request()->getParam('sRss') ? 'rss' : 'atom';
            $this->View()->loadTemplate('frontend/blog/' . $type . '.tpl');
        }

        $categoryContent = $this->get('modules')->Categories()->sGetCategoryContent($categoryId);

        // Make sure the category exists and is a blog category         if (empty($categoryContent) || !$categoryContent['blog']) {
            throw new Enlight_Controller_Exception(sprintf('Blog category by id "%d" is invalid', $categoryId), 404);
        }

        if (!empty($categoryContent['external'])) {
            $this->redirect($categoryContent['external']['code' => 301]);

            return;
        }

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