View Issue Details

IDProjectCategoryView StatusLast Update
0001424OXID eShop (all versions)1.01. Products (product, categories, manufacturer, promotions etc.)public2012-12-07 14:13
Reporterandreas_ziethen Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.1.6 revision 22740 
Fixed in Version4.3.0 revision 26948 
Summary0001424: oxcategorylist: new method _getSqlSelectFieldsForTree() is not recognized in method sortCats()
DescriptionThe method _getSqlSelectFieldsForTree() has been added recently to give developers the possibility to easily add custom fields to the category-tree-objects.
Unfortunately this is not considered in method oxcategorylist::sortCats(). Here a fixed array of table columns is given to function _getSelectString(). But _getSelectString() gets the field list by using _getSqlSelectFieldsForTree() and not from that fixed array of columns.

So if for example you build a module which puts a new field at the very beginning of $sFieldList, the sorting of the root cats does not work any longer cause in sortCats() $rs->fields[0] is used for sorting.

Example as module from oxcategorylist:

protected function _getSqlSelectFieldsForTree($sTable, $aColumns = null)
    {
        $sFieldList = parent::_getSqlSelectFieldsForTree($sTable, $aColumns);
        
        $sFieldList = " $sTable.oxthumb as oxthumb,".$sFieldList;
        

        return $sFieldList;
    }

This leads to the unexpected effect of a wrong sorting of root categories.
TagsCategory, Sorting
Theme
BrowserAll
PHP Version5.2.6
Database Version5.0.33

Relationships

related to 0001113 resolvedsarunas_valaskevicius Category tree loading performance 

Activities

alfonsas_cirtautas

2009-11-13 07:47

reporter   ~0002063

Method _getSqlSelectFieldsForTree and many others changes were introduced after fixing bug 0001113 .

Main purpose of aColums parameter was to allow selecting only needed fields for tree loading and sorting.

Your module can be improved by adding a simple check if is_null($aColumns), because this is the only case where this array can give developers the possibility to easily add custom fields, in other cases it is used only for sorting and tree depth loading optimizations.

protected function _getSqlSelectFieldsForTree($sTable, $aColumns = null)
{
    $sFieldList = parent::_getSqlSelectFieldsForTree($sTable, $aColumns);
    if(is_null($aColumns))
        $sFieldList = " $sTable.oxthumb as oxthumb,".$sFieldList;
    }
    return $sFieldList;
}

alfonsas_cirtautas

2009-11-13 07:50

reporter   ~0002064

Result handling in oxcategorylist::sortCats() changed to associative array, to eliminate such problems and unexpected effects