Exemplo n.º 1
0
 /**
  * Returns array of product categories
  *
  * @param oxarticle $oArticle Article object
  *
  * @return array
  */
 protected function _getCategoryList($oArticle)
 {
     $sMainCatId = false;
     if ($oMainCat = $oArticle->getCategory()) {
         $sMainCatId = $oMainCat->getId();
     }
     $aCatList = array();
     $iLang = $this->getEditLang();
     // adding categories
     $sView = getViewName('oxobject2category');
     $oDb = oxDb::getDb(oxDB::FETCH_MODE_ASSOC);
     $sSqlForPriceCategories = $oArticle->getSqlForPriceCategories('oxid');
     $sQuotesArticleId = $oDb->quote($oArticle->getId());
     $sQ = "select oxobject2category.oxcatnid as oxid from {$sView} as oxobject2category " . "where oxobject2category.oxobjectid=" . $sQuotesArticleId . " union " . $sSqlForPriceCategories;
     $oRs = $oDb->execute($sQ);
     if ($oRs != false && $oRs->recordCount() > 0) {
         while (!$oRs->EOF) {
             $oCat = oxNew('oxCategory');
             if ($oCat->loadInLang($iLang, current($oRs->fields))) {
                 if ($sMainCatId == $oCat->getId()) {
                     $sSuffix = oxRegistry::getLang()->translateString('(main category)', $this->getEditLang());
                     $sTitleField = 'oxcategories__oxtitle';
                     $sTitle = $oCat->{$sTitleField}->getRawValue() . " " . $sSuffix;
                     $oCat->{$sTitleField} = new oxField($sTitle, oxField::T_RAW);
                 }
                 $aCatList[] = $oCat;
             }
             $oRs->moveNext();
         }
     }
     return $aCatList;
 }