OXID eShop CE  4.8.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 {
15  protected $_oRoot = null;
16 
22  protected $_aPath = array();
23 
29  protected $_blShowVendorArticleCnt = false;
30 
36  protected $_oClickedVendor = null;
37 
46  public function __construct( $sObjectsInListName = 'oxvendor')
47  {
48  $this->setShowVendorArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
49  parent::__construct( 'oxvendor');
50  }
51 
59  public function setShowVendorArticleCnt( $blShowVendorArticleCnt = false )
60  {
61  $this->_blShowVendorArticleCnt = $blShowVendorArticleCnt;
62  }
63 
69  public function loadVendorList()
70  {
71  $oBaseObject = $this->getBaseObject();
72  $sFieldList = $oBaseObject->getSelectFields();
73  $sViewName = $oBaseObject->getViewName();
74  $this->getBaseObject()->setShowArticleCnt( $this->_blShowVendorArticleCnt );
75 
76  $sWhere = '';
77  if ( !$this->isAdmin() ) {
78  $sWhere = $oBaseObject->getSqlActiveSnippet();
79  $sWhere = $sWhere?" where $sWhere and ":' where ';
80  $sWhere .= "{$sViewName}.oxtitle != '' ";
81  }
82 
83  $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
84  $this->selectString( $sSelect );
85  }
86 
96  public function buildVendorTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
97  {
98  $sActCat = str_replace( 'v_', '', $sActCat );
99 
100  //Load vendor list
101  $this->loadVendorList();
102 
103 
104  //Create fake vendor root category
105  $this->_oRoot = oxNew( "oxVendor" );
106  $this->_oRoot->load( 'root' );
107 
108  //category fields
109  $this->_addCategoryFields( $this->_oRoot );
110  $this->_aPath[] = $this->_oRoot;
111 
112  foreach ( $this as $sVndId => $oVendor ) {
113 
114  // storing active vendor object
115  if ( $sVndId == $sActCat ) {
116  $this->setClickVendor( $oVendor );
117  }
118 
119  $this->_addCategoryFields( $oVendor );
120  if ( $sActCat == $oVendor->oxvendor__oxid->value ) {
121  $this->_aPath[] = $oVendor;
122  }
123  }
124 
125  $this->_seoSetVendorData();
126  }
127 
133  public function getRootCat()
134  {
135  return $this->_oRoot;
136  }
137 
143  public function getPath()
144  {
145  return $this->_aPath;
146  }
147 
155  protected function _addCategoryFields( $oVendor )
156  {
157  $oVendor->oxcategories__oxid = new oxField("v_".$oVendor->oxvendor__oxid->value);
158  $oVendor->oxcategories__oxicon = $oVendor->oxvendor__oxicon;
159  $oVendor->oxcategories__oxtitle = $oVendor->oxvendor__oxtitle;
160  $oVendor->oxcategories__oxdesc = $oVendor->oxvendor__oxshortdesc;
161 
162  $oVendor->setIsVisible( true );
163  $oVendor->setHasVisibleSubCats( false );
164  }
165 
173  public function setClickVendor( $oVendor )
174  {
175  $this->_oClickedVendor = $oVendor;
176  }
177 
183  public function getClickVendor()
184  {
185  return $this->_oClickedVendor;
186  }
187 
193  protected function _seoSetVendorData()
194  {
195  // only when SEO id on and in front end
196  if ( oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
197 
198  $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
199 
200  // preparing root vendor category
201  if ($this->_oRoot) {
202  $oEncoder->getVendorUrl($this->_oRoot);
203  }
204 
205  // encoding vendor category
206  foreach ($this as $sVndId => $value) {
207  $oEncoder->getVendorUrl( $this->_aArray[$sVndId] );
208  }
209  }
210  }
211 }