source/Application/Controller/Admin/ActionsOrderAjax.php
public function setSorting()
    {
        $sSelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sQuotedSelectionId = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sSelId);
        $sSelect = "select * from oxobject2selectlist where oxobjectid= {$sQuotedSelectionId} order by oxsort";

        $oList = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
        $oList->init("oxbase", "oxobject2selectlist");
        $oList->selectString($sSelect);

        // fixing indexes
        $iSelCnt = 0;
        $aIdx2Id = [];
        foreach ($oList as $sKey => $oSel) {
            if ($oSel->oxobject2selectlist__oxsort->value != $iSelCnt) {
                $oSel->oxobject2selectlist__oxsort->setValue($iSelCnt);

                // saving new index
                $oSel->save();
            }
            $aIdx2Id[$iSelCnt] = $sKey;
            $iSelCnt++;
        }

        //
        if (($iKey = array_search(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sortoxid'), $aIdx2Id)) !== false) {
            $iDir = (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('direction') == 'up') ? ($iKey - 1) : ($iKey + 1);
            if (isset($aIdx2Id[$iDir])) {
                // exchanging indexes
                $oDir1 = $oList->offsetGet($aIdx2Id[$iDir]);
                $oDir2 = $oList->offsetGet($aIdx2Id[$iKey]);

                $iCopy = $oDir1->oxobject2selectlist__oxsort->value;
                $oDir1->oxobject2selectlist__oxsort->setValue($oDir2->oxobject2selectlist__oxsort->value);
                $oDir2->oxobject2selectlist__oxsort->setValue($iCopy);

                $oDir1->save();
                $oDir2->save();
            }
        }

        $sQAdd = $this->_getQuery();

        $sQ = 'select ' . $this->_getQueryCols() . $sQAdd;
        $sCountQ = 'select count( * ) ' . $sQAdd;

        $this->_outputResponse($this->_getData($sCountQ, $sQ));
    }
public function setSorting()
    {
        $sSelId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('oxid');
        $sQuotedSelectionId = \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->quote($sSelId);
        $sSelect = "select * from oxobject2selectlist where oxobjectid= {$sQuotedSelectionId} order by oxsort";

        $oList = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
        $oList->init("oxbase", "oxobject2selectlist");
        $oList->selectString($sSelect);

        // fixing indexes
        $iSelCnt = 0;
        $aIdx2Id = [];
        foreach ($oList as $sKey => $oSel) {
            if ($oSel->oxobject2selectlist__oxsort->value != $iSelCnt) {
                $oSel->oxobject2selectlist__oxsort->setValue($iSelCnt);

                // saving new index
                $oSel->save();
            }
            $aIdx2Id[$iSelCnt] = $sKey;
            $iSelCnt++;
        }

        //
        if (($iKey = array_search(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('sortoxid'), $aIdx2Id)) !== false) {
            $iDir = (\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('direction') == 'up') ? ($iKey - 1) : ($iKey + 1);
            if (isset($aIdx2Id[$iDir])) {
                // exchanging indexes
                $oDir1 = $oList->offsetGet($aIdx2Id[$iDir]);
                $oDir2 = $oList->offsetGet($aIdx2Id[$iKey]);

                $iCopy = $oDir1->oxobject2selectlist__oxsort->value;
                $oDir1->oxobject2selectlist__oxsort->setValue($oDir2->oxobject2selectlist__oxsort->value);
                $oDir2->oxobject2selectlist__oxsort->setValue($iCopy);

                $oDir1->save();
                $oDir2->save();
            }
        }

        $sQAdd = $this->_getQuery();

        $sQ = 'select ' . $this->_getQueryCols() . $sQAdd;
        $sCountQ = 'select count( * ) ' . $sQAdd;

        $this->_outputResponse($this->_getData($sCountQ, $sQ));
    }
public function setSorting ( ) { $ sSelId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'oxid' ) ; $ sQuotedSelectionId = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) -> quote ( $ sSelId ) ; $ sSelect = "select * from oxobject2selectlist where oxobjectid= {$sQuotedSelectionId} order by oxsort" ; $ oList = oxNew ( \ OxidEsales \ Eshop \ Core \ Model \ ListModel :: class ) ; $ oList -> init ( "oxbase" , "oxobject2selectlist" ) ; $ oList -> selectString ( $ sSelect ) ; // fixing indexes $ iSelCnt = 0 ; $ aIdx2Id = [ ] ; foreach ( $ oList as $ sKey => $ oSel ) { if ( $ oSel -> oxobject2selectlist__oxsort -> value != $ iSelCnt ) { $ oSel -> oxobject2selectlist__oxsort -> setValue ( $ iSelCnt ) ; // saving new index $ oSel -> save ( ) ; } $ aIdx2Id [ $ iSelCnt ] = $ sKey ; $ iSelCnt ++ ; } // if ( ( $ iKey = array_search ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'sortoxid' ) , $ aIdx2Id ) ) !== false ) { $ iDir = ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'direction' ) == 'up' ) ? ( $ iKey - 1 ) : ( $ iKey + 1 ) ; if ( isset ( $ aIdx2Id [ $ iDir ] ) ) { // exchanging indexes $ oDir1 = $ oList -> offsetGet ( $ aIdx2Id [ $ iDir ] ) ; $ oDir2 = $ oList -> offsetGet ( $ aIdx2Id [ $ iKey ] ) ; $ iCopy = $ oDir1 -> oxobject2selectlist__oxsort -> value ; $ oDir1 -> oxobject2selectlist__oxsort -> setValue ( $ oDir2 -> oxobject2selectlist__oxsort -> value ) ; $ oDir2 -> oxobject2selectlist__oxsort -> setValue ( $ iCopy ) ; $ oDir1 -> save ( ) ; $ oDir2 -> save ( ) ; } } $ sQAdd = $ this -> _getQuery ( ) ; $ sQ = 'select ' . $ this -> _getQueryCols ( ) . $ sQAdd ; $ sCountQ = 'select count( * ) ' . $ sQAdd ; $ this -> _outputResponse ( $ this -> _getData ( $ sCountQ , $ sQ ) ) ; }
Applies sorting for selection lists
Applies sorting for selection lists