OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxmanufacturerlist.php
Go to the documentation of this file.
1 <?php
2 
9 {
15  protected $_oRoot = null;
16 
22  protected $_aPath = array();
23 
29  protected $_blShowManufacturerArticleCnt = false;
30 
36  protected $_oClickedManufacturer = null;
37 
46  public function __construct( $sObjectsInListName = 'oxmanufacturer')
47  {
48  $this->setShowManufacturerArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
49  parent::__construct( 'oxmanufacturer');
50  }
51 
59  public function setShowManufacturerArticleCnt( $blShowManufacturerArticleCnt = false )
60  {
61  $this->_blShowManufacturerArticleCnt = $blShowManufacturerArticleCnt;
62  }
63 
69  public function loadManufacturerList()
70  {
71  $oBaseObject = $this->getBaseObject();
72 
73  $sFieldList = $oBaseObject->getSelectFields();
74  $sViewName = $oBaseObject->getViewName();
75  $this->getBaseObject()->setShowArticleCnt( $this->_blShowManufacturerArticleCnt );
76 
77  $sWhere = '';
78  if ( !$this->isAdmin() ) {
79  $sWhere = $oBaseObject->getSqlActiveSnippet();
80  $sWhere = $sWhere?" where $sWhere and ":' where ';
81  $sWhere .= "{$sViewName}.oxtitle != '' ";
82  }
83 
84  $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
85  $this->selectString( $sSelect );
86  }
87 
97  public function buildManufacturerTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
98  {
99  //Load manufacturer list
100  $this->loadManufacturerList();
101 
102 
103  //Create fake manufacturer root category
104  $this->_oRoot = oxNew( "oxManufacturer" );
105  $this->_oRoot->load( "root" );
106 
107  //category fields
108  $this->_addCategoryFields( $this->_oRoot );
109  $this->_aPath[] = $this->_oRoot;
110 
111  foreach ( $this as $sVndId => $oManufacturer ) {
112 
113  // storing active manufacturer object
114  if ( $sVndId == $sActCat ) {
115  $this->setClickManufacturer( $oManufacturer );
116  }
117 
118  $this->_addCategoryFields( $oManufacturer );
119  if ( $sActCat == $oManufacturer->oxmanufacturers__oxid->value ) {
120  $this->_aPath[] = $oManufacturer;
121  }
122  }
123 
124  $this->_seoSetManufacturerData();
125  }
126 
132  public function getRootCat()
133  {
134  return $this->_oRoot;
135  }
136 
142  public function getPath()
143  {
144  return $this->_aPath;
145  }
146 
154  protected function _addCategoryFields( $oManufacturer )
155  {
156  $oManufacturer->oxcategories__oxid = new oxField( $oManufacturer->oxmanufacturers__oxid->value );
157  $oManufacturer->oxcategories__oxicon = $oManufacturer->oxmanufacturers__oxicon;
158  $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
159  $oManufacturer->oxcategories__oxdesc = $oManufacturer->oxmanufacturers__oxshortdesc;
160 
161  $oManufacturer->setIsVisible( true );
162  $oManufacturer->setHasVisibleSubCats( false );
163  }
164 
172  public function setClickManufacturer( $oManufacturer )
173  {
174  $this->_oClickedManufacturer = $oManufacturer;
175  }
176 
182  public function getClickManufacturer()
183  {
185  }
186 
192  protected function _seoSetManufacturerData()
193  {
194  // only when SEO id on and in front end
195  if ( oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
196 
197  $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
198 
199  // preparing root manufacturer category
200  if ($this->_oRoot) {
201  $oEncoder->getManufacturerUrl($this->_oRoot);
202  }
203 
204  // encoding manufacturer category
205  foreach ($this as $sVndId => $value) {
206  $oEncoder->getManufacturerUrl( $this->_aArray[$sVndId] );
207  }
208  }
209  }
210 }