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
00176 public function getPrice()
00177 {
00178 if ( $this->_oPrice === null ) {
00179 $this->_oPrice = oxNew( "oxPrice" );
00180 if ( ( $dPrice = $this->_getGroupPrice() ) ) {
00181 $this->_oPrice->setPrice( $dPrice, $this->_dVat );
00182
00183 $this->_applyParentVat( $this->_oPrice );
00184 $this->_applyCurrency( $this->_oPrice );
00185
00186 $this->_applyParentDiscounts($this->_oPrice);
00187 } elseif ( ( $oParent = $this->getParent() ) ) {
00188 $this->_oPrice = $oParent->getPrice();
00189 }
00190 }
00191
00192 return $this->_oPrice;
00193 }
00194
00203 protected function _applyCurrency(oxPrice $oPrice, $oCur = null )
00204 {
00205 if ( !$oCur ) {
00206 $oCur = $this->getConfig()->getActShopCurrencyObject();
00207 }
00208
00209 $oPrice->multiply($oCur->rate);
00210 }
00211
00219 protected function _applyParentDiscounts( $oPrice )
00220 {
00221 if ( ( $oParent = $this->getParent() ) ) {
00222 $oParent->applyDiscountsForVariant( $oPrice );
00223 }
00224 }
00225
00233 protected function _applyParentVat( $oPrice )
00234 {
00235 if ( ( $oParent = $this->getParent() ) && !$this->getConfig()->getConfigParam( 'blEnterNetPrice' ) ) {
00236 $oParent->applyVats($oPrice);
00237 }
00238 }
00239
00247 public function setPrice($oPrice)
00248 {
00249 $this->_oPrice = $oPrice;
00250 }
00251
00257 public function getFPrice()
00258 {
00259 $sPrice = null;
00260 if ( ( $oPrice = $this->getPrice() ) ) {
00261 $sPrice = oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00262 }
00263 return $sPrice;
00264 }
00265
00273 public function setParent($oParent)
00274 {
00275 $this->_oParent = $oParent;
00276 }
00277
00283 public function getParent()
00284 {
00285 return $this->_oParent;
00286 }
00287
00293 public function getLinkType()
00294 {
00295 $iLinkType = 0;
00296 if ( ( $oParent = $this->getParent() ) ) {
00297 $iLinkType = $oParent->getLinkType();
00298 }
00299 return $iLinkType;
00300 }
00301
00309 public function inCategory( $sCatNid )
00310 {
00311 $blIn = false;
00312 if ( ( $oParent = $this->getParent() ) ) {
00313 $blIn = $oParent->inCategory( $sCatNid );
00314 }
00315 return $blIn;
00316 }
00317
00325 public function inPriceCategory( $sCatNid )
00326 {
00327 $blIn = false;
00328 if ( ( $oParent = $this->getParent() ) ) {
00329 $blIn = $oParent->inPriceCategory( $sCatNid );
00330 }
00331 return $blIn;
00332 }
00333
00343 public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00344 {
00345 if ( !isset( $this->_aBaseStdUrls[$iLang][$iLinkType] ) ) {
00346 $oArticle = oxNew( "oxArticle" );
00347 $oArticle->setId( $this->getId() );
00348 $oArticle->setLinkType( $iLinkType );
00349 $this->_aBaseStdUrls[$iLang][$iLinkType] = $oArticle->getBaseStdLink( $iLang, $blAddId, $blFull );
00350 }
00351
00352 return $this->_aBaseStdUrls[$iLang][$iLinkType];
00353 }
00354
00363 public function getStdLink( $iLang = null, $aParams = array() )
00364 {
00365 if ( $iLang === null ) {
00366 $iLang = (int) $this->getLanguage();
00367 }
00368
00369 $iLinkType = $this->getLinkType();
00370 if ( !isset( $this->_aStdUrls[$iLang][$iLinkType] ) ) {
00371 $oArticle = oxNew( "oxArticle" );
00372 $oArticle->setId( $this->getId() );
00373 $oArticle->setLinkType( $iLinkType );
00374 $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink( $iLang, $aParams );
00375 }
00376
00377 return $this->_aStdUrls[$iLang][$iLinkType];
00378 }
00379
00387 public function getBaseSeoLink( $iLang )
00388 {
00389 return oxSeoEncoderArticle::getInstance()->getArticleUrl( $this, $iLang, $iLinkType );
00390 }
00391
00399 public function getLink( $iLang = null )
00400 {
00401 if ( $iLang === null ) {
00402 $iLang = (int) $this->getLanguage();
00403 }
00404
00405 if ( !oxUtils::getInstance()->seoIsActive() ) {
00406 return $this->getStdLink( $iLang );
00407 }
00408
00409 $iLinkType = $this->getLinkType();
00410 if ( !isset( $this->_aSeoUrls[$iLang][$iLinkType] ) ) {
00411 $this->_aSeoUrls[$iLang][$iLinkType] = $this->getBaseSeoLink( $iLang );
00412 }
00413 return $this->_aSeoUrls[$iLang][$iLinkType];
00414
00415 }
00416 }