Beispiel #1
0
 /**
  * Create rewrite rules for articles
  *
  * @param string $lastUpdate
  * @param int $limit
  * @return string
  */
 public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
 {
     $routerArticleTemplate = $this->config->get('sROUTERARTICLETEMPLATE');
     if (empty($routerArticleTemplate)) {
         return $lastUpdate;
     }
     $this->db->query('UPDATE `s_articles` SET `changetime`= NOW() WHERE `changetime`=?', array('0000-00-00 00:00:00'));
     $sql = $this->getSeoArticleQuery();
     $sql = $this->db->limit($sql, $limit);
     $result = $this->db->fetchAll($sql, array(Shopware()->Shop()->get('parentID'), Shopware()->Shop()->getId(), $lastUpdate));
     $result = $this->mapArticleTranslationObjectData($result);
     $result = Shopware()->Events()->filter('Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles', $result, array('shop' => Shopware()->Shop()->getId()));
     foreach ($result as $row) {
         $this->data->assign('sArticle', $row);
         $path = $this->template->fetch('string:' . $routerArticleTemplate, $this->data);
         $path = $this->sCleanupPath($path, false);
         $orgPath = 'sViewport=detail&sArticle=' . $row['id'];
         $this->sInsertUrl($orgPath, $path);
         $lastUpdate = $row['changed'];
         $lastId = $row['id'];
     }
     if (!empty($lastId)) {
         $this->db->query('UPDATE s_articles
             SET changetime = DATE_ADD(changetime, INTERVAL 1 SECOND)
             WHERE changetime=?
             AND id > ?', array($lastUpdate, $lastId));
     }
     return $lastUpdate;
 }
 /**
  * Create CMS rewrite rules
  * Used in multiple locations
  *
  * @param int $offset
  * @param int $limit
  */
 public function sCreateRewriteTableContent($offset = null, $limit = null)
 {
     $sql = "SELECT id, description as name FROM `s_emarketing_promotion_main`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $eMarketingPromotion = $this->db->fetchAll($sql);
     foreach ($eMarketingPromotion as $row) {
         $org_path = 'sViewport=campaign&sCampaign=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, name, ticket_typeID FROM `s_cms_support`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsSupport = $this->db->fetchAll($sql);
     foreach ($cmsSupport as $row) {
         $org_path = 'sViewport=ticket&sFid=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, description as name FROM `s_cms_static` WHERE link=''";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsStatic = $this->db->fetchAll($sql);
     foreach ($cmsStatic as $row) {
         $org_path = 'sViewport=custom&sCustom=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
     $sql = "SELECT id, description as name FROM `s_cms_groups`";
     if ($limit !== null) {
         $sql = $this->db->limit($sql, $limit, $offset);
     }
     $cmsGroups = $this->db->fetchAll($sql);
     foreach ($cmsGroups as $row) {
         $org_path = 'sViewport=content&sContent=' . $row['id'];
         $path = $this->sCleanupPath($row['name']);
         $this->sInsertUrl($org_path, $path);
     }
 }