oxsimplevariant.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSimpleVariant extends oxI18n
00008 {
00009 
00015     protected $_blUseLazyLoading = true;
00016 
00022     protected $_oPrice = null;
00023 
00029     protected $_oParent = null;
00030 
00035     public function __construct()
00036     {
00037         parent::__construct();
00038         $this->_sCacheKey = "simplevariants";
00039         $this->init( 'oxarticles' );
00040     }
00041 
00048     public function getSelectLists()
00049     {
00050         return null;
00051     }
00052 
00058     public function getPrice()
00059     {
00060         if (!is_null($this->_oPrice)) {
00061             return $this->_oPrice;
00062         }
00063 
00064         $this->_oPrice = oxNew("oxPrice");
00065         $dPrice = $this->oxarticles__oxprice->value;
00066         if (!$dPrice) {
00067             $dPrice = $this->_getParentPrice();
00068         }
00069 
00070         $this->_oPrice->setPrice($dPrice, $this->_dVat);
00071 
00072         $this->_applyParentVat($this->_oPrice);
00073         $this->_applyCurrency($this->_oPrice);
00074         // apply discounts
00075         $this->_applyParentDiscounts($this->_oPrice);
00076 
00077         return $this->_oPrice;
00078     }
00079 
00088     protected function _applyCurrency(oxPrice $oPrice, $oCur = null )
00089     {
00090         if ( !$oCur ) {
00091             $oCur = $this->getConfig()->getActShopCurrencyObject();
00092         }
00093 
00094         $oPrice->multiply($oCur->rate);
00095     }
00096 
00105     protected function _applyParentDiscounts( $oPrice )
00106     {
00107         $oParent = $this->getParent();
00108         if (!($oParent instanceof oxarticle)) {
00109             return;
00110         }
00111 
00112         $oParent->applyDiscountsForVariant( $oPrice );
00113 
00114     }
00115 
00122     protected function _applyParentVat($oPrice)
00123     {
00124         $oParent = $this->getParent();
00125         if (!($oParent instanceof oxarticle)) {
00126             return;
00127         }
00128 
00129         $oParent->applyVats($oPrice);
00130     }
00131 
00139     public function setPrice($oPrice)
00140     {
00141         $this->_oPrice = $oPrice;
00142     }
00143 
00149     public function getFPrice()
00150     {
00151         if ( $oPrice = $this->getPrice() ) {
00152             return oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00153         } else {
00154             return null;
00155         }
00156     }
00157 
00165     public function setParent($oParent)
00166     {
00167         $this->_oParent = $oParent;
00168     }
00169 
00175     public function getParent()
00176     {
00177         return $this->_oParent;
00178     }
00179 
00185     protected function _getParentPrice()
00186     {
00187 
00188         if (isset($this->_oParent->oxarticles__oxprice->value)) {
00189             return $this->_oParent->oxarticles__oxprice->value;
00190         }
00191 
00192         return 0;
00193     }
00194 }

Generated on Wed Jun 17 12:09:02 2009 for OXID eShop CE by  doxygen 1.5.5