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
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 )?array( oxNew("oxarticle"), '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
00097 $aHistoryArticles = array_unique( $aHistoryArticles);
00098
00099 if(count($aHistoryArticles) > 5) {
00100 array_shift($aHistoryArticles);
00101 }
00102
00103
00104 $mySession->setVar('aHistoryArticles', $aHistoryArticles);
00105
00106
00107
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
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
00135 break;
00136 case 1:
00137
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
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
00177 break;
00178 case 1:
00179
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
00205 if( !trim( $sActionID) ) {
00206 return;
00207 }
00208
00209 $sShopID = $this->getConfig()->getShopId();
00210 $sActionID = strtolower( $sActionID);
00211
00212
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
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
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
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
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
00322
00323 $iArticleCount = null;
00324 if ( $aSessionFilter) {
00325 $oRet = oxDb::getDb()->Execute( $sSelect );
00326 $iArticleCount = $oRet->recordCount();
00327 }
00328
00329 if ($iLimit = (int) $iLimit) {
00330 $sSelect .= " LIMIT $iLimit";
00331 }
00332
00333 $this->selectString( $sSelect );
00334
00335 if ( $iArticleCount !== null ) {
00336 return $iArticleCount;
00337 }
00338
00339 $iTotalCount = oxUtilsCount::getInstance()->getCatArticleCount($sCatId);
00340
00341
00342 return $iTotalCount;
00343 }
00344
00353 public function loadRecommArticles( $sRecommId, $sArticlesFilter = null )
00354 {
00355 $sSelect = $this->_getArticleSelect( $sRecommId, $sArticlesFilter);
00356 $this->selectString( $sSelect );
00357 }
00358
00367 public function loadRecommArticleIds( $sRecommId, $sArticlesFilter )
00368 {
00369 $sSelect = $this->_getArticleSelect( $sRecommId, $sArticlesFilter );
00370
00371 $sArtView = getViewName( 'oxarticles' );
00372 $sPartial = substr( $sSelect, strpos( $sSelect, ' from ' ) );
00373 $sSelect = "select distinct $sArtView.oxid $sPartial ";
00374
00375 $this->_createIdListFromSql( $sSelect );
00376 }
00377
00386 protected function _getArticleSelect( $sRecommId, $sArticlesFilter = null )
00387 {
00388 $sArtView = getViewName( 'oxarticles' );
00389 $sSelect = "select distinct $sArtView.*, oxobject2list.oxdesc from oxobject2list ";
00390 $sSelect .= "left join $sArtView on oxobject2list.oxobjectid = $sArtView.oxid ";
00391 $sSelect .= "where (oxobject2list.oxlistid = '".$sRecommId."') ".$sArticlesFilter;
00392
00393 return $sSelect;
00394 }
00395
00405 public function loadSearchIds( $sSearchStr = '', $sSearchCat = '', $sSearchVendor = '' )
00406 {
00407 $oDb = oxDb::getDb();
00408 $sSearchCat = $sSearchCat?$oDb->quote( $sSearchCat ):null;
00409 $sSearchVendor = $sSearchVendor?$oDb->quote( $sSearchVendor ):null;
00410
00411 $sWhere = null;
00412
00413 if( $sSearchStr ) {
00414 $sWhere = $this->_getSearchSelect( $sSearchStr );
00415 }
00416
00417 $sArticleTable = getViewName('oxarticles');
00418
00419
00420 $sDescTable = '';
00421 $sDescJoin = '';
00422 if ( is_array( $aSearchCols = oxConfig::getInstance()->getConfigParam( 'aSearchCols' ) ) ) {
00423 if ( in_array( 'oxlongdesc', $aSearchCols ) || in_array( 'oxtags', $aSearchCols ) ) {
00424 $sDescView = getViewName( 'oxartextends' );
00425 $sDescTable = ", {$sDescView} ";
00426 $sDescJoin = " {$sDescView}.oxid={$sArticleTable}.oxid and ";
00427 }
00428 }
00429
00430
00431 $sSelect = "select $sArticleTable.oxid from $sArticleTable $sDescTable where $sDescJoin";
00432
00433
00434 if ( $sSearchCat ) {
00435 $sO2CView = getViewName('oxobject2category');
00436 $sSelect = "select $sArticleTable.oxid from $sArticleTable, $sO2CView as oxobject2category $sDescTable ";
00437 $sSelect .= "where oxobject2category.oxcatnid=$sSearchCat and oxobject2category.oxobjectid=$sArticleTable.oxid and $sDescJoin ";
00438 }
00439 $sSelect .= $this->getBaseObject()->getSqlActiveSnippet();
00440 $sSelect .= " and $sArticleTable.oxparentid = '' and $sArticleTable.oxissearch = 1 ";
00441
00442
00443 if ( $sSearchVendor ) {
00444 $sSelect .= " and $sArticleTable.oxvendorid = $sSearchVendor ";
00445 }
00446 $sSelect .= $sWhere;
00447
00448 if ($this->_sCustomSorting) {
00449 $sSelect .= " order by {$this->_sCustomSorting} ";
00450 }
00451
00452 $this->_createIdListFromSql($sSelect);
00453 }
00454
00463 public function loadPriceIds( $dPriceFrom, $dPriceTo )
00464 {
00465
00466 $sSelect = $this->_getPriceSelect( $dPriceFrom, $dPriceTo );
00467 $this->_createIdListFromSql($sSelect);
00468 }
00469
00480 public function loadPriceArticles( $dPriceFrom, $dPriceTo, $oCategory = null)
00481 {
00482 $sArticleTable = getViewName('oxarticles');
00483
00484 $sSelect = $this->_getPriceSelect( $dPriceFrom, $dPriceTo );
00485
00486 $this->selectString( $sSelect);
00487
00488
00489 if ( !$oCategory ) {
00490 return $this->count();
00491 }
00492
00493
00494 $iNumOfArticles = $oCategory->getNrOfArticles();
00495 if ( !isset($iNumOfArticles) || $iNumOfArticles == -1) {
00496 return oxUtilsCount::getInstance()->getPriceCatArticleCount($oCategory->getId(), $dPriceFrom, $dPriceTo );
00497 } else {
00498 return $oCategory->getNrOfArticles();
00499 }
00500 }
00501
00509 public function loadVendorIDs( $sVendorId)
00510 {
00511 $sSelect = $this->_getVendorSelect($sVendorId);
00512 $this->_createIdListFromSql($sSelect);
00513 }
00514
00524 public function loadVendorArticles( $sVendorId, $oVendor = null )
00525 {
00526 $sSelect = $this->_getVendorSelect($sVendorId);
00527 $this->selectString( $sSelect);
00528
00529 return oxUtilsCount::getInstance()->getVendorArticleCount( $sVendorId );
00530 }
00531
00540 public function loadTagArticles( $sTag, $iLang )
00541 {
00542 $oListObject = $this->getBaseObject();
00543 $sArticleTable = $oListObject->getViewName();
00544 $sArticleFields = $oListObject->getSelectFields();
00545 $sActiveSnippet = $oListObject->getSqlActiveSnippet();
00546
00547 $sLangExt = oxLang::getInstance()->getLanguageTag( $iLang );
00548
00549 $oTagHandler = oxNew( 'oxtagcloud' );
00550 $sTag = $oTagHandler->prepareTags( $sTag );
00551
00552 $sQ = "select {$sArticleFields} from oxartextends inner join {$sArticleTable} on
00553 {$sArticleTable}.oxid = oxartextends.oxid where match ( oxartextends.oxtags{$sLangExt} )
00554 against( ".oxDb::getDb()->quote( $sTag )." )";
00555
00556
00557 if ( $sActiveSnippet ) {
00558 $sQ .= " and {$sActiveSnippet}";
00559 }
00560
00561 if ( $this->_sCustomSorting ) {
00562 $sQ .= " order by {$sArticleTable}.{$this->_sCustomSorting} ";
00563 }
00564
00565 $this->selectString( $sQ );
00566
00567
00568 return oxUtilsCount::getInstance()->getTagArticleCount( $sTag, $iLang );
00569 }
00570
00579 public function getTagArticleIds( $sTag, $iLang )
00580 {
00581 $oListObject = $this->getBaseObject();
00582 $sArticleTable = $oListObject->getViewName();
00583 $sActiveSnippet = $oListObject->getSqlActiveSnippet();
00584 $sLangExt = oxLang::getInstance()->getLanguageTag( $iLang );
00585
00586 $oTagHandler = oxNew( 'oxtagcloud' );
00587 $sTag = $oTagHandler->prepareTags( $sTag );
00588
00589 $sQ = "select oxartextends.oxid from oxartextends inner join {$sArticleTable} on
00590 {$sArticleTable}.oxid = oxartextends.oxid where match ( oxartextends.oxtags{$sLangExt} )
00591 against( ".oxDb::getDb()->quote( $sTag )." )";
00592
00593
00594 if ( $sActiveSnippet ) {
00595 $sQ .= " and {$sActiveSnippet}";
00596 }
00597
00598 if ( $this->_sCustomSorting ) {
00599 $sQ .= " order by {$sArticleTable}.{$this->_sCustomSorting} ";
00600 }
00601
00602 return $this->_createIdListFromSql( $sQ );
00603 }
00604
00612 public function loadIds($aIds)
00613 {
00614 if (!count($aIds)) {
00615 $this->clear();
00616 return;
00617 }
00618
00619 foreach ($aIds as $iKey => $sVal)
00620 $aIds[$iKey] = mysql_real_escape_string($sVal);
00621
00622 $sArticleTable = $this->getBaseObject()->getViewName();
00623 $sArticleFields = $this->getBaseObject()->getSelectFields();
00624
00625 $sSelect = "select $sArticleFields from $sArticleTable ";
00626 $sSelect .= "where $sArticleTable.oxid in ( '".implode("','", $aIds)."' ) and ";
00627 $sSelect .= $this->getBaseObject()->getSqlActiveSnippet();
00628
00629 $this->selectString($sSelect);
00630 }
00631
00639 public function loadOrderArticles($aOrders)
00640 {
00641 if (!count($aOrders)) {
00642 $this->clear();
00643 return;
00644 }
00645
00646 foreach ($aOrders as $iKey => $oOrder) {
00647 $aOrdersIds[] = $oOrder->getId();
00648 }
00649
00650 $sArticleTable = $this->getBaseObject()->getViewName();
00651 $sArticleFields = $this->getBaseObject()->getSelectFields();
00652
00653 $sSelect = "SELECT $sArticleFields FROM oxorderarticles ";
00654 $sSelect .= "left join $sArticleTable on oxorderarticles.oxartid = $sArticleTable.oxid ";
00655 $sSelect .= "WHERE oxorderarticles.oxorderid IN ( '".implode("','", $aOrdersIds)."' ) ";
00656 $sSelect .= "order by $sArticleTable.oxid ";
00657
00658 $this->selectString( $sSelect );
00659 }
00660
00668 protected function _createIdListFromSql( $sSql)
00669 {
00670 $rs = oxDb::getDb(true)->execute( $sSql);
00671 if ($rs != false && $rs->recordCount() > 0) {
00672 while (!$rs->EOF) {
00673 $rs->fields = array_change_key_case($rs->fields, CASE_LOWER);
00674 $this[$rs->fields['oxid']] = $rs->fields['oxid'];
00675 $rs->moveNext();
00676 }
00677 }
00678 }
00679
00688 protected function _getFilterSql($sCatId, $aFilter)
00689 {
00690 $sO2CView = getViewName( 'oxobject2category' );
00691 $sArticleTable = getViewName( 'oxarticles' );
00692 $sFilter = '';
00693 $iCnt = 0;
00694 $sSuffix = oxLang::getInstance()->getLanguageTag();
00695
00696 foreach ( $aFilter as $sAttrId => $sValue ) {
00697 if ( $sValue ) {
00698 if ( $sFilter ) {
00699 $sFilter .= ' or ';
00700 }
00701 $sValue = mysql_real_escape_string($sValue);
00702 $sFilter .= "( oa.oxattrid = '$sAttrId' and oa.oxvalue$sSuffix = '$sValue' )";
00703 $iCnt++;
00704 }
00705 }
00706 if ( $sFilter ) {
00707 $sFilter = "WHERE $sFilter ";
00708 }
00709
00710 $sFilterSelect = "select oc.oxobjectid as oxobjectid, count(*) as cnt from ";
00711 $sFilterSelect.= "(SELECT * FROM $sO2CView WHERE $sO2CView.oxcatnid = '$sCatId' GROUP BY $sO2CView.oxobjectid, $sO2CView.oxcatnid) as oc ";
00712 $sFilterSelect.= "INNER JOIN oxobject2attribute as oa ON ( oa.oxobjectid = oc.oxobjectid ) ";
00713 $sFilterSelect.= $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
00750 $sSorting = '';
00751 if ( $this->_sCustomSorting ) {
00752 $sSorting = " {$this->_sCustomSorting} , ";
00753 }
00754
00755
00756
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 GROUP BY oc.oxcatnid, oc.oxobjectid ORDER BY $sSorting oc.oxpos, oc.oxobjectid ";
00766
00767 return $sSelect;
00768 }
00769
00777 protected function _getSearchSelect( $sSearchString )
00778 {
00779
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
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
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 }