예제 #1
0
 /**
  * Returns SEO uri for passed category
  *
  * @param oxcategory $oCat         category object
  * @param int        $iLang        language
  * @param bool       $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getCategoryUri($oCat, $iLang = null, $blRegenerate = false)
 {
     startProfile(__FUNCTION__);
     $sCatId = $oCat->getId();
     // skipping external category URLs
     if ($oCat->oxcategories__oxextlink->value) {
         $sSeoUrl = null;
     } else {
         // not found in cache, process it from the top
         if (!isset($iLang)) {
             $iLang = $oCat->getLanguage();
         }
         $aCacheMap = array();
         $aStdLinks = array();
         while ($oCat && !($sSeoUrl = $this->_categoryUrlLoader($oCat, $iLang))) {
             if ($iLang != $oCat->getLanguage()) {
                 $sId = $oCat->getId();
                 $oCat = oxNew('oxcategory');
                 $oCat->loadInLang($iLang, $sId);
             }
             // prepare oCat title part
             $sTitle = $this->_prepareTitle($oCat->oxcategories__oxtitle->value, false, $oCat->getLanguage());
             foreach (array_keys($aCacheMap) as $id) {
                 $aCacheMap[$id] = $sTitle . '/' . $aCacheMap[$id];
             }
             $aCacheMap[$oCat->getId()] = $sTitle;
             $aStdLinks[$oCat->getId()] = $oCat->getBaseStdLink($iLang);
             // load parent
             $oCat = $oCat->getParentCategory();
         }
         foreach ($aCacheMap as $sId => $sUri) {
             $this->_aCatCache[$sId . '_' . $iLang] = $this->_processSeoUrl($sSeoUrl . $sUri . '/', $sId, $iLang);
             $this->_saveToDb('oxcategory', $sId, $aStdLinks[$sId], $this->_aCatCache[$sId . '_' . $iLang], $iLang);
         }
         $sSeoUrl = $this->_aCatCache[$sCatId . '_' . $iLang];
     }
     stopProfile(__FUNCTION__);
     return $sSeoUrl;
 }
예제 #2
0
 /**
  * Setting product position in list, amount of articles etc
  *
  * @param oxcategory $oCategory    active category id
  * @param object     $oCurrArticle current article
  * @param string     $sOrderBy     order by fields
  *
  * @return object
  */
 protected function _loadIdsInList($oCategory, $oCurrArticle, $sOrderBy = null)
 {
     $oIdList = oxNew('oxArticleList');
     $oIdList->setCustomSorting($sOrderBy);
     // additionally check if this category is loaded and is price category ?
     if ($oCategory->isPriceCategory()) {
         $oIdList->loadPriceIds($oCategory->oxcategories__oxpricefrom->value, $oCategory->oxcategories__oxpriceto->value);
     } else {
         $sActCat = $oCategory->getId();
         $oIdList->loadCategoryIDs($sActCat, oxRegistry::getSession()->getVariable('session_attrfilter'));
         // if not found - reloading with empty filter
         if (!isset($oIdList[$oCurrArticle->getId()])) {
             $oIdList->loadCategoryIDs($sActCat, null);
         }
     }
     return $oIdList;
 }