OXID eShop CE  4.9.10
 All Classes Files Functions Variables Pages
oxvendorlist.php
Go to the documentation of this file.
1 <?php
2 
8 class oxVendorList extends oxList
9 {
10 
16  protected $_oRoot = null;
17 
23  protected $_aPath = array();
24 
30  protected $_blShowVendorArticleCnt = false;
31 
37  protected $_oClickedVendor = null;
38 
44  public function __construct()
45  {
46  $this->setShowVendorArticleCnt($this->getConfig()->getConfigParam('bl_perfShowActionCatArticleCnt'));
47  parent::__construct('oxvendor');
48  }
49 
55  public function setShowVendorArticleCnt($blShowVendorArticleCnt = false)
56  {
57  $this->_blShowVendorArticleCnt = $blShowVendorArticleCnt;
58  }
59 
63  public function loadVendorList()
64  {
65  $oBaseObject = $this->getBaseObject();
66  $sFieldList = $oBaseObject->getSelectFields();
67  $sViewName = $oBaseObject->getViewName();
68  $this->getBaseObject()->setShowArticleCnt($this->_blShowVendorArticleCnt);
69 
70  $sWhere = '';
71  if (!$this->isAdmin()) {
72  $sWhere = $oBaseObject->getSqlActiveSnippet();
73  $sWhere = $sWhere ? " where $sWhere and " : ' where ';
74  $sWhere .= "{$sViewName}.oxtitle != '' ";
75  }
76 
77  $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
78  $this->selectString($sSelect);
79  }
80 
88  public function buildVendorTree($sLinkTarget, $sActCat, $sShopHomeUrl)
89  {
90  $sActCat = str_replace('v_', '', $sActCat);
91 
92  //Load vendor list
93  $this->loadVendorList();
94 
95 
96  //Create fake vendor root category
97  $this->_oRoot = oxNew("oxVendor");
98  $this->_oRoot->load('root');
99 
100  //category fields
101  $this->_addCategoryFields($this->_oRoot);
102  $this->_aPath[] = $this->_oRoot;
103 
104  foreach ($this as $sVndId => $oVendor) {
105 
106  // storing active vendor object
107  if ($sVndId == $sActCat) {
108  $this->setClickVendor($oVendor);
109  }
110 
111  $this->_addCategoryFields($oVendor);
112  if ($sActCat == $oVendor->oxvendor__oxid->value) {
113  $this->_aPath[] = $oVendor;
114  }
115  }
116 
117  $this->_seoSetVendorData();
118  }
119 
125  public function getRootCat()
126  {
127  return $this->_oRoot;
128  }
129 
135  public function getPath()
136  {
137  return $this->_aPath;
138  }
139 
145  protected function _addCategoryFields($oVendor)
146  {
147  $oVendor->oxcategories__oxid = new oxField("v_" . $oVendor->oxvendor__oxid->value);
148  $oVendor->oxcategories__oxicon = $oVendor->oxvendor__oxicon;
149  $oVendor->oxcategories__oxtitle = $oVendor->oxvendor__oxtitle;
150  $oVendor->oxcategories__oxdesc = $oVendor->oxvendor__oxshortdesc;
151 
152  $oVendor->setIsVisible(true);
153  $oVendor->setHasVisibleSubCats(false);
154  }
155 
161  public function setClickVendor($oVendor)
162  {
163  $this->_oClickedVendor = $oVendor;
164  }
165 
171  public function getClickVendor()
172  {
173  return $this->_oClickedVendor;
174  }
175 
179  protected function _seoSetVendorData()
180  {
181  // only when SEO id on and in front end
182  if (oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
183 
184  $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
185 
186  // preparing root vendor category
187  if ($this->_oRoot) {
188  $oEncoder->getVendorUrl($this->_oRoot);
189  }
190 
191  // encoding vendor category
192  foreach ($this as $sVndId => $value) {
193  $oEncoder->getVendorUrl($this->_aArray[$sVndId]);
194  }
195  }
196  }
197 }