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
00076 public function assign( $aRecord)
00077 {
00078
00079 parent::assign( $aRecord);
00080
00081 }
00082
00083
00090 public function getSelectLists()
00091 {
00092 return null;
00093 }
00094
00100 public function getArticleUser()
00101 {
00102 if ( $this->_oUser === null ) {
00103 $this->_oUser = $this->getUser();
00104 }
00105 return $this->_oUser;
00106 }
00107
00113 protected function _getGroupPrice()
00114 {
00115 $dPrice = $this->oxarticles__oxprice->value;
00116 if ( $oUser = $this->getArticleUser() ) {
00117 if ( $oUser->inGroup( 'oxidpricea' ) ) {
00118 $dPrice = $this->oxarticles__oxpricea->value;
00119 } elseif ( $oUser->inGroup( 'oxidpriceb' ) ) {
00120 $dPrice = $this->oxarticles__oxpriceb->value;
00121 } elseif ( $oUser->inGroup( 'oxidpricec' ) ) {
00122 $dPrice = $this->oxarticles__oxpricec->value;
00123 }
00124 }
00125
00126
00127 if ( $this->getConfig()->getConfigParam( 'blOverrideZeroABCPrices' ) && (double) $dPrice == 0 ) {
00128 $dPrice = $this->oxarticles__oxprice->value;
00129 }
00130
00131 return $dPrice;
00132 }
00133
00134
00140 public function getPrice()
00141 {
00142 $myConfig = $this->getConfig();
00143
00144 if ( !$myConfig->getConfigParam( 'bl_perfLoadPrice' ) ) {
00145 return;
00146 }
00147
00148 if ( $this->_oPrice === null ) {
00149 $this->_oPrice = oxNew( "oxPrice" );
00150 if ( ( $dPrice = $this->_getGroupPrice() ) ) {
00151 $this->_oPrice->setPrice( $dPrice, $this->_dVat );
00152
00153 $this->_applyParentVat( $this->_oPrice );
00154 $this->_applyCurrency( $this->_oPrice );
00155
00156 $this->_applyParentDiscounts($this->_oPrice);
00157 } elseif ( ( $oParent = $this->getParent() ) ) {
00158 $this->_oPrice = $oParent->getPrice();
00159 }
00160 }
00161
00162 return $this->_oPrice;
00163 }
00164
00173 protected function _applyCurrency(oxPrice $oPrice, $oCur = null )
00174 {
00175 if ( !$oCur ) {
00176 $oCur = $this->getConfig()->getActShopCurrencyObject();
00177 }
00178
00179 $oPrice->multiply($oCur->rate);
00180 }
00181
00189 protected function _applyParentDiscounts( $oPrice )
00190 {
00191 if ( ( $oParent = $this->getParent() ) ) {
00192 $oParent->applyDiscountsForVariant( $oPrice );
00193 }
00194 }
00195
00203 protected function _applyParentVat( $oPrice )
00204 {
00205 if ( ( $oParent = $this->getParent() ) && !$this->getConfig()->getConfigParam( 'bl_perfCalcVatOnlyForBasketOrder' ) ) {
00206 $oParent->applyVats($oPrice);
00207 }
00208 }
00209
00217 public function setPrice($oPrice)
00218 {
00219 $this->_oPrice = $oPrice;
00220 }
00221
00227 public function getFPrice()
00228 {
00229 $sPrice = null;
00230 if ( ( $oPrice = $this->getPrice() ) ) {
00231 $sPrice = oxRegistry::getLang()->formatCurrency( $oPrice->getBruttoPrice() );
00232 }
00233 return $sPrice;
00234 }
00235
00243 public function setParent($oParent)
00244 {
00245 $this->_oParent = $oParent;
00246 }
00247
00253 public function getParent()
00254 {
00255 return $this->_oParent;
00256 }
00257
00263 public function getLinkType()
00264 {
00265 $iLinkType = 0;
00266 if ( ( $oParent = $this->getParent() ) ) {
00267 $iLinkType = $oParent->getLinkType();
00268 }
00269 return $iLinkType;
00270 }
00271
00279 public function inCategory( $sCatNid )
00280 {
00281 $blIn = false;
00282 if ( ( $oParent = $this->getParent() ) ) {
00283 $blIn = $oParent->inCategory( $sCatNid );
00284 }
00285 return $blIn;
00286 }
00287
00295 public function inPriceCategory( $sCatNid )
00296 {
00297 $blIn = false;
00298 if ( ( $oParent = $this->getParent() ) ) {
00299 $blIn = $oParent->inPriceCategory( $sCatNid );
00300 }
00301 return $blIn;
00302 }
00303
00313 public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00314 {
00315 if ( !isset( $this->_aBaseStdUrls[$iLang][$iLinkType] ) ) {
00316 $oArticle = oxNew( "oxArticle" );
00317 $oArticle->setId( $this->getId() );
00318 $oArticle->setLinkType( $iLinkType );
00319 $this->_aBaseStdUrls[$iLang][$iLinkType] = $oArticle->getBaseStdLink( $iLang, $blAddId, $blFull );
00320 }
00321
00322 return $this->_aBaseStdUrls[$iLang][$iLinkType];
00323 }
00324
00333 public function getStdLink( $iLang = null, $aParams = array() )
00334 {
00335 if ( $iLang === null ) {
00336 $iLang = (int) $this->getLanguage();
00337 }
00338
00339 $iLinkType = $this->getLinkType();
00340 if ( !isset( $this->_aStdUrls[$iLang][$iLinkType] ) ) {
00341 $oArticle = oxNew( "oxArticle" );
00342 $oArticle->setId( $this->getId() );
00343 $oArticle->setLinkType( $iLinkType );
00344 $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink( $iLang, $aParams );
00345 }
00346
00347 return $this->_aStdUrls[$iLang][$iLinkType];
00348 }
00349
00357 public function getBaseSeoLink( $iLang )
00358 {
00359 return oxRegistry::get("oxSeoEncoderArticle")->getArticleUrl( $this, $iLang, $iLinkType );
00360 }
00361
00369 public function getLink( $iLang = null )
00370 {
00371 if ( $iLang === null ) {
00372 $iLang = (int) $this->getLanguage();
00373 }
00374
00375 if ( !oxRegistry::getUtils()->seoIsActive() ) {
00376 return $this->getStdLink( $iLang );
00377 }
00378
00379 $iLinkType = $this->getLinkType();
00380 if ( !isset( $this->_aSeoUrls[$iLang][$iLinkType] ) ) {
00381 $this->_aSeoUrls[$iLang][$iLinkType] = $this->getBaseSeoLink( $iLang );
00382 }
00383 return $this->_aSeoUrls[$iLang][$iLinkType];
00384
00385 }
00386 }