Go to the documentation of this file.00001 <?php
00002
00007 class oxSimpleVariant extends oxI18n implements oxIUrl
00008 {
00009
00015 protected $_blUseLazyLoading = true;
00016
00022 protected $_oPrice = null;
00023
00029 protected $_oParent = null;
00030
00036 protected $_aStdUrls = array();
00037
00043 protected $_aBaseStdUrls = array();
00044
00050 protected $_aSeoUrls = array();
00051
00057 protected $_oUser = null;
00058
00063 public function __construct()
00064 {
00065 parent::__construct();
00066 $this->_sCacheKey = "simplevariants";
00067 $this->init('oxarticles');
00068 }
00069
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
00106 return $this->_oUser;
00107 }
00108
00114 protected function _getGroupPrice()
00115 {
00116 $dPrice = $this->oxarticles__oxprice->value;
00117 if ($oUser = $this->getArticleUser()) {
00118 if ($oUser->inGroup('oxidpricea')) {
00119 $dPrice = $this->oxarticles__oxpricea->value;
00120 } elseif ($oUser->inGroup('oxidpriceb')) {
00121 $dPrice = $this->oxarticles__oxpriceb->value;
00122 } elseif ($oUser->inGroup('oxidpricec')) {
00123 $dPrice = $this->oxarticles__oxpricec->value;
00124 }
00125 }
00126
00127
00128 if ($this->getConfig()->getConfigParam('blOverrideZeroABCPrices') && (double) $dPrice == 0) {
00129 $dPrice = $this->oxarticles__oxprice->value;
00130 }
00131
00132 return $dPrice;
00133 }
00134
00135
00141 public function getPrice()
00142 {
00143 $myConfig = $this->getConfig();
00144
00145 if (!$myConfig->getConfigParam('bl_perfLoadPrice')) {
00146 return;
00147 }
00148
00149 if ($this->_oPrice === null) {
00150 $this->_oPrice = oxNew("oxPrice");
00151 if (($dPrice = $this->_getGroupPrice())) {
00152 $this->_oPrice->setPrice($dPrice, $this->_dVat);
00153
00154 $this->_applyParentVat($this->_oPrice);
00155 $this->_applyCurrency($this->_oPrice);
00156
00157 $this->_applyParentDiscounts($this->_oPrice);
00158 } elseif (($oParent = $this->getParent())) {
00159 $this->_oPrice = $oParent->getPrice();
00160 }
00161 }
00162
00163 return $this->_oPrice;
00164 }
00165
00172 protected function _applyCurrency(oxPrice $oPrice, $oCur = null)
00173 {
00174 if (!$oCur) {
00175 $oCur = $this->getConfig()->getActShopCurrencyObject();
00176 }
00177
00178 $oPrice->multiply($oCur->rate);
00179 }
00180
00186 protected function _applyParentDiscounts($oPrice)
00187 {
00188 if (($oParent = $this->getParent())) {
00189 $oParent->applyDiscountsForVariant($oPrice);
00190 }
00191 }
00192
00198 protected function _applyParentVat($oPrice)
00199 {
00200 if (($oParent = $this->getParent()) && !$this->getConfig()->getConfigParam('bl_perfCalcVatOnlyForBasketOrder')) {
00201 $oParent->applyVats($oPrice);
00202 }
00203 }
00204
00210 public function setPrice($oPrice)
00211 {
00212 $this->_oPrice = $oPrice;
00213 }
00214
00220 public function getFPrice()
00221 {
00222 $sPrice = null;
00223 if (($oPrice = $this->getPrice())) {
00224 $sPrice = oxRegistry::getLang()->formatCurrency($oPrice->getBruttoPrice());
00225 }
00226
00227 return $sPrice;
00228 }
00229
00235 public function setParent($oParent)
00236 {
00237 $this->_oParent = $oParent;
00238 }
00239
00245 public function getParent()
00246 {
00247 return $this->_oParent;
00248 }
00249
00255 public function getLinkType()
00256 {
00257 $iLinkType = 0;
00258 if (($oParent = $this->getParent())) {
00259 $iLinkType = $oParent->getLinkType();
00260 }
00261
00262 return $iLinkType;
00263 }
00264
00272 public function inCategory($sCatNid)
00273 {
00274 $blIn = false;
00275 if (($oParent = $this->getParent())) {
00276 $blIn = $oParent->inCategory($sCatNid);
00277 }
00278
00279 return $blIn;
00280 }
00281
00289 public function inPriceCategory($sCatNid)
00290 {
00291 $blIn = false;
00292 if (($oParent = $this->getParent())) {
00293 $blIn = $oParent->inPriceCategory($sCatNid);
00294 }
00295
00296 return $blIn;
00297 }
00298
00308 public function getBaseStdLink($iLang, $blAddId = true, $blFull = true)
00309 {
00310 if (!isset($this->_aBaseStdUrls[$iLang][$iLinkType])) {
00311 $oArticle = oxNew("oxArticle");
00312 $oArticle->setId($this->getId());
00313 $oArticle->setLinkType($iLinkType);
00314 $this->_aBaseStdUrls[$iLang][$iLinkType] = $oArticle->getBaseStdLink($iLang, $blAddId, $blFull);
00315 }
00316
00317 return $this->_aBaseStdUrls[$iLang][$iLinkType];
00318 }
00319
00328 public function getStdLink($iLang = null, $aParams = array())
00329 {
00330 if ($iLang === null) {
00331 $iLang = (int) $this->getLanguage();
00332 }
00333
00334 $iLinkType = $this->getLinkType();
00335 if (!isset($this->_aStdUrls[$iLang][$iLinkType])) {
00336 $oArticle = oxNew("oxArticle");
00337 $oArticle->setId($this->getId());
00338 $oArticle->setLinkType($iLinkType);
00339 $this->_aStdUrls[$iLang][$iLinkType] = $oArticle->getStdLink($iLang, $aParams);
00340 }
00341
00342 return $this->_aStdUrls[$iLang][$iLinkType];
00343 }
00344
00352 public function getBaseSeoLink($iLang)
00353 {
00354 return oxRegistry::get("oxSeoEncoderArticle")->getArticleUrl($this, $iLang, $iLinkType);
00355 }
00356
00364 public function getLink($iLang = null)
00365 {
00366 if ($iLang === null) {
00367 $iLang = (int) $this->getLanguage();
00368 }
00369
00370 if (!oxRegistry::getUtils()->seoIsActive()) {
00371 return $this->getStdLink($iLang);
00372 }
00373
00374 $iLinkType = $this->getLinkType();
00375 if (!isset($this->_aSeoUrls[$iLang][$iLinkType])) {
00376 $this->_aSeoUrls[$iLang][$iLinkType] = $this->getBaseSeoLink($iLang);
00377 }
00378
00379 return $this->_aSeoUrls[$iLang][$iLinkType];
00380
00381 }
00382 }