示例#1
0
 /**
  * Builds basket product category path
  *
  * @param oxarticle $oArticle article to build category id
  *
  * @return string
  */
 protected function _getBasketProductCatPath($oArticle)
 {
     $sCatPath = '';
     if ($oCategory = $oArticle->getCategory()) {
         $sTable = $oCategory->getViewName();
         $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
         $sQ = "select {$sTable}.oxtitle as oxtitle from {$sTable}\n                       where {$sTable}.oxleft <= " . $oDb->quote($oCategory->oxcategories__oxleft->value) . " and\n                             {$sTable}.oxright >= " . $oDb->quote($oCategory->oxcategories__oxright->value) . " and\n                             {$sTable}.oxrootid = " . $oDb->quote($oCategory->oxcategories__oxrootid->value) . "\n                       order by {$sTable}.oxleft";
         $oRs = $oDb->execute($sQ);
         if ($oRs != false && $oRs->recordCount() > 0) {
             while (!$oRs->EOF) {
                 if ($sCatPath) {
                     $sCatPath .= '/';
                 }
                 $sCatPath .= strip_tags($oRs->fields['oxtitle']);
                 $oRs->moveNext();
             }
         }
     }
     $sCatPath = $this->_convertToUtf($sCatPath);
     return $sCatPath;
 }
示例#2
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;
 }