OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
vendorlist.php
Go to the documentation of this file.
1 <?php
2 
9 class VendorList extends aList
10 {
11 
17  protected $_sListType = 'vendor';
18 
24  protected $_blVisibleSubCats = null;
25 
31  protected $_oSubCatList = null;
32 
38  protected $_sTplLocation = null;
39 
45  protected $_sCatTitle = null;
46 
52  protected $_oPageNavigation = null;
53 
59  protected $_blShowSorting = true;
60 
67 
73  protected $_oVendorTree = null;
74 
85  public function render()
86  {
88 
89  // load vendor
90  if (($this->_getVendorId() && $this->getVendorTree())) {
91  if (($oVendor = $this->getActVendor())) {
92  if ($oVendor->getId() != 'root') {
93  // load the articles
94  $this->getArticleList();
95 
96  // checking if requested page is correct
97  $this->_checkRequestedPage();
98 
99  // processing list articles
100  $this->_processListArticles();
101  }
102  }
103  }
104 
105  return $this->_sThisTemplate;
106  }
107 
113  protected function _getProductLinkType()
114  {
116  }
117 
125  protected function _loadArticles($oVendor)
126  {
127  $sVendorId = $oVendor->getId();
128 
129  // load only articles which we show on screen
130  $iNrOfCatArticles = (int) $this->getConfig()->getConfigParam('iNrofCatArticles');
131  $iNrOfCatArticles = $iNrOfCatArticles ? $iNrOfCatArticles : 1;
132 
133  $oArtList = oxNew('oxArticleList');
134  $oArtList->setSqlLimit($iNrOfCatArticles * $this->_getRequestPageNr(), $iNrOfCatArticles);
135  $oArtList->setCustomSorting($this->getSortingSql($this->getSortIdent()));
136 
137  // load the articles
138  $this->_iAllArtCnt = $oArtList->loadVendorArticles($sVendorId, $oVendor);
139 
140  // counting pages
141  $this->_iCntPages = round($this->_iAllArtCnt / $iNrOfCatArticles + 0.49);
142 
143  return array($oArtList, $this->_iAllArtCnt);
144  }
145 
151  protected function _getSeoObjectId()
152  {
153  if (($oVendor = $this->getActVendor())) {
154  return $oVendor->getId();
155  }
156  }
157 
168  protected function _addPageNrParam($sUrl, $iPage, $iLang = null)
169  {
170  if (oxRegistry::getUtils()->seoIsActive() && ($oVendor = $this->getActVendor())) {
171  if ($iPage) {
172  // only if page number > 0
173  $sUrl = $oVendor->getBaseSeoLink($iLang, $iPage);
174  }
175  } else {
176  $sUrl = oxUBase::_addPageNrParam($sUrl, $iPage, $iLang);
177  }
178 
179  return $sUrl;
180  }
181 
187  public function generatePageNavigationUrl()
188  {
189  if ((oxRegistry::getUtils()->seoIsActive() && ($oVendor = $this->getActVendor()))) {
190  return $oVendor->getLink();
191  } else {
193  }
194  }
195 
201  public function hasVisibleSubCats()
202  {
203  if ($this->_blVisibleSubCats === null) {
204  $this->_blVisibleSubCats = false;
205  if (($this->_getVendorId() && $oVendorTree = $this->getVendorTree())) {
206  if (($oVendor = $this->getActVendor())) {
207  if ($oVendor->getId() == 'root') {
208  $this->_blVisibleSubCats = $oVendorTree->count();
209  $this->_oSubCatList = $oVendorTree;
210  }
211  }
212  }
213  }
214 
216  }
217 
223  public function getSubCatList()
224  {
225  if ($this->_oSubCatList === null) {
226  $this->_oSubCatList = array();
227  if ($this->hasVisibleSubCats()) {
228  return $this->_oSubCatList;
229  }
230  }
231 
232  return $this->_oSubCatList;
233  }
234 
240  public function getArticleList()
241  {
242  if ($this->_aArticleList === null) {
243  $this->_aArticleList = array();
244  if (($oVendor = $this->getActVendor()) && ($oVendor->getId() != 'root')) {
245  list($aArticleList, $iAllArtCnt) = $this->_loadArticles($oVendor);
246  if ($iAllArtCnt) {
247  $this->_aArticleList = $aArticleList;
248  }
249  }
250  }
251 
252  return $this->_aArticleList;
253  }
254 
260  public function getTitle()
261  {
262  if ($this->_sCatTitle === null) {
263  $this->_sCatTitle = '';
264  if ($oVendor = $this->getActVendor()) {
265  $this->_sCatTitle = $oVendor->oxvendor__oxtitle->value;
266  }
267  }
268 
269  return $this->_sCatTitle;
270  }
271 
277  public function getTreePath()
278  {
279  if ($this->_getVendorId() && $oVendorTree = $this->getVendorTree()) {
280  return $oVendorTree->getPath();
281  }
282  }
283 
289  protected function _getVendorId()
290  {
291  return oxRegistry::getConfig()->getRequestParameter('cnid');
292  }
293 
299  public function getActiveCategory()
300  {
301  if ($this->_oActCategory === null) {
302  $this->_oActCategory = false;
303  if (($this->_getVendorId() && $oVendorTree = $this->getVendorTree())) {
304  if ($oVendor = $this->getActVendor()) {
305  $this->_oActCategory = $oVendor;
306  }
307  }
308  }
309 
310  return $this->_oActCategory;
311  }
312 
318  public function getCatTreePath()
319  {
320  if ($this->_sCatTreePath === null) {
321  $this->_sCatTreePath = false;
322  if (($oVendorTree = $this->getVendorTree())) {
323  $this->_sCatTreePath = $oVendorTree->getPath();
324  }
325  }
326 
327  return $this->_sCatTreePath;
328  }
329 
335  public function getTitleSuffix()
336  {
337  if ($this->getActVendor()->oxvendor__oxshowsuffix->value) {
338  return $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
339  }
340  }
341 
351  protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
352  {
353  return parent::_collectMetaKeyword($sKeywords);
354  }
355 
366  protected function _prepareMetaDescription($sMeta, $iLength = 1024, $blDescTag = false)
367  {
368  return parent::_collectMetaDescription($sMeta, $iLength, $blDescTag);
369  }
370 
379  protected function _getSubject($iLang)
380  {
381  return $this->getActVendor();
382  }
383 
389  public function getAddUrlParams()
390  {
391  $sAddParams = parent::getAddUrlParams();
392  $sAddParams .= ($sAddParams ? '&amp;' : '') . "listtype={$this->_sListType}";
393  if ($oVendor = $this->getActVendor()) {
394  $sAddParams .= "&amp;cnid=v_" . $oVendor->getId();
395  }
396 
397  return $sAddParams;
398  }
399 
405  public function getBreadCrumb()
406  {
407  $aPaths = array();
408  $oCatTree = $this->getVendorTree();
409 
410  if ($oCatTree) {
411  foreach ($oCatTree->getPath() as $oCat) {
412  $aCatPath = array();
413 
414  $aCatPath['link'] = $oCat->getLink();
415  $aCatPath['title'] = $oCat->oxcategories__oxtitle->value;
416 
417  $aPaths[] = $aCatPath;
418  }
419  }
420 
421  return $aPaths;
422  }
423 
424 
430  public function getVendorTree()
431  {
432  if ($this->_getVendorId() && $this->_oVendorTree === null) {
434  $oVendorTree = oxNew('oxVendorList');
435  $oVendorTree->buildVendorTree(
436  'vendorlist',
437  $this->getActVendor()->getId(),
438  $this->getConfig()->getShopHomeURL()
439  );
440  $this->_oVendorTree = $oVendorTree;
441  }
442 
443  return $this->_oVendorTree;
444  }
445 
451  public function setVendorTree($oVendorTree)
452  {
453  $this->_oVendorTree = $oVendorTree;
454  }
455 
462  public function getAttributes()
463  {
464  return null;
465  }
466 }