getCachedTime example

class Shopware_Components_SeoIndex extends Enlight_Class
{
    /** * The old 'refreshIndex' method from the RouterRewrite Plugin * * This method ist used, if the SEO index needs to be build in *one* request - e.g. CronJob or Live * * @throws Zend_Db_Adapter_Exception */
    public function refreshSeoIndex()
    {
        list($cachedTime$elementId$shopId) = $this->getCachedTime();

        $cache = (int) Shopware()->Config()->get('routerCache');
        $cache = $cache < 360 ? 86400 : $cache;
        $currentTime = date('Y-m-d H:i:s');

        if (strtotime($cachedTime) < time() - $cache) {
            $this->setCachedTime($currentTime$elementId$shopId);

            $resultTime = Shopware()->Modules()->RewriteTable()->sCreateRewriteTable($cachedTime);
            if ($resultTime === $cachedTime) {
                $resultTime = $currentTime;
            }
$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 {
                $lastUpdateVal = $this->rewriteTable->sCreateRewriteTableArticles($lastUpdateVal$limit);
                $lastId = $this->rewriteTable->getRewriteArticleslastId();
            }
/** * Create SEO urls for articles */
    public function seoArticleAction()
    {
        @set_time_limit(1200);
        $shopId = (int) $this->Request()->getParam('shopId', 1);

        // Create shop         $shop = $this->SeoIndex()->registerShop($shopId);
        list($cachedTime$elementId$shopId) = $this->SeoIndex()->getCachedTime();
        $currentTime = new DateTime();

        $this->seoArticle(
            (int) $this->Request()->getParam('offset', 0),
            (int) $this->Request()->getParam('limit', 50),
            $shop
        );

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

        $this->View()->assign([
            
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 {
                $lastUpdateVal = $this->RewriteTable()->sCreateRewriteTableArticles($lastUpdateVal$limit);
                $lastId = $this->RewriteTable()->getRewriteArticleslastId();
            }
Home | Imprint | This part of the site doesn't use cookies.