Go to the documentation of this file.00001 <?php
00002
00007 class oxSimpleVariant extends oxI18n implements oxIUrl
00008 {
00014 protected $_blUseLazyLoading = true;
00015
00021 protected $_oPrice = null;
00022
00028 protected $_oParent = null;
00029
00035 protected $_aStdUrls = array();
00036
00042 protected $_aBaseStdUrls = array();
00043
00049 protected $_aSeoUrls = array();
00050
00055 protected $_oUser = null;
00056
00061 public function __construct()
00062 {
00063 parent::__construct();
00064 $this->_sCacheKey = "simplevariants";
00065 $this->init( 'oxarticles' );
00066 }
00067
00075 public function __get($sName)
00076 {
00077 $myUtils = oxUtils::getInstance();
00078 switch ($sName) {
00079 case 'aSelectlist' :
00080 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00081 return $this->aSelectlist = $this->getSelectLists();
00082 }
00083 return;
00084 break;
00085 }
00086
00087 return parent::__get($sName);
00088 }
00089
00098 public function assign( $aRecord)
00099 {
00100
00101 parent::assign( $aRecord);
00102
00103 }
00104
00105
00117 protected function _setLongDesc($sDbValue)
00118 {
00119 }
00120
00127 public function getSelectLists()
00128 {
00129 return null;
00130 }
00131
00137 public function getArticleUser()
00138 {
00139 if ( $this->_oUser === null ) {
00140 $this->_oUser = $this->getUser();
00141 }
00142 return $this->_oUser;
00143 }
00144
00150 protected function _getGroupPrice()
00151 {
00152 $dPrice = $this->oxarticles__oxprice->value;
00153 if ( $oUser = $this->getArticleUser() ) {
00154 if ( $oUser->inGroup( 'oxidpricea' ) ) {
00155 $dPrice = $this->oxarticles__oxpricea->value;
00156 } elseif ( $oUser->inGroup( 'oxidpriceb' ) ) {
00157 $dPrice = $this->oxarticles__oxpriceb->value;
00158 } elseif ( $oUser->inGroup( 'oxidpricec' ) ) {
00159 $dPrice = $this->oxarticles__oxpricec->value;
00160 }
00161 }
00162
00163
00164 if ( $this->getConfig()->getConfigParam( 'blOverrideZeroABCPrices' ) && (double) $dPrice == 0 ) {
00165 $dPrice = $this->oxarticles__oxprice->value;
00166 }
00167
00168 return $dPrice;
00169 }
00170
00171
00177 public function getPrice()
00178 {
00179 $myConfig = $this->getConfig();
00180
00181 if ( !$myConfig->getConfigParam( 'bl_perfLoadPrice' ) ) {
00182 return;
00183 }
00184
00185 if ( $this->_oPrice === null ) {
00186 $this->_oPrice = oxNew( "oxPrice" );
00187 if ( ( $dPrice = $this->_getGroupPrice() ) ) {
00188 $this->_oPrice->setPrice( $dPrice, $this->_dVat );
00189
00190 $this->_applyParentVat( $this->_oPrice );
00191 $this->_applyCurrency( $this->_oPrice );
00192
00193 $this->_applyParentDiscounts($this->_oPrice);
00194 } elseif ( ( $oParent = $this->getParent() ) ) {
00195 $this->_oPrice = $oParent->getPrice();
00196 }
00197 }
00198
00199 return $this->_oPrice;
00200 }
00201
00210 protected function _applyCurrency(oxPrice $oPrice, $oCur = null )
00211 {
00212 if ( !$oCur ) {
00213 $oCur = $this->getConfig()->getActShopCurrencyObject();
00214 }
00215
00216 $oPrice->multiply($oCur->rate);
00217 }
00218
00226 protected function _applyParentDiscounts( $oPrice )
00227 {
00228 if ( ( $oParent = $this->getParent() ) ) {
00229 $oParent->applyDiscountsForVariant( $oPrice );
00230 }
00231 }
00232
00240 protected function _applyParentVat( $oPrice )
00241 {
00242 if ( ( $oParent = $this->getParent() ) && !$this->getConfig()->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
00243 $oParent->applyVats($oPrice);
00244 }
00245 }
00246
00254 public function setPrice($oPrice)
00255 {
00256 $this->_oPrice = $oPrice;
00257 }
00258
00264 public function getFPrice()
00265 {
00266 $sPrice = null;
00267 if ( ( $oPrice = $this->getPrice() ) ) {
00268 $sPrice = oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00269 }
00270 return $sPrice;
00271 }
00272
00280 public function setParent($oParent)
00281 {
00282 $this->_oParent = $oParent;
00283 }
00284
00290 public function getParent()
00291 {
00292 return $this->_oParent;
00293 }
00294
00300 public function getLinkType()
00301 {
00302 $iLinkType = 0;
00303 if ( ( $oParent = $this->getParent() ) ) {
00304 $iLinkType = $oParent->getLinkType();
00305 }
00306 return $iLinkType;
00307 }
00308
00316 public function inCategory( $sCatNid )
00317 {
00318 $blIn = false;
00319 if ( ( $oParent = $this->getParent() ) ) {
00320 $blIn = $oParent->inCategory( $sCatNid );
00321 }
00322 return $blIn;
00323 }
00324
00332 public function inPriceCategory( $sCatNid )
00333 {
00334 $blIn = false;
00335 if ( ( $oParent = $this->getParent() ) ) {
00336 $blIn = $oParent->inPriceCategory( $sCatNid );
00337 }
00338 return $blIn;
00339 }
00340
00350 public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00351 {
00352 if ( !isset( $this->_aBaseStdUrls[$iLang][$iLinkType] ) ) {
00353 $oArticle = oxNew( "oxArticle" );
00354 $oArticle->setId( $this->getId() );
00355 $oArticle->setLinkType( $iLinkType );
00356 $this->_aBaseStdUrls[$iLang][$iLinkType] = $oArticle->getBaseStdLink( $iLang, $blAddId, $blFull );
00357 }
00358
00359 return $this->_aBaseStdUrls[$iLang][$iLinkType];
00360 }
00361
00370 public function getStdLink( $iLang = null, $aParams = array() )
00371 {
00372 if ( $iLang === null ) {
00373 $iLang = (int) $this->getLanguage();
00374 }
00375
00376 $iLinkType = $this->getLinkType();
00377 if ( !isset( $this->_aStdUrls[$iLang][$iLinkType] ) ) {
00378 $oArticle = oxNew( "oxArticle" );
00379 $oArticle->setId( $this->getId() );
00380 $oArticle->setLinkType( $iLinkType );
00381 $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink( $iLang, $aParams );
00382 }
00383
00384 return $this->_aStdUrls[$iLang][$iLinkType];
00385 }
00386
00394 public function getBaseSeoLink( $iLang )
00395 {
00396 return oxSeoEncoderArticle::getInstance()->getArticleUrl( $this, $iLang, $iLinkType );
00397 }
00398
00406 public function getLink( $iLang = null )
00407 {
00408 if ( $iLang === null ) {
00409 $iLang = (int) $this->getLanguage();
00410 }
00411
00412 if ( !oxUtils::getInstance()->seoIsActive() ) {
00413 return $this->getStdLink( $iLang );
00414 }
00415
00416 $iLinkType = $this->getLinkType();
00417 if ( !isset( $this->_aSeoUrls[$iLang][$iLinkType] ) ) {
00418 $this->_aSeoUrls[$iLang][$iLinkType] = $this->getBaseSeoLink( $iLang );
00419 }
00420 return $this->_aSeoUrls[$iLang][$iLinkType];
00421
00422 }
00423 }