source/Application/Model/AttributeList.php
public function getCategoryAttributes($sCategoryId, $iLang)
    {
        $aSessionFilter = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('session_attrfilter');

        $oArtList = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);
        $oArtList->loadCategoryIDs($sCategoryId, $aSessionFilter);

        // Only if we have articles
        if (count($oArtList) > 0) {
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $sArtIds = '';
            foreach (array_keys($oArtList->getArray()) as $sId) {
                if ($sArtIds) {
                    $sArtIds .= ',';
                }
                $sArtIds .= $oDb->quote($sId);
            }

            $sActCatQuoted = $oDb->quote($sCategoryId);
            $sAttTbl = getViewName('oxattribute', $iLang);
            $sO2ATbl = getViewName('oxobject2attribute', $iLang);
            $sC2ATbl = getViewName('oxcategory2attribute', $iLang);

            $sSelect = "SELECT DISTINCT att.oxid, att.oxtitle, o2a.oxvalue " .
                       "FROM $sAttTbl as att, $sO2ATbl as o2a ,$sC2ATbl as c2a " .
                       "WHERE att.oxid = o2a.oxattrid AND c2a.oxobjectid = $sActCatQuoted AND c2a.oxattrid = att.oxid AND o2a.oxvalue !='' AND o2a.oxobjectid IN ($sArtIds) " .
                       "ORDER BY c2a.oxsort , att.oxpos, att.oxtitle, o2a.oxvalue";

            $rs = $oDb->select($sSelect);

            if ($rs != false && $rs->count() > 0) {
                while (!$rs->EOF && list($sAttId, $sAttTitle, $sAttValue) = $rs->fields) {
                    if (!$this->offsetExists($sAttId)) {
                        $oAttribute = oxNew(\OxidEsales\Eshop\Application\Model\Attribute::class);
                        $oAttribute->setTitle($sAttTitle);

                        $this->offsetSet($sAttId, $oAttribute);
                        $iLang = \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
                        if (isset($aSessionFilter[$sCategoryId][$iLang][$sAttId])) {
                            $oAttribute->setActiveValue($aSessionFilter[$sCategoryId][$iLang][$sAttId]);
                        }
                    } else {
                        $oAttribute = $this->offsetGet($sAttId);
                    }

                    $oAttribute->addValue($sAttValue);
                    $rs->fetchRow();
                }
            }
        }

        return $this;
    }
public function getCategoryAttributes($sCategoryId, $iLang)
    {
        $aSessionFilter = \OxidEsales\Eshop\Core\Registry::getSession()->getVariable('session_attrfilter');

        $oArtList = oxNew(\OxidEsales\Eshop\Application\Model\ArticleList::class);
        $oArtList->loadCategoryIDs($sCategoryId, $aSessionFilter);

        // Only if we have articles
        if (count($oArtList) > 0) {
            $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
            $sArtIds = '';
            foreach (array_keys($oArtList->getArray()) as $sId) {
                if ($sArtIds) {
                    $sArtIds .= ',';
                }
                $sArtIds .= $oDb->quote($sId);
            }

            $sActCatQuoted = $oDb->quote($sCategoryId);
            $sAttTbl = getViewName('oxattribute', $iLang);
            $sO2ATbl = getViewName('oxobject2attribute', $iLang);
            $sC2ATbl = getViewName('oxcategory2attribute', $iLang);

            $sSelect = "SELECT DISTINCT att.oxid, att.oxtitle, o2a.oxvalue " .
                       "FROM $sAttTbl as att, $sO2ATbl as o2a ,$sC2ATbl as c2a " .
                       "WHERE att.oxid = o2a.oxattrid AND c2a.oxobjectid = $sActCatQuoted AND c2a.oxattrid = att.oxid AND o2a.oxvalue !='' AND o2a.oxobjectid IN ($sArtIds) " .
                       "ORDER BY c2a.oxsort , att.oxpos, att.oxtitle, o2a.oxvalue";

            $rs = $oDb->select($sSelect);

            if ($rs != false && $rs->count() > 0) {
                while (!$rs->EOF && list($sAttId, $sAttTitle, $sAttValue) = $rs->fields) {
                    if (!$this->offsetExists($sAttId)) {
                        $oAttribute = oxNew(\OxidEsales\Eshop\Application\Model\Attribute::class);
                        $oAttribute->setTitle($sAttTitle);

                        $this->offsetSet($sAttId, $oAttribute);
                        $iLang = \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
                        if (isset($aSessionFilter[$sCategoryId][$iLang][$sAttId])) {
                            $oAttribute->setActiveValue($aSessionFilter[$sCategoryId][$iLang][$sAttId]);
                        }
                    } else {
                        $oAttribute = $this->offsetGet($sAttId);
                    }

                    $oAttribute->addValue($sAttValue);
                    $rs->fetchRow();
                }
            }
        }

        return $this;
    }
public function getCategoryAttributes ( $ sCategoryId , $ iLang ) { $ aSessionFilter = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( 'session_attrfilter' ) ; $ oArtList = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ ArticleList :: class ) ; $ oArtList -> loadCategoryIDs ( $ sCategoryId , $ aSessionFilter ) ; // Only if we have articles if ( count ( $ oArtList ) > 0 ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sArtIds = '' ; foreach ( array_keys ( $ oArtList -> getArray ( ) ) as $ sId ) { if ( $ sArtIds ) { $ sArtIds .= ',' ; } $ sArtIds .= $ oDb -> quote ( $ sId ) ; } $ sActCatQuoted = $ oDb -> quote ( $ sCategoryId ) ; $ sAttTbl = getViewName ( 'oxattribute' , $ iLang ) ; $ sO2ATbl = getViewName ( 'oxobject2attribute' , $ iLang ) ; $ sC2ATbl = getViewName ( 'oxcategory2attribute' , $ iLang ) ; $ sSelect = "SELECT DISTINCT att.oxid, att.oxtitle, o2a.oxvalue " . "FROM $sAttTbl as att, $sO2ATbl as o2a ,$sC2ATbl as c2a " . "WHERE att.oxid = o2a.oxattrid AND c2a.oxobjectid = $sActCatQuoted AND c2a.oxattrid = att.oxid AND o2a.oxvalue !='' AND o2a.oxobjectid IN ($sArtIds) " . "ORDER BY c2a.oxsort , att.oxpos, att.oxtitle, o2a.oxvalue" ; $ rs = $ oDb -> select ( $ sSelect ) ; if ( $ rs != false && $ rs -> count ( ) > 0 ) { while ( ! $ rs -> EOF && list ( $ sAttId , $ sAttTitle , $ sAttValue ) = $ rs -> fields ) { if ( ! $ this -> offsetExists ( $ sAttId ) ) { $ oAttribute = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Attribute :: class ) ; $ oAttribute -> setTitle ( $ sAttTitle ) ; $ this -> offsetSet ( $ sAttId , $ oAttribute ) ; $ iLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> getBaseLanguage ( ) ; if ( isset ( $ aSessionFilter [ $ sCategoryId ] [ $ iLang ] [ $ sAttId ] ) ) { $ oAttribute -> setActiveValue ( $ aSessionFilter [ $ sCategoryId ] [ $ iLang ] [ $ sAttId ] ) ; } } else { $ oAttribute = $ this -> offsetGet ( $ sAttId ) ; } $ oAttribute -> addValue ( $ sAttValue ) ; $ rs -> fetchRow ( ) ; } } } return $ this ; }
get category attributes by category Id

@param string  $sCategoryId category Id
@param integer $iLang       language No

@return object;
get category attributes by category Id