00001 <?php
00002
00007 class oxSimpleVariant extends oxI18n
00008 {
00009
00015 protected $_blUseLazyLoading = true;
00016
00022 protected $_dVat = null;
00023
00029 protected $_oPrice = null;
00030
00036 protected $_oParent = null;
00037
00042 public function __construct()
00043 {
00044 parent::__construct();
00045 $this->_sCacheKey = "simplevariants";
00046 $this->init( 'oxarticles' );
00047 }
00048
00055 public function getSelectLists()
00056 {
00057 return null;
00058 }
00059
00065 public function getPrice()
00066 {
00067 if (!is_null($this->_oPrice)) {
00068 return $this->_oPrice;
00069 }
00070
00071 $this->_oPrice = oxNew("oxPrice");
00072 $dPrice = $this->oxarticles__oxprice->value;
00073 if (!$dPrice) {
00074 $dPrice = $this->_getParentPrice();
00075 }
00076 $this->_oPrice->setPrice($dPrice, $this->_dVat);
00077 return $this->_oPrice;
00078 }
00079
00087 public function setPrice($oPrice)
00088 {
00089 $this->_oPrice = $oPrice;
00090 }
00091
00097 public function getFPrice()
00098 {
00099 if ( $oPrice = $this->getPrice() ) {
00100 return oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00101 } else {
00102 return null;
00103 }
00104 }
00105
00113 public function setVat($dVat)
00114 {
00115 $this->_dVat = $dVat;
00116 }
00117
00125 public function setParent($oParent)
00126 {
00127 $this->_oParent = $oParent;
00128 }
00129
00135 public function getParent()
00136 {
00137 return $this->_oParent;
00138 }
00139
00145 protected function _getParentPrice()
00146 {
00147
00148 if (isset($this->_oParent->oxarticles__oxprice->value)) {
00149 return $this->_oParent->oxarticles__oxprice->value;
00150 }
00151
00152 return 0;
00153 }
00154 }