OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
manufacturerlist.php
Go to the documentation of this file.
1 <?php
2 
9 class ManufacturerList extends aList
10 {
15  protected $_sListType = 'manufacturer';
16 
21  protected $_blVisibleSubCats = null;
22 
27  protected $_oSubCatList = null;
28 
33  protected $_oRecommList = null;
34 
40  protected $_sTplLocation = null;
41 
47  protected $_sCatTitle = null;
48 
53  protected $_oPageNavigation = null;
54 
59  protected $_blShowSorting = true;
60 
67 
78  public function render()
79  {
81 
82  // load Manufacturer
83  if ( $this->getManufacturerTree() ) {
84  if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
85  if ( $oManufacturer->getId() != 'root' ) {
86  // load the articles
87  $this->getArticleList();
88 
89  // checking if requested page is correct
90  $this->_checkRequestedPage();
91 
92  // processing list articles
93  $this->_processListArticles();
94  }
95  }
96  }
97 
98  return $this->_sThisTemplate;
99  }
100 
106  protected function _getProductLinkType()
107  {
109  }
110 
122  public function setItemSorting( $sCnid, $sSortBy, $sSortDir = null )
123  {
124  parent::setItemSorting( $sCnid, $sSortBy, $sSortDir );
125  }
126 
136  public function getSorting( $sCnid )
137  {
138  return parent::getSorting( $sCnid );
139  }
140 
148  protected function _loadArticles( $oManufacturer )
149  {
150  $sManufacturerId = $oManufacturer->getId();
151 
152  // load only articles which we show on screen
153  $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
154  $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 1;
155 
156  $oArtList = oxNew( 'oxarticlelist' );
157  $oArtList->setSqlLimit( $iNrofCatArticles * $this->_getRequestPageNr(), $iNrofCatArticles );
158  $oArtList->setCustomSorting( $this->getSortingSql( $this->getSortIdent() ) );
159 
160  // load the articles
161  $this->_iAllArtCnt = $oArtList->loadManufacturerArticles( $sManufacturerId, $oManufacturer );
162 
163  // counting pages
164  $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
165 
166  return array( $oArtList, $this->_iAllArtCnt );
167  }
168 
174  protected function _getSeoObjectId()
175  {
176  $sId = null;
177  if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
178  $sId = $oManufacturer->getId();
179  }
180  return $sId;
181  }
182 
193  protected function _addPageNrParam( $sUrl, $iPage, $iLang = null)
194  {
195  if ( oxRegistry::getUtils()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) {
196  if ( $iPage ) {
197  // only if page number > 0
198  $sUrl = $oManufacturer->getBaseSeoLink( $iLang, $iPage );
199  }
200  } else {
201  $sUrl = parent::_addPageNrParam( $sUrl, $iPage, $iLang );
202  }
203  return $sUrl;
204  }
205 
211  public function generatePageNavigationUrl()
212  {
213  if ( ( oxRegistry::getUtils()->seoIsActive() && ( $oManufacturer = $this->getActManufacturer() ) ) ) {
214  return $oManufacturer->getLink();
215  } else {
217  }
218  }
219 
225  public function hasVisibleSubCats()
226  {
227  if ( $this->_blVisibleSubCats === null ) {
228  $this->_blVisibleSubCats = false;
229  if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
230  if ( ( $oManufacturer = $this->getActManufacturer() ) ) {
231  if ( $oManufacturer->getId() == 'root' ) {
232  $this->_blVisibleSubCats = $oManufacturerTree->count();
233  $this->_oSubCatList = $oManufacturerTree;
234  }
235  }
236  }
237  }
239  }
240 
246  public function getSubCatList()
247  {
248  if ( $this->_oSubCatList === null ) {
249  $this->_oSubCatList = $this->hasVisibleSubCats() ? $this->_oSubCatList : array();
250  }
251  return $this->_oSubCatList;
252  }
253 
259  public function getArticleList()
260  {
261  if ( $this->_aArticleList === null ) {
262  $this->_aArticleList = array();
263  if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
264  if ( ( $oManufacturer = $this->getActManufacturer() ) && ( $oManufacturer->getId() != 'root' ) && $oManufacturer->getIsVisible() ) {
265  list( $aArticleList, $iAllArtCnt ) = $this->_loadArticles( $oManufacturer );
266  if ( $iAllArtCnt ) {
267  $this->_aArticleList = $aArticleList;
268  }
269  }
270  }
271  }
272  return $this->_aArticleList;
273  }
274 
280  public function getTitle()
281  {
282  if ( $this->_sCatTitle === null ) {
283  $this->_sCatTitle = '';
284  if ( $oManufacturerTree = $this->getManufacturerTree() ) {
285  if ( $oManufacturer = $this->getActManufacturer() ) {
286  $this->_sCatTitle = $oManufacturer->oxmanufacturers__oxtitle->value;
287  }
288  }
289  }
290  return $this->_sCatTitle;
291  }
292 
298  public function getTreePath()
299  {
300  $aPath = null;
301  if ( $oManufacturerTree = $this->getManufacturerTree() ) {
302  $aPath = $oManufacturerTree->getPath();
303  }
304  return $aPath;
305  }
306 
312  public function getActiveCategory()
313  {
314  if ( $this->_oActCategory === null ) {
315  $this->_oActCategory = false;
316  if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
317  if ( $oManufacturer = $this->getActManufacturer() ) {
318  $this->_oActCategory = $oManufacturer;
319  }
320  }
321  }
322  return $this->_oActCategory;
323  }
324 
330  public function getCatTreePath()
331  {
332  if ( $this->_sCatTreePath === null ) {
333  $this->_sCatTreePath = false;
334  if ( ( $oManufacturerTree = $this->getManufacturerTree() ) ) {
335  $this->_sCatTreePath = $oManufacturerTree->getPath();
336  }
337  }
338  return $this->_sCatTreePath;
339  }
340 
346  public function getTitleSuffix()
347  {
348  $sSuffix = null;
349  if ( $this->getActManufacturer()->oxmanufacturers__oxshowsuffix->value ) {
350  $sSuffix = $this->getConfig()->getActiveShop()->oxshops__oxtitlesuffix->value;
351  }
352  return $sSuffix;
353  }
354 
363  protected function _prepareMetaKeyword( $aCatPath, $blRemoveDuplicatedWords = true )
364  {
365  return parent::_collectMetaKeyword( $aCatPath );
366  }
367 
380  protected function _prepareMetaDescription( $aCatPath, $iLength = 1024, $blDescTag = false )
381  {
382  return parent::_collectMetaDescription( $aCatPath, $iLength, $blDescTag );
383  }
384 
393  protected function _getSubject( $iLang )
394  {
395  return $this->getActManufacturer();
396  }
397 
403  public function getAddUrlParams()
404  {
405  $sAddParams = parent::getAddUrlParams();
406  $sAddParams .= ($sAddParams?'&amp;':'') . "listtype={$this->_sListType}";
407  if ( $oManufacturer = $this->getActManufacturer() ) {
408  $sAddParams .= "&amp;mnid=" . $oManufacturer->getId();
409  }
410  return $sAddParams;
411  }
412 
418  public function getBreadCrumb()
419  {
420  $aPaths = array();
421 
422  $oCatTree = $this->getManufacturerTree();
423 
424  if ( $oCatTree ) {
425  foreach ( $oCatTree->getPath() as $oCat ) {
426  $aCatPath = array();
427  $aCatPath['link'] = $oCat->getLink();
428  $aCatPath['title'] = $oCat->oxmanufacturers__oxtitle->value;
429 
430  $aPaths[] = $aCatPath;
431  }
432  }
433 
434  return $aPaths;
435  }
436 
443  public function getAttributes()
444  {
445  return null;
446  }
447 }