createShopContext example


    private function getAdditionalTexts(array $products): array
    {
        $shopRepo = $this->get(ModelManager::class)->getRepository(Shop::class);

        $shop = $shopRepo->getActiveDefault();

        $contextService = $this->get(ContextServiceInterface::class);

        $context = $contextService->createShopContext(
            $shop->getId(),
            $shop->getCurrency()->getId(),
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $service = $this->get(AdditionalTextServiceInterface::class);

        return $service->buildAdditionalTextLists($products$context);
    }

    /** * @return ListProduct[] */
$this->connection = $connection;
        $this->contextService = $contextService;
        $this->fieldHelper = $fieldHelper;
        $this->hydrator = $hydrator;
    }

    /** * {@inheritdoc} */
    public function get(Shop $shop$groupIds)
    {
        $context = $this->contextService->createShopContext(
            $shop->getId(),
            null,
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $result = [];
        $query = $this->getQuery($context);

        foreach ($groupIds as $groupId) {
            $query->setParameter(':id', $groupId);
            $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
            

    private function getPositionAssociatedData(array $data, Order $order): array
    {
        // Checks if the status id for the position is passed and search for the assigned status model         if ($data['statusId'] >= 0) {
            $data['status'] = $this->getManager()->find(DetailStatus::class$data['statusId']);
        } else {
            unset($data['status']);
        }

        $shopContext = $this->createShopContext($order);
        $data = $this->checkTaxRule($data$shopContext);
        $orderPosition = null;
        foreach ($order->getDetails() as $position) {
            if ($position->getId() === (int) $data['id']) {
                $orderPosition = $position;
                break;
            }
        }
        // Only get graduated price if a new position should be added or quantity has changed         if (($orderPosition === null || $orderPosition->getQuantity() !== (int) $data['quantity'])
            && $this->hasProductGraduatedPrices($data['articleNumber']$order)
        )
/** * @param array $shopPositions * * @return array */
    public function getPositionImages($shopPositions)
    {
        $shopPositionImages = [];

        foreach ($shopPositions as $shopId => $positions) {
            $context = $this->get(ContextServiceInterface::class)->createShopContext($shopId);

            $shopPositionImages[$shopId] = $this->get(MediaServiceInterface::class)->getCovers(
                $positions,
                $context
            );

            $shopPositionImages[$shopId] = array_map(
                function D$mediaStruct) {
                    return $this->get(LegacyStructConverter::class)->convertMediaStruct($mediaStruct);
                },
                $shopPositionImages[$shopId]
            );
return array_values($result);
    }

    /** * @param int $shopId * * @return \Doctrine\DBAL\Query\QueryBuilder */
    private function getQuery($shopId)
    {
        $query = $this->connection->createQueryBuilder();
        $context = $this->shopContextService->createShopContext($shopId);

        $query->select([
            'page.id',
            'page.description',
            'page.link',
            'page.target',
            'page.parentID',
            'groups.key as `group`',
            'mapping.key as mapping',
        ]);

        
$this->listingVariationLoader = $visibilityLoader;
        $this->crudService = $crudService;
        $this->manualPositionLoader = $manualPositionLoader;
        $this->config = $config;
    }

    /** * {@inheritdoc} */
    public function get(Shop $shop$numbers)
    {
        $context = $this->contextService->createShopContext(
            $shop->getId(),
            null,
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $availability = null;
        $listingPrices = null;
        $combinations = null;
        $configurations = null;
        $variantConfiguration = null;
        $products = $this->productGateway->getList($numbers$context);
        

    public function sCreateRewriteTable($lastUpdate)
    {
        $this->baseSetup();

        $context = $this->contextService->createShopContext(Shopware()->Shop()->getId());

        $this->sCreateRewriteTableCleanup();
        $this->sCreateRewriteTableStatic();
        $this->sCreateRewriteTableCategories();
        $this->sCreateRewriteTableBlog(null, null, $context);
        $this->sCreateRewriteTableCampaigns();
        $lastUpdate = $this->sCreateRewriteTableArticles($lastUpdate);
        $this->sCreateRewriteTableContent(null, null, $context);
        $this->createManufacturerUrls($context);
        $this->createContentTypeUrls($context);

        

    private function getAdditionalTexts(array $products): array
    {
        $service = $this->get(AdditionalTextServiceInterface::class);

        $shopRepo = $this->get(ModelManager::class)->getRepository(Shop::class);

        $shop = $shopRepo->getActiveDefault();

        $contextService = $this->get(ContextServiceInterface::class);

        $context = $contextService->createShopContext(
            $shop->getId(),
            $shop->getCurrency()->getId(),
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        return $service->buildAdditionalTextLists($products$context);
    }

    /** * @return array{data: array, total: int} */
    
$limit = 10000;
            $lastId = null;
            $lastUpdateVal = '0000-00-00 00:00:00';

            do {
                $lastUpdateVal = $this->RewriteTable()->sCreateRewriteTableArticles($lastUpdateVal$limit);
                $lastId = $this->RewriteTable()->getRewriteArticleslastId();
            } while ($lastId !== null);

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

            $context = $this->get(ContextServiceInterface::class)->createShopContext($shopId);

            $this->RewriteTable()->sCreateRewriteTableCategories();
            $this->RewriteTable()->sCreateRewriteTableCampaigns();
            $this->RewriteTable()->sCreateRewriteTableContent();
            $this->RewriteTable()->sCreateRewriteTableBlog(null, null, $context);
            $this->RewriteTable()->createManufacturerUrls($context);
            $this->RewriteTable()->sCreateRewriteTableStatic();
            $this->RewriteTable()->createContentTypeUrls($context);

            Shopware()->Events()->notify(
                'Shopware_CronJob_RefreshSeoIndex_CreateRewriteTable',
                [
/** * {@inheritdoc} */
    public function generate(Shop $shop)
    {
        if (!$this->sitemapLock->doLock($shop$this->shopwareConfig->get('sitemapRefreshTime'))) {
            throw new AlreadyLockedException(sprintf('Cannot acquire lock for shop %d', $shop->getId()));
        }

        $routerContext = Context::createFromShop($shop$this->shopwareConfig);
        $shopContext = $this->contextService->createShopContext($shop->getId()$shop->getCurrency()->getId()$shop->getCustomerGroup()->getKey());

        foreach ($this->urlProvider as $urlProvider) {
            $urlProvider->reset();
            while ($urls = $urlProvider->getUrls($routerContext$shopContext)) {
                $urls = $this->urlFilter->filter($urls(int) $shop->getId());

                if (!$urls) {
                    continue;
                }

                $this->sitemapWriter->writeFile($shop$urls);
            }
$shop = $modelManager->getRepository(Shop::class)->getActiveById($notify['language']);

            // Continue if shop is inactive or deleted             if ($shop === null) {
                continue;
            }

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

            $shopContext = Context::createFromShop($shop$this->get(Shopware_Components_Config::class));
            $this->get(RouterInterface::class)->setContext($shopContext);
            $sContext = $this->get(ContextServiceInterface::class)->createShopContext($notify['language']);

            $productInformation = $this->get(ListProductServiceInterface::class)->get($notify['ordernumber']$sContext);

            if (empty($productInformation)) {
                continue;
            }

            $productInformation = $this->get('legacy_struct_converter')->convertListProductStruct($productInformation);

            $link = Shopware()->Front()->ensureRouter()->assemble([
                'sViewport' => 'detail',
                
/** * @param int $shopId * @param string[] $customerGroups * @param int[] $currencies */
    private function getContexts($shopId$customerGroups$currencies): array
    {
        $contexts = [];
        foreach ($customerGroups as $customerGroup) {
            foreach ($currencies as $currency) {
                $contexts[] = $this->contextService->createShopContext($shopId$currency$customerGroup);
            }
        }

        return $contexts;
    }

    private function getFilteredGroups(array $configuration, VariantFacet $variantFacet): array
    {
        return array_filter(array_map(static function DGroup $group) use ($variantFacet) {
            if (!\in_array($group->getId()$variantFacet->getGroupIds(), true)) {
                return null;
            }

        @set_time_limit(1200);

        $offset = $this->Request()->getParam('offset', 0);
        $limit = $this->Request()->getParam('limit', 50);
        $shopId = (int) $this->Request()->getParam('shopId', 1);

        // Create shop         $shop = $this->SeoIndex()->registerShop($shopId);

        $this->RewriteTable()->baseSetup();
        $context = $this->get(\Shopware\Bundle\StoreFrontBundle\Service\ContextServiceInterface::class)->createShopContext($shopId);
        $this->RewriteTable()->sCreateRewriteTableBlog($offset$limit$context);

        $this->View()->assign([
            'success' => true,
        ]);
    }

    /** * Create SEO urls for articles */
    public function seoArticleAction()
    {


    /** * @param array<array<string, mixed>> $products * * @return array<array<string, mixed>> */
    private function assignAdditionalText(array $products): array
    {
        $shop = $this->entityManager->getRepository(Shop::class)->getActiveDefault();

        $context = $this->contextService->createShopContext(
            $shop->getId(),
            $shop->getCurrency()->getId(),
            ContextService::FALLBACK_CUSTOMER_GROUP
        );

        $tempProducts = $this->buildListProducts($products);
        $tempProducts = $this->additionalTextService->buildAdditionalTextLists($tempProducts$context);

        foreach ($tempProducts as $tempProduct) {
            $number = $tempProduct->getNumber();
            if (!isset($products[$number])) {
                
$limit = 10000;
            $lastId = null;
            $lastUpdateVal = '0000-00-00 00:00:00';

            do {
                $lastUpdateVal = $this->rewriteTable->sCreateRewriteTableArticles($lastUpdateVal$limit);
                $lastId = $this->rewriteTable->getRewriteArticleslastId();
            } while ($lastId !== null);

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

            $context = $this->container->get(ContextServiceInterface::class)->createShopContext($shopId);

            $this->rewriteTable->sCreateRewriteTableCategories();
            $this->rewriteTable->sCreateRewriteTableCampaigns();
            $this->rewriteTable->sCreateRewriteTableContent();
            $this->rewriteTable->sCreateRewriteTableBlog(null, null, $context);
            $this->rewriteTable->createManufacturerUrls($context);
            $this->rewriteTable->sCreateRewriteTableStatic();
            $this->rewriteTable->createContentTypeUrls($context);

            $this->events->notify(
                'Shopware_Command_RebuildSeoIndexCommand_CreateRewriteTable',
                [
Home | Imprint | This part of the site doesn't use cookies.