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