47 $this->
init(
'oxrecommlists');
59 public function getArticles($iStart = null, $iNrofArticles = null, $blReload =
false)
62 if ($this->_oArticles !== null && !$blReload) {
66 $this->_oArticles =
oxNew(
'oxarticlelist');
68 if ($iStart !== null && $iNrofArticles !== null) {
69 $this->_oArticles->setSqlLimit($iStart, $iNrofArticles);
73 $this->_oArticles->loadRecommArticles($this->
getId(), $this->_sArticlesFilter);
102 $sSelect =
"select count(distinct $sArtView.oxid) from oxobject2list ";
103 $sSelect .=
"left join $sArtView on oxobject2list.oxobjectid = $sArtView.oxid ";
104 $sSelect .=
"where (oxobject2list.oxlistid = '" . $this->
getId() .
"') ";
116 $oArtList =
oxNew(
'oxarticlelist');
117 $oArtList->setSqlLimit(0, 1);
118 $oArtList->loadRecommArticles($this->
getId(), $this->_sArticlesFilter);
121 return $oArtList->current();
131 public function delete($sOXID = null)
134 $sOXID = $this->
getId();
140 if (($blDelete = parent::delete($sOXID))) {
143 $oDb->execute(
"delete from oxobject2list where oxlistid = " . $oDb->quote($sOXID));
165 $sSelect =
'select oxdesc from oxobject2list where oxlistid = ' . $oDb->quote($this->
getId()) .
' and oxobjectid = ' . $oDb->quote($sOXID);
167 return $oDb->getOne($sSelect);
182 $sQ =
"delete from oxobject2list where oxobjectid = " . $oDb->quote($sOXID) .
" and oxlistid=" . $oDb->quote($this->
getId());
184 return $oDb->execute($sQ);
201 if (!$oDb->getOne(
"select oxid from oxobject2list where oxobjectid=" . $oDb->quote($sOXID) .
" and oxlistid=" . $oDb->quote($this->
getId()),
false,
false)) {
203 $sQ =
"insert into oxobject2list ( oxid, oxobjectid, oxlistid, oxdesc ) values ( '$sUid', " . $oDb->quote($sOXID) .
", " . $oDb->quote($this->
getId()) .
", " . $oDb->quote($sDesc) .
" )";
204 $blAdd = $oDb->execute($sQ);
223 if (count($aArticleIds)) {
224 startProfile(__FUNCTION__);
228 $oRecommList =
oxNew(
'oxlist');
229 $oRecommList->init(
'oxrecommlist');
231 $iShopId = $this->
getConfig()->getShopId();
232 $iCnt = $this->
getConfig()->getConfigParam(
'iNrofCrossellArticles');
234 $oRecommList->setSqlLimit(0, $iCnt);
236 $sSelect =
"SELECT distinct lists.* FROM oxobject2list AS o2l_lists";
237 $sSelect .=
" LEFT JOIN oxobject2list AS o2l_count ON o2l_lists.oxlistid = o2l_count.oxlistid";
238 $sSelect .=
" LEFT JOIN oxrecommlists as lists ON o2l_lists.oxlistid = lists.oxid";
239 $sSelect .=
" WHERE o2l_lists.oxobjectid IN ( $sIds ) and lists.oxshopid ='$iShopId'";
240 $sSelect .=
" GROUP BY lists.oxid order by (";
241 $sSelect .=
" SELECT count( order1.oxobjectid ) FROM oxobject2list AS order1";
242 $sSelect .=
" WHERE order1.oxobjectid IN ( $sIds ) AND o2l_lists.oxlistid = order1.oxlistid";
243 $sSelect .=
" ) DESC, count( lists.oxid ) DESC";
245 $oRecommList->selectString($sSelect);
247 stopProfile(__FUNCTION__);
249 if ($oRecommList->count()) {
250 startProfile(
'_loadFirstArticles');
254 stopProfile(
'_loadFirstArticles');
273 $sIds = implode(
", ", $aIds);
277 foreach ($oRecommList as $key => $oRecomm) {
279 if (count($aPrevIds)) {
280 $sNegateSql =
" AND $sArtView.oxid not in ( '" . implode(
"','", $aPrevIds) .
"' ) ";
284 $sArticlesFilter =
"$sNegateSql ORDER BY $sArtView.oxid in ( $sIds ) desc";
285 $oRecomm->setArticlesFilter($sArticlesFilter);
286 $oArtList =
oxNew(
'oxarticlelist');
287 $oArtList->setSqlLimit(0, 1);
288 $oArtList->loadRecommArticles($oRecomm->getId(), $sArticlesFilter);
290 if (count($oArtList) == 1) {
292 $oArticle = $oArtList->current();
293 $sId = $oArticle->getId();
294 $aPrevIds[$sId] = $sId;
296 $sIds = implode(
", ", $aIds);
298 unset($oRecommList[$key]);
315 $iActPage = ($iActPage < 0) ? 0 : $iActPage;
318 $iNrofCatArticles = $this->
getConfig()->getConfigParam(
'iNrofCatArticles');
319 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
321 $oRecommList =
oxNew(
'oxlist');
322 $oRecommList->init(
'oxrecommlist');
324 $oRecommList->setSqlLimit($iNrofCatArticles * $iActPage, $iNrofCatArticles);
325 $oRecommList->selectString($sSelect);
344 $sPartial = substr($sSelect, strpos($sSelect,
' from '));
345 $sSelect =
"select count( distinct rl.oxid ) $sPartial ";
361 $iShopId = $this->
getConfig()->getShopId();
362 $sSearchStrQuoted =
oxDb::getDb()->quote(
"%$sSearchStr%");
364 $sSelect =
"select distinct rl.* from oxrecommlists as rl";
365 $sSelect .=
" inner join oxobject2list as o2l on o2l.oxlistid = rl.oxid";
366 $sSelect .=
" where ( rl.oxtitle like $sSearchStrQuoted or rl.oxdesc like $sSearchStrQuoted";
367 $sSelect .=
" or o2l.oxdesc like $sSearchStrQuoted ) and rl.oxshopid = '$iShopId'";
379 $dOldRating = $this->oxrecommlists__oxrating->value;
380 $dOldCnt = $this->oxrecommlists__oxratingcnt->value;
381 $this->oxrecommlists__oxrating =
new oxField(($dOldRating * $dOldCnt + $iRating) / ($dOldCnt + 1),
oxField::T_RAW);
393 $oReview =
oxNew(
'oxreview');
394 $oRevs = $oReview->loadList(
'oxrecommlist', $this->
getId());
396 if ($oRevs->count() < 1) {
415 return $oEncoder->getRecommUrl($this, $iLang);
418 return $oEncoder->getRecommPageUrl($this, $iPage, $iLang);
430 if ($iLang === null) {
438 if (!isset($this->_aSeoUrls[$iLang])) {
442 return $this->_aSeoUrls[$iLang];
453 public function getStdLink($iLang = null, $aParams = array())
455 if ($iLang === null) {
476 $sUrl = $this->
getConfig()->getShopUrl($iLang,
false);
479 return $sUrl .
"index.php?cl=recommlist" . ($blAddId ?
"&recommid=" . $this->
getId() :
"");
489 $this->_sArticlesFilter = $sArticlesFilter;
499 if (!$this->oxrecommlists__oxtitle->value) {
500 throw oxNew(
"oxObjectException",
'EXCEPTION_RECOMMLIST_NOTITLE');