OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
oxmanufacturerlist.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
16  protected $_oRoot = null;
17 
23  protected $_aPath = array();
24 
30  protected $_blShowManufacturerArticleCnt = false;
31 
37  protected $_oClickedManufacturer = null;
38 
44  public function __construct()
45  {
46  $this->setShowManufacturerArticleCnt($this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt'));
47  parent::__construct('oxmanufacturer');
48  }
49 
55  public function setShowManufacturerArticleCnt($blShowManufacturerArticleCnt = false)
56  {
57  $this->_blShowManufacturerArticleCnt = $blShowManufacturerArticleCnt;
58  }
59 
63  public function loadManufacturerList()
64  {
65  $oBaseObject = $this->getBaseObject();
66 
67  $sFieldList = $oBaseObject->getSelectFields();
68  $sViewName = $oBaseObject->getViewName();
69  $this->getBaseObject()->setShowArticleCnt($this->_blShowManufacturerArticleCnt);
70 
71  $sWhere = '';
72  if (!$this->isAdmin()) {
73  $sWhere = $oBaseObject->getSqlActiveSnippet();
74  $sWhere = $sWhere ? " where $sWhere and " : ' where ';
75  $sWhere .= "{$sViewName}.oxtitle != '' ";
76  }
77 
78  $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
79  $this->selectString($sSelect);
80  }
81 
89  public function buildManufacturerTree($sLinkTarget, $sActCat, $sShopHomeUrl)
90  {
91  //Load manufacturer list
92  $this->loadManufacturerList();
93 
94 
95  //Create fake manufacturer root category
96  $this->_oRoot = oxNew("oxManufacturer");
97  $this->_oRoot->load("root");
98 
99  //category fields
100  $this->_addCategoryFields($this->_oRoot);
101  $this->_aPath[] = $this->_oRoot;
102 
103  foreach ($this as $sVndId => $oManufacturer) {
104 
105  // storing active manufacturer object
106  if ($sVndId == $sActCat) {
107  $this->setClickManufacturer($oManufacturer);
108  }
109 
110  $this->_addCategoryFields($oManufacturer);
111  if ($sActCat == $oManufacturer->oxmanufacturers__oxid->value) {
112  $this->_aPath[] = $oManufacturer;
113  }
114  }
115 
116  $this->_seoSetManufacturerData();
117  }
118 
124  public function getRootCat()
125  {
126  return $this->_oRoot;
127  }
128 
134  public function getPath()
135  {
136  return $this->_aPath;
137  }
138 
144  protected function _addCategoryFields($oManufacturer)
145  {
146  $oManufacturer->oxcategories__oxid = new oxField($oManufacturer->oxmanufacturers__oxid->value);
147  $oManufacturer->oxcategories__oxicon = $oManufacturer->oxmanufacturers__oxicon;
148  $oManufacturer->oxcategories__oxtitle = $oManufacturer->oxmanufacturers__oxtitle;
149  $oManufacturer->oxcategories__oxdesc = $oManufacturer->oxmanufacturers__oxshortdesc;
150 
151  $oManufacturer->setIsVisible(true);
152  $oManufacturer->setHasVisibleSubCats(false);
153  }
154 
160  public function setClickManufacturer($oManufacturer)
161  {
162  $this->_oClickedManufacturer = $oManufacturer;
163  }
164 
170  public function getClickManufacturer()
171  {
173  }
174 
178  protected function _seoSetManufacturerData()
179  {
180  // only when SEO id on and in front end
181  if (oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
182 
183  $oEncoder = oxRegistry::get("oxSeoEncoderManufacturer");
184 
185  // preparing root manufacturer category
186  if ($this->_oRoot) {
187  $oEncoder->getManufacturerUrl($this->_oRoot);
188  }
189 
190  // encoding manufacturer category
191  foreach ($this as $sVndId => $value) {
192  $oEncoder->getManufacturerUrl($this->_aArray[$sVndId]);
193  }
194  }
195  }
196 }