45 $this->
init(
'oxrecommlists' );
57 public function getArticles( $iStart = null, $iNrofArticles = null, $blReload =
false )
60 if ( $this->_oArticles !== null && !$blReload ) {
64 $this->_oArticles =
oxNew(
'oxarticlelist' );
66 if ( $iStart !== null && $iNrofArticles !== null ) {
67 $this->_oArticles->setSqlLimit( $iStart, $iNrofArticles );
71 $this->_oArticles->loadRecommArticles( $this->
getId(), $this->_sArticlesFilter );
99 $sSelect =
"select count(distinct $sArtView.oxid) from oxobject2list ";
100 $sSelect .=
"left join $sArtView on oxobject2list.oxobjectid = $sArtView.oxid ";
101 $sSelect .=
"where (oxobject2list.oxlistid = '".$this->getId().
"') ";
113 $oArtList =
oxNew(
'oxarticlelist' );
114 $oArtList->setSqlLimit( 0, 1 );
115 $oArtList->loadRecommArticles( $this->
getId(), $this->_sArticlesFilter );
117 return $oArtList->current();
127 public function delete( $sOXID = null )
130 $sOXID = $this->
getId();
136 if ( ( $blDelete = parent::delete( $sOXID ) ) ) {
139 $oDb->execute(
"delete from oxobject2list where oxlistid = ".$oDb->quote( $sOXID ) );
161 $sSelect =
'select oxdesc from oxobject2list where oxlistid = '.$oDb->quote( $this->
getId() ).
' and oxobjectid = '.$oDb->quote( $sOXID );
162 return $oDb->getOne( $sSelect );
177 $sQ =
"delete from oxobject2list where oxobjectid = ".$oDb->quote( $sOXID ) .
" and oxlistid=".$oDb->quote( $this->
getId() );
178 return $oDb->execute( $sQ );
195 if ( !$oDb->getOne(
"select oxid from oxobject2list where oxobjectid=".$oDb->quote( $sOXID ).
" and oxlistid=".$oDb->quote( $this->
getId() ),
false,
false) ) {
197 $sQ =
"insert into oxobject2list ( oxid, oxobjectid, oxlistid, oxdesc ) values ( '$sUid', ".$oDb->quote( $sOXID ).
", ".$oDb->quote( $this->
getId() ).
", ".$oDb->quote( $sDesc ).
" )";
198 $blAdd = $oDb->execute( $sQ );
216 if ( count( $aArticleIds ) ) {
217 startProfile(__FUNCTION__);
221 $oRecommList =
oxNew(
'oxlist' );
222 $oRecommList->init(
'oxrecommlist' );
224 $iShopId = $this->
getConfig()->getShopId();
225 $iCnt = $this->
getConfig()->getConfigParam(
'iNrofCrossellArticles' );
227 $oRecommList->setSqlLimit( 0, $iCnt );
229 $sSelect =
"SELECT distinct lists.* FROM oxobject2list AS o2l_lists";
230 $sSelect.=
" LEFT JOIN oxobject2list AS o2l_count ON o2l_lists.oxlistid = o2l_count.oxlistid";
231 $sSelect.=
" LEFT JOIN oxrecommlists as lists ON o2l_lists.oxlistid = lists.oxid";
232 $sSelect.=
" WHERE o2l_lists.oxobjectid IN ( $sIds ) and lists.oxshopid ='$iShopId'";
233 $sSelect.=
" GROUP BY lists.oxid order by (";
234 $sSelect.=
" SELECT count( order1.oxobjectid ) FROM oxobject2list AS order1";
235 $sSelect.=
" WHERE order1.oxobjectid IN ( $sIds ) AND o2l_lists.oxlistid = order1.oxlistid";
236 $sSelect.=
" ) DESC, count( lists.oxid ) DESC";
238 $oRecommList->selectString( $sSelect );
240 stopProfile(__FUNCTION__);
242 if ( $oRecommList->count() ) {
243 startProfile(
'_loadFirstArticles');
247 stopProfile(
'_loadFirstArticles');
268 $sIds = implode(
", ", $aIds);
272 foreach ($oRecommList as $key => $oRecomm) {
274 if (count($aPrevIds)) {
275 $sNegateSql =
" AND $sArtView.oxid not in ( '".implode(
"','", $aPrevIds).
"' ) ";
279 $sArticlesFilter =
"$sNegateSql ORDER BY $sArtView.oxid in ( $sIds ) desc";
280 $oRecomm->setArticlesFilter($sArticlesFilter);
281 $oArtList =
oxNew(
'oxarticlelist' );
282 $oArtList->setSqlLimit( 0, 1 );
283 $oArtList->loadRecommArticles( $oRecomm->getId(), $sArticlesFilter );
285 if (count($oArtList) == 1) {
287 $oArticle = $oArtList->current();
288 $sId = $oArticle->getId();
289 $aPrevIds[$sId] = $sId;
291 $sIds = implode(
", ", $aIds);
293 unset($oRecommList[$key]);
310 $iActPage = ($iActPage < 0) ? 0 : $iActPage;
313 $iNrofCatArticles = $this->
getConfig()->getConfigParam(
'iNrofCatArticles' );
314 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
316 $oRecommList =
oxNew(
'oxlist' );
317 $oRecommList->init(
'oxrecommlist' );
319 $oRecommList->setSqlLimit( $iNrofCatArticles * $iActPage, $iNrofCatArticles );
320 $oRecommList->selectString( $sSelect );
339 $sPartial = substr( $sSelect, strpos( $sSelect,
' from ' ) );
340 $sSelect =
"select count( distinct rl.oxid ) $sPartial ";
355 $iShopId = $this->
getConfig()->getShopId();
356 $sSearchStrQuoted =
oxDb::getDb()->quote(
"%$sSearchStr%" );
358 $sSelect =
"select distinct rl.* from oxrecommlists as rl";
359 $sSelect.=
" inner join oxobject2list as o2l on o2l.oxlistid = rl.oxid";
360 $sSelect.=
" where ( rl.oxtitle like $sSearchStrQuoted or rl.oxdesc like $sSearchStrQuoted";
361 $sSelect.=
" or o2l.oxdesc like $sSearchStrQuoted ) and rl.oxshopid = '$iShopId'";
375 $dOldRating = $this->oxrecommlists__oxrating->value;
376 $dOldCnt = $this->oxrecommlists__oxratingcnt->value;
377 $this->oxrecommlists__oxrating =
new oxField(( $dOldRating * $dOldCnt + $iRating ) / ($dOldCnt + 1),
oxField::T_RAW);
389 $oReview =
oxNew(
'oxreview');
390 $oRevs = $oReview->loadList(
'oxrecommlist', $this->
getId());
392 if ( $oRevs->count() < 1 ) {
410 return $oEncoder->getRecommUrl( $this, $iLang );
412 return $oEncoder->getRecommPageUrl( $this, $iPage, $iLang );
424 if ( $iLang === null ) {
432 if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
436 return $this->_aSeoUrls[$iLang];
447 public function getStdLink( $iLang = null, $aParams = array() )
449 if ( $iLang === null ) {
470 $sUrl = $this->
getConfig()->getShopUrl( $iLang,
false );
473 return $sUrl .
"index.php?cl=recommlist" . ( $blAddId ?
"&recommid=".$this->getId() :
"" );
485 $this->_sArticlesFilter = $sArticlesFilter;
495 if (!$this->oxrecommlists__oxtitle->value) {
496 throw oxNew(
"oxObjectException",
'EXCEPTION_RECOMMLIST_NOTITLE');