46 $this->
init(
'oxrecommlists');
58 public function getArticles($iStart = null, $iNrofArticles = null, $blReload =
false)
61 if ($this->_oArticles !== null && !$blReload) {
65 $this->_oArticles =
oxNew(
'oxarticlelist');
67 if ($iStart !== null && $iNrofArticles !== null) {
68 $this->_oArticles->setSqlLimit($iStart, $iNrofArticles);
72 $this->_oArticles->loadRecommArticles($this->
getId(), $this->_sArticlesFilter);
101 $sSelect =
"select count(distinct $sArtView.oxid) from oxobject2list ";
102 $sSelect .=
"left join $sArtView on oxobject2list.oxobjectid = $sArtView.oxid ";
103 $sSelect .=
"where (oxobject2list.oxlistid = '" . $this->
getId() .
"') ";
115 $oArtList =
oxNew(
'oxarticlelist');
116 $oArtList->setSqlLimit(0, 1);
117 $oArtList->loadRecommArticles($this->
getId(), $this->_sArticlesFilter);
120 return $oArtList->current();
130 public function delete($sOXID = null)
133 $sOXID = $this->
getId();
139 if (($blDelete = parent::delete($sOXID))) {
142 $oDb->execute(
"delete from oxobject2list where oxlistid = " . $oDb->quote($sOXID));
164 $sSelect =
'select oxdesc from oxobject2list where oxlistid = ' . $oDb->quote($this->
getId()) .
' and oxobjectid = ' . $oDb->quote($sOXID);
166 return $oDb->getOne($sSelect);
181 $sQ =
"delete from oxobject2list where oxobjectid = " . $oDb->quote($sOXID) .
" and oxlistid=" . $oDb->quote($this->
getId());
183 return $oDb->execute($sQ);
200 if (!$oDb->getOne(
"select oxid from oxobject2list where oxobjectid=" . $oDb->quote($sOXID) .
" and oxlistid=" . $oDb->quote($this->
getId()),
false,
false)) {
202 $sQ =
"insert into oxobject2list ( oxid, oxobjectid, oxlistid, oxdesc ) values ( '$sUid', " . $oDb->quote($sOXID) .
", " . $oDb->quote($this->
getId()) .
", " . $oDb->quote($sDesc) .
" )";
203 $blAdd = $oDb->execute($sQ);
222 if (count($aArticleIds)) {
223 startProfile(__FUNCTION__);
227 $oRecommList =
oxNew(
'oxlist');
228 $oRecommList->init(
'oxrecommlist');
230 $iShopId = $this->
getConfig()->getShopId();
231 $iCnt = $this->
getConfig()->getConfigParam(
'iNrofCrossellArticles');
233 $oRecommList->setSqlLimit(0, $iCnt);
235 $sSelect =
"SELECT distinct lists.* FROM oxobject2list AS o2l_lists";
236 $sSelect .=
" LEFT JOIN oxobject2list AS o2l_count ON o2l_lists.oxlistid = o2l_count.oxlistid";
237 $sSelect .=
" LEFT JOIN oxrecommlists as lists ON o2l_lists.oxlistid = lists.oxid";
238 $sSelect .=
" WHERE o2l_lists.oxobjectid IN ( $sIds ) and lists.oxshopid ='$iShopId'";
239 $sSelect .=
" GROUP BY lists.oxid order by (";
240 $sSelect .=
" SELECT count( order1.oxobjectid ) FROM oxobject2list AS order1";
241 $sSelect .=
" WHERE order1.oxobjectid IN ( $sIds ) AND o2l_lists.oxlistid = order1.oxlistid";
242 $sSelect .=
" ) DESC, count( lists.oxid ) DESC";
244 $oRecommList->selectString($sSelect);
246 stopProfile(__FUNCTION__);
248 if ($oRecommList->count()) {
249 startProfile(
'_loadFirstArticles');
253 stopProfile(
'_loadFirstArticles');
272 $sIds = implode(
", ", $aIds);
276 foreach ($oRecommList as $key => $oRecomm) {
278 if (count($aPrevIds)) {
279 $sNegateSql =
" AND $sArtView.oxid not in ( '" . implode(
"','", $aPrevIds) .
"' ) ";
283 $sArticlesFilter =
"$sNegateSql ORDER BY $sArtView.oxid in ( $sIds ) desc";
284 $oRecomm->setArticlesFilter($sArticlesFilter);
285 $oArtList =
oxNew(
'oxarticlelist');
286 $oArtList->setSqlLimit(0, 1);
287 $oArtList->loadRecommArticles($oRecomm->getId(), $sArticlesFilter);
289 if (count($oArtList) == 1) {
291 $oArticle = $oArtList->current();
292 $sId = $oArticle->getId();
293 $aPrevIds[$sId] = $sId;
295 $sIds = implode(
", ", $aIds);
297 unset($oRecommList[$key]);
314 $iActPage = ($iActPage < 0) ? 0 : $iActPage;
317 $iNrofCatArticles = $this->
getConfig()->getConfigParam(
'iNrofCatArticles');
318 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
320 $oRecommList =
oxNew(
'oxlist');
321 $oRecommList->init(
'oxrecommlist');
323 $oRecommList->setSqlLimit($iNrofCatArticles * $iActPage, $iNrofCatArticles);
324 $oRecommList->selectString($sSelect);
343 $sPartial = substr($sSelect, strpos($sSelect,
' from '));
344 $sSelect =
"select count( distinct rl.oxid ) $sPartial ";
360 $iShopId = $this->
getConfig()->getShopId();
361 $sSearchStrQuoted =
oxDb::getDb()->quote(
"%$sSearchStr%");
363 $sSelect =
"select distinct rl.* from oxrecommlists as rl";
364 $sSelect .=
" inner join oxobject2list as o2l on o2l.oxlistid = rl.oxid";
365 $sSelect .=
" where ( rl.oxtitle like $sSearchStrQuoted or rl.oxdesc like $sSearchStrQuoted";
366 $sSelect .=
" or o2l.oxdesc like $sSearchStrQuoted ) and rl.oxshopid = '$iShopId'";
378 $dOldRating = $this->oxrecommlists__oxrating->value;
379 $dOldCnt = $this->oxrecommlists__oxratingcnt->value;
380 $this->oxrecommlists__oxrating =
new oxField(($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1),
oxField::T_RAW);
392 $oReview =
oxNew(
'oxreview');
393 $oRevs = $oReview->loadList(
'oxrecommlist', $this->
getId());
395 if ($oRevs->count() < 1) {
414 return $oEncoder->getRecommUrl($this, $iLang);
417 return $oEncoder->getRecommPageUrl($this, $iPage, $iLang);
429 if ($iLang === null) {
437 if (!isset($this->_aSeoUrls[$iLang])) {
441 return $this->_aSeoUrls[$iLang];
452 public function getStdLink($iLang = null, $aParams = array())
454 if ($iLang === null) {
475 $sUrl = $this->
getConfig()->getShopUrl($iLang,
false);
478 return $sUrl .
"index.php?cl=recommlist" . ($blAddId ?
"&recommid=" . $this->
getId() :
"");
488 $this->_sArticlesFilter = $sArticlesFilter;
498 if (!$this->oxrecommlists__oxtitle->value) {
499 throw oxNew(
"oxObjectException",
'EXCEPTION_RECOMMLIST_NOTITLE');