/**
  * Returns array containing default list type and category (or manufacturer ir vendor) id
  *
  * @param oxarticle $oProduct current product object
  *
  * @return array
  */
 protected function _getDefaultParams($oProduct)
 {
     $sListType = null;
     $aArticleCats = $oProduct->getCategoryIds(true);
     if (is_array($aArticleCats) && count($aArticleCats)) {
         $sActCat = reset($aArticleCats);
     } elseif ($sActCat = $oProduct->getManufacturerId()) {
         // not assigned to any category ? maybe it is assigned to Manufacturer ?
         $sListType = 'manufacturer';
     } elseif ($sActCat = $oProduct->getVendorId()) {
         // not assigned to any category ? maybe it is assigned to vendor ?
         $sListType = 'vendor';
     } else {
         $sActCat = null;
     }
     return array($sListType, $sActCat);
 }
예제 #2
0
 /**
  * finds deepest category path
  *
  * @param oxarticle $oArticle article object
  *
  * @return string
  */
 protected function _findDeepestCatPath($oArticle)
 {
     $sRet = "";
     // find deepest
     $aIds = $oArticle->getCategoryIds();
     if (is_array($aIds) && count($aIds)) {
         if ($aCatLvlCache = $this->_loadRootCats()) {
             $sIdMax = null;
             $dMaxLvl = 0;
             foreach ($aIds as $sCatId) {
                 if ($dMaxLvl < $aCatLvlCache[$sCatId]->ilevel) {
                     $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
                     $sIdMax = $sCatId;
                     $sRet = $aCatLvlCache[$sCatId]->oxtitle;
                 }
             }
             // endless
             while (true) {
                 if (!isset($aCatLvlCache[$sIdMax]->oxparentid) || $aCatLvlCache[$sIdMax]->oxparentid == "oxrootid") {
                     break;
                 }
                 $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
                 $sRet = $aCatLvlCache[$sIdMax]->oxtitle . "/" . $sRet;
             }
         }
     }
     return $sRet;
 }