View Issue Details

IDProjectCategoryView StatusLast Update
0004555OXID eShop (all versions)1.01. Products (product, categories, manufacturer, promotions etc.)public2012-12-07 14:10
Reporteravenger Assigned To 
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
Summary0004555: Wrong interpretation of "$aSessionFilter" in filter SQL buiding
DescriptionIn "alist"

    public function executefilter()
    {
        $iLang = oxLang::getInstance()->getBaseLanguage();
        // store this into session
        $aFilter = oxConfig::getParameter( 'attrfilter', 1 );
        $sActCat = oxConfig::getParameter( 'cnid' );

        if ( !empty( $aFilter ) ) {
            $aSessionFilter = oxSession::getVar( 'session_attrfilter' );
            //fix for 0002904 - if language will be changed attributes of this category will be deleted from session
            //and new filters for active language set.
            $aSessionFilter[$sActCat] = null;
            $aSessionFilter[$sActCat][$iLang] = $aFilter;
            oxSession::setVar( 'session_attrfilter', $aSessionFilter );
        }
    }

"$aSessionFilter" receives a new dimension "$iLang"....

So it's structure is

$aSessionFilter: array ( catid => array($iLang => array( attrid => value,...)))

In "alist"

    protected function _loadArticles( $oCategory )
    {
..........
            $aSessionFilter = oxSession::getVar( 'session_attrfilter' );

            $sActCat = oxConfig::getParameter( 'cnid' );
            $this->_iAllArtCnt = $oArtList->loadCategoryArticles( $sActCat, $aSessionFilter );
..........
    }

"$aSessionFilter" is the retrieved with this new structure

But all(!) subsequent uses of it still assume the old structure!!!

E.g.:

   * @param array $aSessionFilter Like array ( catid => array( attrid => value,...))
   *
   * @return string SQL
   */
  protected function _getCategorySelect( $sFields, &$sCatId, $aSessionFilter )
  {

So the SQL-criteria built for filter selections are dead wrong!
Additional InformationSolution:

Change "protected function _loadArticles( $oCategory )" in "alist.php" to eliminate the language dimension:

    protected function _loadArticles( $oCategory )
    {
        $myConfig = $this->getConfig();

        $iNrofCatArticles = (int) $myConfig->getConfigParam( 'iNrofCatArticles' );
        $iNrofCatArticles = $iNrofCatArticles?$iNrofCatArticles:1;

        // load only articles which we show on screen
        $oArtList = oxNew( 'oxarticlelist' );
        $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
        $oArtList->setCustomSorting( $this->getSortingSql( $oCategory->getId() ) );

        if ( $oCategory->isPriceCategory() ) {
            $dPriceFrom = $oCategory->oxcategories__oxpricefrom->value;
            $dPriceTo = $oCategory->oxcategories__oxpriceto->value;

            $this->_iAllArtCnt = $oArtList->loadPriceArticles( $dPriceFrom, $dPriceTo, $oCategory );
        } else {
            $aSessionFilter = oxSession::getVar( 'session_attrfilter' );
            //Avenger
            //Eliminate language dimension from filters
            $iLang = oxLang::getInstance()->getBaseLanguage();
            $sCategoryId=$oCategory->getId();
            $aSessionFilter[$sCategoryId]=$aSessionFilter[$sCategoryId][$iLang];
            //Avenger
            $sActCat = oxConfig::getParameter( 'cnid' );
            $this->_iAllArtCnt = $oArtList->loadCategoryArticles( $sActCat, $aSessionFilter );
        }

        $this->_iCntPages = round( $this->_iAllArtCnt/$iNrofCatArticles + 0.49 );

        return $oArtList;
    }

TagsAttributes
ThemeBoth
BrowserAll
PHP Versionany
Database Versionany

Activities

leofonic

2012-09-25 11:38

reporter   ~0007488

@avenger: Language dimension is already stripped along with category dimension in oxarticlelist::_getCategorySelect:


        // ----------------------------------
        // filtering ?
        $sFilterSql = '';
        $iLang = oxLang::getInstance()->getBaseLanguage();
        if ( $aSessionFilter && isset( $aSessionFilter[$sCatId][$iLang] ) ) {
            $sFilterSql = $this->_getFilterSql($sCatId, $aSessionFilter[$sCatId][$iLang]);
        }

Linas Kukulskis

2012-11-21 09:53

reporter   ~0007924

attribute filter management is ok