oxarticlelist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxArticleList extends oxList
00009 {
00013     protected $_sCustomSorting;
00014 
00020     protected $_sObjectsInListName = 'oxarticle';
00021 
00027     protected $_blLoadSelectLists = false;
00028 
00034     protected $_blLoadPrice = true;
00035 
00043     public function setCustomSorting( $sSorting)
00044     {
00045         // sorting for multilanguage fields
00046         $aSorting = explode(" ", $sSorting);
00047         $aSorting[0] = $this->getBaseObject()->getSqlFieldName($aSorting[0]);
00048         $this->_sCustomSorting = implode( " ", $aSorting );
00049     }
00050 
00056     public function enableSelectLists()
00057     {
00058         $this->_blLoadSelectLists = true;
00059     }
00060 
00069     public function selectString( $sSelect )
00070     {
00071         if ( !$this->isAdmin() ) {
00072             $this->_aAssignCallbackPrepend = ( !$this->_blLoadPrice )?'disablePriceLoad':null;
00073         }
00074 
00075         startProfile("loadinglists");
00076         $oRes = parent::selectString( $sSelect );
00077         stopProfile("loadinglists");
00078 
00079         return $oRes;
00080     }
00081 
00090     public function loadHistoryArticles($sArtId)
00091     {
00092         $mySession = $this->getSession();
00093         $aHistoryArticles = $mySession->getVar('aHistoryArticles');
00094         $aHistoryArticles[] = $sArtId;
00095 
00096         // removing dublicates
00097         $aHistoryArticles = array_unique( $aHistoryArticles);
00098 
00099         if(count($aHistoryArticles) > 5) {
00100             array_shift($aHistoryArticles);
00101         }
00102 
00103         //add to session
00104         $mySession->setVar('aHistoryArticles', $aHistoryArticles);
00105 
00106         //remove current article and return array
00107         //asignment =, not ==
00108         if (($iCurrentArt = array_search($sArtId, $aHistoryArticles)) !== false) {
00109             unset ($aHistoryArticles[$iCurrentArt]);
00110         }
00111 
00112         $this->loadIds(array_values($aHistoryArticles));
00113     }
00114 
00122     public function loadNewestArticles( $iLimit = null )
00123     {
00124         //has module?
00125         $myConfig = $this->getConfig();
00126 
00127         if ( !$myConfig->getConfigParam( 'bl_perfLoadPriceForAddList' ) ) {
00128             $this->_blLoadPrice = false;
00129         }
00130 
00131         $this->_aArray = array();
00132         switch( $myConfig->getConfigParam( 'iNewestArticlesMode' ) ) {
00133             case 0:
00134                 // switched off, do nothing
00135                 break;
00136             case 1:
00137                 // manually entered
00138                 $this->loadAktionArticles( 'oxnewest' );
00139                 break;
00140             case 2:
00141                 $sArticleTable = getViewName('oxarticles');
00142                 if ( $myConfig->getConfigParam( 'blNewArtByInsert' ) ) {
00143                     $sType = 'oxinsert';
00144                 } else {
00145                     $sType = 'oxtimestamp';
00146                 }
00147                 $sSelect  = "select * from $sArticleTable ";
00148                 $sSelect .= "where oxparentid = '' and ".$this->getBaseObject()->getSqlActiveSnippet()." and oxissearch = 1 order by $sType desc ";
00149                 if (!($iLimit = (int) $iLimit)) {
00150                     $iLimit = $myConfig->getConfigParam( 'iNrofNewcomerArticles' );
00151                 }
00152                 $sSelect .= "limit " . $iLimit;
00153 
00154                 $this->selectString($sSelect);
00155                 break;
00156         }
00157 
00158     }
00159 
00165     public function loadTop5Articles()
00166     {
00167         //has module?
00168         $myConfig = $this->getConfig();
00169 
00170         if ( !$myConfig->getConfigParam( 'bl_perfLoadPriceForAddList' ) ) {
00171             $this->_blLoadPrice = false;
00172         }
00173 
00174         switch( $myConfig->getConfigParam( 'iTop5Mode' ) ) {
00175             case 0:
00176                 // switched off, do nothing
00177                 break;
00178             case 1:
00179                 // manually entered
00180                 $this->loadAktionArticles( 'oxtop5');
00181                 break;
00182             case 2:
00183                 $sArticleTable = getViewName('oxarticles');
00184 
00185                 $sSelect  = "select * from $sArticleTable ";
00186                 $sSelect .= "where ".$this->getBaseObject()->getSqlActiveSnippet()." and $sArticleTable.oxissearch = 1 ";
00187                 $sSelect .= "and $sArticleTable.oxparentid = '' and $sArticleTable.oxsoldamount>0 ";
00188                 $sSelect .= "order by $sArticleTable.oxsoldamount desc limit 5";
00189 
00190                 $this->selectString($sSelect);
00191                 break;
00192         }
00193     }
00194 
00202     public function loadAktionArticles( $sActionID )
00203     {
00204         // Performance
00205         if( !trim( $sActionID) ) {
00206             return;
00207         }
00208 
00209         $sShopID        = $this->getConfig()->getShopId();
00210         $sActionID      = strtolower( $sActionID);
00211 
00212         //echo $sSelect;
00213 
00214         $sArticleTable  = $this->getBaseObject()->getViewName();
00215         $sArticleFields = $this->getBaseObject()->getSelectFields();
00216 
00217         $oBase = oxNew("oxactions");
00218         $sActiveSql = $oBase->getSqlActiveSnippet();
00219 
00220         $sSelect = "select $sArticleFields from oxactions2article
00221                               left join $sArticleTable on $sArticleTable.oxid = oxactions2article.oxartid
00222                               left join oxactions on oxactions.oxid = oxactions2article.oxactionid
00223                               where oxactions2article.oxshopid = '$sShopID' and oxactions2article.oxactionid = '$sActionID' and $sActiveSql  
00224                               and $sArticleTable.oxid is not null and " .$this->getBaseObject()->getSqlActiveSnippet(). "
00225                               order by oxactions2article.oxsort";
00226 
00227         $this->selectString( $sSelect );
00228     }
00229 
00237     public function loadArticleCrossSell( $sArticleId )
00238     {
00239         $myConfig = $this->getConfig();
00240 
00241         // Performance
00242         if ( !$myConfig->getConfigParam( 'bl_perfLoadCrossselling' ) ) {
00243             return null;
00244         }
00245 
00246         $sArticleTable  = $this->getBaseObject()->getViewName();
00247 
00248         $sSelect  = "select $sArticleTable.* from oxobject2article left join $sArticleTable on oxobject2article.oxobjectid=$sArticleTable.oxid ";
00249         $sSelect .= "where oxobject2article.oxarticlenid = '$sArticleId' ";
00250         $sSelect .= " and $sArticleTable.oxid is not null and " .$this->getBaseObject()->getSqlActiveSnippet(). " order by rand()";
00251 
00252         // #525 bidirectional crossselling
00253         if ( $myConfig->getConfigParam( 'blBidirectCross' ) ) {
00254             $sSelect  = "select distinct $sArticleTable.* from oxobject2article left join $sArticleTable on (oxobject2article.oxobjectid=$sArticleTable.oxid or oxobject2article.oxarticlenid=$sArticleTable.oxid) ";
00255             $sSelect .= "where (oxobject2article.oxarticlenid = '$sArticleId' or oxobject2article.oxobjectid = '$sArticleId' )";
00256             $sSelect .= " and $sArticleTable.oxid is not null and " .$this->getBaseObject()->getSqlActiveSnippet(). " having $sArticleTable.oxid!='$sArticleId' order by rand()";
00257         }
00258 
00259         $this->setSqlLimit( 0, $myConfig->getConfigParam( 'iNrofCrossellArticles' ));
00260         $this->selectString( $sSelect );
00261     }
00262 
00270     public function loadArticleAccessoires( $sArticleId )
00271     {
00272         $myConfig = $this->getConfig();
00273 
00274         // Performance
00275         if ( !$myConfig->getConfigParam( 'bl_perfLoadAccessoires' ) ) {
00276             return;
00277         }
00278 
00279         $sArticleTable  = $this->getBaseObject()->getViewName();
00280 
00281         $sSelect  = "select $sArticleTable.* from oxaccessoire2article left join $sArticleTable on oxaccessoire2article.oxobjectid=$sArticleTable.oxid ";
00282         $sSelect .= "where oxaccessoire2article.oxarticlenid = '$sArticleId' ";
00283         $sSelect .= " and $sArticleTable.oxid is not null and " .$this->getBaseObject()->getSqlActiveSnippet();
00284         //sorting articles
00285         $sSelect .= " order by oxaccessoire2article.oxsort";
00286 
00287         $this->selectString( $sSelect );
00288     }
00289 
00298     public function loadCategoryIds( $sCatId, $aSessionFilter )
00299     {
00300         $sArticleTable = $this->getBaseObject()->getViewName();
00301         $sSelect = $this->_getCategorySelect( $sArticleTable.'.oxid as oxid', $sCatId, $aSessionFilter );
00302 
00303         $this->_createIdListFromSql( $sSelect );
00304     }
00305 
00315     public function loadCategoryArticles( $sCatId, $aSessionFilter, $iLimit = null )
00316     {
00317         $sArticleFields = $this->getBaseObject()->getSelectFields();
00318 
00319         $sSelect = $this->_getCategorySelect( $sArticleFields, $sCatId, $aSessionFilter );
00320 
00321         // calc count - we can not use count($this) here as we might have paging enabled
00322         // $sSelect = str_replace( $sArticleFields, 'count(*) as cnt', $sSelect);
00323         // #1970C - if any filters are used, we can not use cached category article count
00324         $iArticleCount = null;
00325         if ( $aSessionFilter) {
00326             $oDb = oxDb::getDb();
00327             $sCountSelect = str_replace( "SELECT ".$sArticleFields, 'SELECT count(*) as cnt', $sSelect);
00328             $iArticleCount = $oDb->getOne( $sCountSelect);
00329         }
00330 
00331         if ($iLimit = (int) $iLimit) {
00332             $sSelect .= " LIMIT $iLimit";
00333         }
00334 
00335         $this->selectString( $sSelect );
00336 
00337         if ( $iArticleCount !== null ) {
00338             return $iArticleCount;
00339         }
00340 
00341         $iTotalCount = oxUtilsCount::getInstance()->getCatArticleCount($sCatId);
00342         // this select is FAST so no need to hazzle here with getNrOfArticles()
00343 
00344         return $iTotalCount;
00345     }
00346 
00355     public function loadRecommArticles( $sRecommId, $sArticlesFilter = null )
00356     {
00357         $sSelect = $this->_getArticleSelect( $sRecommId, $sArticlesFilter);
00358         $this->selectString( $sSelect );
00359     }
00360 
00369     public function loadRecommArticleIds( $sRecommId, $sArticlesFilter )
00370     {
00371         $sSelect = $this->_getArticleSelect( $sRecommId, $sArticlesFilter );
00372 
00373         $sArtView = getViewName( 'oxarticles' );
00374         $sPartial = substr( $sSelect, strpos( $sSelect, ' from ' ) );
00375         $sSelect  = "select distinct $sArtView.oxid $sPartial ";
00376 
00377         $this->_createIdListFromSql( $sSelect );
00378     }
00379 
00388     protected function _getArticleSelect( $sRecommId, $sArticlesFilter = null )
00389     {
00390         $sArtView = getViewName( 'oxarticles' );
00391         $sSelect  = "select distinct $sArtView.*, oxobject2list.oxdesc from oxobject2list ";
00392         $sSelect .= "left join $sArtView on oxobject2list.oxobjectid = $sArtView.oxid ";
00393         $sSelect .= "where (oxobject2list.oxlistid = '".$sRecommId."') ".$sArticlesFilter;
00394 
00395         return $sSelect;
00396     }
00397 
00407     public function loadSearchIds( $sSearchStr = '', $sSearchCat = '', $sSearchVendor = '' )
00408     {
00409         $oDb = oxDb::getDb();
00410         $sSearchCat    = $sSearchCat?$oDb->quote( $sSearchCat ):null;
00411         $sSearchVendor = $sSearchVendor?$oDb->quote( $sSearchVendor ):null;
00412 
00413         $sWhere = null;
00414 
00415         if( $sSearchStr ) {
00416             $sWhere = $this->_getSearchSelect( $sSearchStr );
00417         }
00418 
00419         $sArticleTable = getViewName('oxarticles');
00420 
00421         // longdesc field now is kept on different table
00422         $sDescTable = '';
00423         $sDescJoin  = '';
00424         if ( is_array( $aSearchCols = oxConfig::getInstance()->getConfigParam( 'aSearchCols' ) ) ) {
00425             if ( in_array( 'oxlongdesc', $aSearchCols ) || in_array( 'oxtags', $aSearchCols ) ) {
00426                 $sDescView  = getViewName( 'oxartextends' );
00427                 $sDescTable = ", {$sDescView} ";
00428                 $sDescJoin  = " {$sDescView}.oxid={$sArticleTable}.oxid and ";
00429             }
00430         }
00431 
00432         // load the articles
00433         $sSelect  =  "select $sArticleTable.oxid from $sArticleTable $sDescTable where $sDescJoin";
00434 
00435         // must be additional conditions in select if searching in category
00436         if ( $sSearchCat ) {
00437             $sO2CView = getViewName('oxobject2category');
00438             $sSelect  = "select $sArticleTable.oxid from $sArticleTable, $sO2CView as oxobject2category $sDescTable ";
00439             $sSelect .= "where oxobject2category.oxcatnid=$sSearchCat and oxobject2category.oxobjectid=$sArticleTable.oxid and $sDescJoin ";
00440         }
00441         $sSelect .= $this->getBaseObject()->getSqlActiveSnippet();
00442         $sSelect .= " and $sArticleTable.oxparentid = '' and $sArticleTable.oxissearch = 1 ";
00443 
00444         // #671
00445         if ( $sSearchVendor ) {
00446             $sSelect .= " and $sArticleTable.oxvendorid = $sSearchVendor ";
00447         }
00448         $sSelect .= $sWhere;
00449 
00450         if ($this->_sCustomSorting) {
00451             $sSelect .= " order by {$this->_sCustomSorting} ";
00452         }
00453 
00454         $this->_createIdListFromSql($sSelect);
00455     }
00456 
00465     public function loadPriceIds( $dPriceFrom, $dPriceTo )
00466     {
00467 
00468         $sSelect =  $this->_getPriceSelect( $dPriceFrom, $dPriceTo );
00469         $this->_createIdListFromSql($sSelect);
00470     }
00471 
00482     public function loadPriceArticles( $dPriceFrom, $dPriceTo, $oCategory = null)
00483     {
00484         $sArticleTable = getViewName('oxarticles');
00485 
00486         $sSelect =  $this->_getPriceSelect( $dPriceFrom, $dPriceTo );
00487 
00488         $this->selectString( $sSelect);
00489         //echo( $sSelect);
00490 
00491         if ( !$oCategory ) {
00492             return $this->count();
00493         }
00494 
00495         // #858A
00496         $iNumOfArticles = $oCategory->getNrOfArticles();
00497         if ( !isset($iNumOfArticles) || $iNumOfArticles == -1) {
00498             return oxUtilsCount::getInstance()->getPriceCatArticleCount($oCategory->getId(), $dPriceFrom, $dPriceTo );
00499         } else {
00500             return $oCategory->getNrOfArticles();
00501         }
00502     }
00503 
00511     public function loadVendorIDs( $sVendorId)
00512     {
00513         $sSelect = $this->_getVendorSelect($sVendorId);
00514         $this->_createIdListFromSql($sSelect);
00515     }
00516 
00526     public function loadVendorArticles( $sVendorId, $oVendor = null )
00527     {
00528         $sSelect = $this->_getVendorSelect($sVendorId);
00529         $this->selectString( $sSelect);
00530 
00531         return oxUtilsCount::getInstance()->getVendorArticleCount( $sVendorId );
00532     }
00533 
00542     public function loadTagArticles( $sTag, $iLang )
00543     {
00544         $oListObject = $this->getBaseObject();
00545         $sArticleTable  = $oListObject->getViewName();
00546         $sArticleFields = $oListObject->getSelectFields();
00547         $sActiveSnippet = $oListObject->getSqlActiveSnippet();
00548 
00549         $sLangExt = oxLang::getInstance()->getLanguageTag( $iLang );
00550 
00551         $oTagHandler = oxNew( 'oxtagcloud' );
00552         $sTag = $oTagHandler->prepareTags( $sTag );
00553 
00554         $sQ = "select {$sArticleFields} from oxartextends inner join {$sArticleTable} on
00555                {$sArticleTable}.oxid = oxartextends.oxid where match ( oxartextends.oxtags{$sLangExt} )
00556                against( ".oxDb::getDb()->quote( $sTag )." )";
00557 
00558         // checking stock etc
00559         if ( $sActiveSnippet ) {
00560             $sQ .= " and {$sActiveSnippet}";
00561         }
00562 
00563         if ( $this->_sCustomSorting ) {
00564             $sQ .= " order by {$sArticleTable}.{$this->_sCustomSorting} ";
00565         }
00566 
00567         $this->selectString( $sQ );
00568 
00569         // calc count - we can not use count($this) here as we might have paging enabled
00570         return oxUtilsCount::getInstance()->getTagArticleCount( $sTag, $iLang );
00571     }
00572 
00581     public function getTagArticleIds( $sTag, $iLang )
00582     {
00583         $oListObject = $this->getBaseObject();
00584         $sArticleTable  = $oListObject->getViewName();
00585         $sActiveSnippet = $oListObject->getSqlActiveSnippet();
00586         $sLangExt = oxLang::getInstance()->getLanguageTag( $iLang );
00587 
00588         $oTagHandler = oxNew( 'oxtagcloud' );
00589         $sTag = $oTagHandler->prepareTags( $sTag );
00590 
00591         $sQ = "select oxartextends.oxid from oxartextends inner join {$sArticleTable} on
00592                {$sArticleTable}.oxid = oxartextends.oxid where match ( oxartextends.oxtags{$sLangExt} )
00593                against( ".oxDb::getDb()->quote( $sTag )." )";
00594 
00595         // checking stock etc
00596         if ( $sActiveSnippet ) {
00597             $sQ .= " and {$sActiveSnippet}";
00598         }
00599 
00600         if ( $this->_sCustomSorting ) {
00601             $sQ .= " order by {$sArticleTable}.{$this->_sCustomSorting} ";
00602         }
00603 
00604         return $this->_createIdListFromSql( $sQ );
00605     }
00606 
00614     public function loadIds($aIds)
00615     {
00616         if (!count($aIds)) {
00617             $this->clear();
00618             return;
00619         }
00620 
00621         foreach ($aIds as $iKey => $sVal)
00622             $aIds[$iKey] = mysql_real_escape_string($sVal);
00623 
00624         $sArticleTable = $this->getBaseObject()->getViewName();
00625         $sArticleFields = $this->getBaseObject()->getSelectFields();
00626 
00627         $sSelect  = "select $sArticleFields from $sArticleTable ";
00628         $sSelect .= "where $sArticleTable.oxid in ( '".implode("','", $aIds)."' ) and ";
00629         $sSelect .= $this->getBaseObject()->getSqlActiveSnippet();
00630 
00631         $this->selectString($sSelect);
00632     }
00633 
00641     public function loadOrderArticles($aOrders)
00642     {
00643         if (!count($aOrders)) {
00644             $this->clear();
00645             return;
00646         }
00647 
00648         foreach ($aOrders as $iKey => $oOrder) {
00649             $aOrdersIds[] = $oOrder->getId();
00650         }
00651 
00652         $sArticleTable = $this->getBaseObject()->getViewName();
00653         $sArticleFields = $this->getBaseObject()->getSelectFields();
00654 
00655         $sSelect  = "SELECT $sArticleFields FROM oxorderarticles ";
00656         $sSelect .= "left join $sArticleTable on oxorderarticles.oxartid = $sArticleTable.oxid ";
00657         $sSelect .= "WHERE oxorderarticles.oxorderid IN ( '".implode("','", $aOrdersIds)."' ) ";
00658         $sSelect .= "order by $sArticleTable.oxid ";
00659 
00660         $this->selectString( $sSelect );
00661     }
00662 
00670     protected function _createIdListFromSql( $sSql)
00671     {
00672         $rs = oxDb::getDb(true)->execute( $sSql);
00673         if ($rs != false && $rs->recordCount() > 0) {
00674             while (!$rs->EOF) {
00675                 $rs->fields = array_change_key_case($rs->fields, CASE_LOWER);
00676                 $this[$rs->fields['oxid']] =  $rs->fields['oxid']; //only the oxid
00677                 $rs->moveNext();
00678             }
00679         }
00680     }
00681 
00690     protected function _getFilterSql($sCatId, $aFilter)
00691     {
00692         $sO2CView      = getViewName( 'oxobject2category' );
00693         $sArticleTable = getViewName( 'oxarticles' );
00694         $sFilter = '';
00695         $iCnt    = 0;
00696         $sSuffix = oxLang::getInstance()->getLanguageTag();
00697 
00698         foreach ( $aFilter as $sAttrId => $sValue ) {
00699             if ( $sValue ) {
00700                 if ( $sFilter ) {
00701                     $sFilter .= ' or ';
00702                 }
00703                 $sValue = mysql_real_escape_string($sValue);
00704                 $sFilter .= "( oa.oxattrid = '$sAttrId' and oa.oxvalue$sSuffix = '$sValue' )";
00705                 $iCnt++;
00706             }
00707         }
00708         if ( $sFilter ) {
00709             $sFilter = "and ( $sFilter ) ";
00710         }
00711         $sFilterSelect = "select oc.oxobjectid as oxobjectid, count(*) as cnt from $sO2CView as oc ";
00712         $sFilterSelect.= "INNER JOIN oxobject2attribute as oa ON ( oa.oxobjectid = oc.oxobjectid ) ";
00713         $sFilterSelect.= "WHERE oc.oxcatnid = '$sCatId' $sFilter ";
00714         $sFilterSelect.= "GROUP BY oa.oxobjectid HAVING cnt = $iCnt ";
00715 
00716         $aIds = oxDb::getDb( true )->getAll( $sFilterSelect );
00717         $sIds = '';
00718 
00719         if ( $aIds ) {
00720             foreach ( $aIds as $aArt ) {
00721                 if ( $sIds ) {
00722                     $sIds .= ', ';
00723                 }
00724                 $sIds .= " '{$aArt['oxobjectid']}' ";
00725             }
00726 
00727             if ( $sIds ) {
00728                 $sFilterSql = " and $sArticleTable.oxid in ( $sIds ) ";
00729             }
00730         }
00731         return $sFilterSql;
00732     }
00733 
00743     protected function _getCategorySelect( $sFields, $sCatId, $aSessionFilter )
00744     {
00745         $sArticleTable = getViewName( 'oxarticles' );
00746         $sO2CView      = getViewName( 'oxobject2category' );
00747 
00748         // ----------------------------------
00749         // sorting
00750         $sSorting = '';
00751         if ( $this->_sCustomSorting ) {
00752             $sSorting = " {$this->_sCustomSorting} , ";
00753         }
00754 
00755         // ----------------------------------
00756         // filtering ?
00757         $sFilterSql = '';
00758         if ( $aSessionFilter && isset( $aSessionFilter[$sCatId] ) ) {
00759             $sFilterSql = $this->_getFilterSql($sCatId, $aSessionFilter[$sCatId]);
00760         }
00761 
00762         $sSelect = "SELECT $sFields FROM $sO2CView as oc left join $sArticleTable
00763                     ON $sArticleTable.oxid = oc.oxobjectid
00764                     WHERE ".$this->getBaseObject()->getSqlActiveSnippet()." and $sArticleTable.oxparentid = ''
00765                     and oc.oxcatnid = '$sCatId' $sFilterSql ORDER BY $sSorting oc.oxpos, oc.oxobjectid ";
00766 
00767         return $sSelect;
00768     }
00769 
00777     protected function _getSearchSelect( $sSearchString )
00778     {
00779         // check if it has string at all
00780         if ( !$sSearchString || !str_replace( ' ', '', $sSearchString ) ) {
00781             return '';
00782         }
00783 
00784         $myConfig = $this->getConfig();
00785         $myUtils  = oxUtils::getInstance();
00786         $sArticleTable = $this->getBaseObject()->getViewName();
00787 
00788         $aSearch = explode( ' ', $sSearchString);
00789 
00790         $sSearch  = ' and ( ';
00791         $blSep = false;
00792 
00793         // #723
00794         if ( $myConfig->getConfigParam( 'blSearchUseAND' ) ) {
00795             $sSearchSep = ' and ';
00796         } else {
00797             $sSearchSep = ' or ';
00798         }
00799 
00800         $aSearchCols = $myConfig->getConfigParam( 'aSearchCols' );
00801         foreach ( $aSearch as $sSearchString) {
00802 
00803             if ( !strlen( $sSearchString ) ) {
00804                 continue;
00805             }
00806 
00807             if ( $blSep ) {
00808                 $sSearch .= $sSearchSep;
00809             }
00810             $blSep2   = false;
00811             $sSearch .= '( ';
00812 
00813             $sUml = oxUtilsString::getInstance()->prepareStrForSearch($sSearchString);
00814             foreach ( $aSearchCols as $sField ) {
00815 
00816                 if ( $blSep2) {
00817                     $sSearch  .= ' or ';
00818                 }
00819 
00820                 // as long description now is on different table table must differ
00821                 if ( $sField == 'oxlongdesc' || $sField == 'oxtags') {
00822                     $sSearchTable = getViewName( 'oxartextends' );
00823                 } else {
00824                     $sSearchTable = $sArticleTable;
00825                 }
00826 
00827                 $sField = $this->getBaseObject()->getSqlFieldName( $sField );
00828 
00829                 $sSearch .= $sSearchTable.'.'.$sField.' like '.oxDb::getDb()->Quote('%'.$sSearchString.'%') . ' ';
00830                 if ( $sUml ) {
00831                     $sSearch  .= ' or '.$sSearchTable.'.'.$sField.' like '.oxDb::getDb()->Quote('%'.$sUml.'%');
00832                 }
00833                 $blSep2 = true;
00834             }
00835             $sSearch  .= ' ) ';
00836             $blSep = true;
00837         }
00838         $sSearch .= ' ) ';
00839 
00840         return $sSearch;
00841     }
00842 
00851     protected function _getPriceSelect( $dPriceFrom, $dPriceTo )
00852     {
00853         $sArticleTable = $this->getBaseObject()->getViewName();
00854         $sSelectFields = $this->getBaseObject()->getSelectFields();
00855 
00856         $sSubSelect  = "select if(oxparentid='',oxid,oxparentid) as id from $sArticleTable where oxprice > 0 ";
00857         if ( $dPriceTo) {
00858             $sSubSelect .= $dPriceTo?"and oxprice <= $dPriceTo ":" ";
00859         }
00860         $sSubSelect .= "group by id having ";
00861         if ( $dPriceFrom) {
00862             $sSubSelect .= $dPriceFrom?"min(oxprice) >= $dPriceFrom ":" ";
00863         }
00864         $sSelect =  "select $sSelectFields from $sArticleTable where ";
00865         $sSelect .= "$sArticleTable.oxid in ($sSubSelect) ";
00866         $sSelect .= "and ".$this->getBaseObject()->getSqlActiveSnippet()." and $sArticleTable.oxissearch = 1";
00867 
00868         if ( !$this->_sCustomSorting ) {
00869             $sSelect .= " order by $sArticleTable.oxprice asc , $sArticleTable.oxid";
00870         } else {
00871             $sSelect .= " order by {$this->_sCustomSorting}, $sArticleTable.oxid ";
00872         }
00873 
00874         return $sSelect;
00875 
00876     }
00877 
00885     protected function _getVendorSelect( $sVendorId )
00886     {
00887         $sArticleTable = getViewName('oxarticles');
00888         $sFieldNames = $this->getBaseObject()->getSelectFields();
00889         $sSelect  = "select $sFieldNames from $sArticleTable ";
00890         $sSelect .= "where $sArticleTable.oxvendorid = '$sVendorId' ";
00891         $sSelect .= " and " . $this->getBaseObject()->getSqlActiveSnippet() . " and $sArticleTable.oxparentid = ''  ";
00892 
00893         if ( $this->_sCustomSorting ) {
00894             $sSelect .= " ORDER BY {$this->_sCustomSorting} ";
00895         }
00896 
00897         return $sSelect;
00898     }
00899 
00900 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5