oxvendorlist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxVendorList extends oxList
00009 {
00015     protected $_oRoot = null;
00016 
00022     protected $_aPath = array();
00023 
00029     protected $_blShowVendorArticleCnt = false;
00030 
00036     protected $_oClickedVendor = null;
00037 
00046     public function __construct( $sObjectsInListName = 'oxvendor')
00047     {
00048         $this->setShowVendorArticleCnt( $this->getConfig()->getConfigParam( 'bl_perfShowActionCatArticleCnt' ) );
00049         parent::__construct( 'oxvendor');
00050     }
00051 
00059     public function setShowVendorArticleCnt( $blShowVendorArticleCnt = false )
00060     {
00061         $this->_blShowVendorArticleCnt = $blShowVendorArticleCnt;
00062     }
00063 
00069     public function loadVendorList()
00070     {
00071         $oBaseObject = $this->getBaseObject();
00072         $sFieldList = $oBaseObject->getSelectFields();
00073         $sViewName  = $oBaseObject->getViewName();
00074         $this->getBaseObject()->setShowArticleCnt( $this->_blShowVendorArticleCnt );
00075 
00076         $sWhere = '';
00077         if ( !$this->isAdmin() ) {
00078             $sWhere  = $oBaseObject->getSqlActiveSnippet();
00079             $sWhere  = $sWhere?" where $sWhere and ":' where ';
00080             $sWhere .= "{$sViewName}.oxtitle != '' ";
00081         }
00082 
00083         $sSelect = "select {$sFieldList} from {$sViewName} {$sWhere} order by {$sViewName}.oxtitle";
00084         $this->selectString( $sSelect );
00085     }
00086 
00096     public function buildVendorTree( $sLinkTarget, $sActCat, $sShopHomeUrl )
00097     {
00098         $sActCat = str_replace( 'v_', '', $sActCat );
00099 
00100         //Load vendor list
00101         $this->loadVendorList();
00102 
00103 
00104         //Create fake vendor root category
00105         $this->_oRoot = oxNew( "oxVendor" );
00106         $this->_oRoot->load( 'root' );
00107 
00108         //category fields
00109         $this->_addCategoryFields( $this->_oRoot );
00110         $this->_aPath[] = $this->_oRoot;
00111 
00112         foreach ( $this as $sVndId => $oVendor ) {
00113 
00114             // storing active vendor object
00115             if ( $sVndId == $sActCat ) {
00116                 $this->setClickVendor( $oVendor );
00117             }
00118 
00119             $this->_addCategoryFields( $oVendor );
00120             if ( $sActCat == $oVendor->oxvendor__oxid->value ) {
00121                 $this->_aPath[] = $oVendor;
00122             }
00123         }
00124 
00125         $this->_seoSetVendorData();
00126     }
00127 
00133     public function getRootCat()
00134     {
00135         return $this->_oRoot;
00136     }
00137 
00143     public function getPath()
00144     {
00145         return $this->_aPath;
00146     }
00147 
00155     protected function _addCategoryFields( $oVendor )
00156     {
00157         $oVendor->oxcategories__oxid    = new oxField("v_".$oVendor->oxvendor__oxid->value);
00158         $oVendor->oxcategories__oxicon  = $oVendor->oxvendor__oxicon;
00159         $oVendor->oxcategories__oxtitle = $oVendor->oxvendor__oxtitle;
00160         $oVendor->oxcategories__oxdesc  = $oVendor->oxvendor__oxshortdesc;
00161 
00162         $oVendor->setIsVisible( true );
00163         $oVendor->setHasVisibleSubCats( false );
00164     }
00165 
00173     public function setClickVendor( $oVendor )
00174     {
00175         $this->_oClickedVendor = $oVendor;
00176     }
00177 
00183     public function getClickVendor()
00184     {
00185         return $this->_oClickedVendor;
00186     }
00187 
00193     protected function _seoSetVendorData()
00194     {
00195         // only when SEO id on and in front end
00196         if ( oxRegistry::getUtils()->seoIsActive() && !$this->isAdmin()) {
00197 
00198             $oEncoder = oxRegistry::get("oxSeoEncoderVendor");
00199 
00200             // preparing root vendor category
00201             if ($this->_oRoot) {
00202                 $oEncoder->getVendorUrl($this->_oRoot);
00203             }
00204 
00205             // encoding vendor category
00206             foreach ($this as $sVndId => $value) {
00207                 $oEncoder->getVendorUrl( $this->_aArray[$sVndId] );
00208             }
00209         }
00210     }
00211 }