warmUpUrls example

$resource = $this->Request()->get('resource');
        $provider = $urlProviderFactory->getProvider($resource);

        $urls = $provider->getUrls($context$limit$offset);

        $view = $this->View();

        $this->get('events')->addListener('Shopware_Components_CacheWarmer_ErrorOccured', function D) use ($view) {
            $view->assign('requestFailed', true);
        });

        $cacheWarmer->warmUpUrls($urls$context$concurrentRequests);

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

    /** * Regenerate sitemap cache */
    public function buildSitemapCacheAction()
    {
// Progressbar             $progressBar = $io->createProgressBar($totalResultCount);
            $io->writeln(sprintf("\nShop '%s' (ID: %s)", $shop->getName()$shop->getId()));
            $progressBar->setBarWidth(100);
            $progressBar->setFormat('very_verbose');
            $progressBar->start();

            // Warm URL-List             while ($offset < $totalResultCount) {
                $sliceUrls = \array_slice($urls$offset$limit, true);
                $cacheWarmer->warmUpUrls($sliceUrls$context$concurrentRequests);

                $sliceCount = \count($sliceUrls);
                if ($sliceCount === 0) {
                    break;
                }
                $progressBar->advance($sliceCount);
                $offset += $sliceCount;
            }
            $progressBar->finish();
            $io->newLine();
        }
        
Home | Imprint | This part of the site doesn't use cookies.