oxsimplevariant.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSimpleVariant extends oxI18n
00008 {
00014     protected $_blUseLazyLoading = true;
00015 
00021     protected $_oPrice = null;
00022 
00028     protected $_oParent = null;
00029 
00034     public function __construct()
00035     {
00036         parent::__construct();
00037         $this->_sCacheKey = "simplevariants";
00038         $this->init( 'oxarticles' );
00039     }
00040 
00048     public function __get($sName)
00049     {
00050         $myUtils = oxUtils::getInstance();
00051         switch ($sName) {
00052             case 'aSelectlist' :
00053                 if ( $this->getConfig()->getConfigParam( 'bl_perfLoadSelectLists' ) ) {
00054                     return $this->aSelectlist = $this->getSelectLists();
00055                 }
00056                 return;
00057                 break;
00058         }
00059 
00060         return parent::__get($sName);
00061     }
00062 
00069     public function getSelectLists()
00070     {
00071         return null;
00072     }
00073 
00079     public function getPrice()
00080     {
00081         if (!is_null($this->_oPrice)) {
00082             return $this->_oPrice;
00083         }
00084 
00085         $this->_oPrice = oxNew("oxPrice");
00086         $dPrice = $this->oxarticles__oxprice->value;
00087         if (!$dPrice) {
00088             $dPrice = $this->_getParentPrice();
00089         }
00090 
00091         $this->_oPrice->setPrice($dPrice, $this->_dVat);
00092 
00093         $this->_applyParentVat($this->_oPrice);
00094         $this->_applyCurrency($this->_oPrice);
00095         // apply discounts
00096         $this->_applyParentDiscounts($this->_oPrice);
00097 
00098         return $this->_oPrice;
00099     }
00100 
00109     protected function _applyCurrency(oxPrice $oPrice, $oCur = null )
00110     {
00111         if ( !$oCur ) {
00112             $oCur = $this->getConfig()->getActShopCurrencyObject();
00113         }
00114 
00115         $oPrice->multiply($oCur->rate);
00116     }
00117 
00125     protected function _applyParentDiscounts( $oPrice )
00126     {
00127         $oParent = $this->getParent();
00128         if (!($oParent instanceof oxarticle)) {
00129             return;
00130         }
00131 
00132         $oParent->applyDiscountsForVariant( $oPrice );
00133 
00134     }
00135 
00143     protected function _applyParentVat($oPrice)
00144     {
00145         $oParent = $this->getParent();
00146         if (!($oParent instanceof oxarticle)) {
00147             return;
00148         }
00149 
00150         $oParent->applyVats($oPrice);
00151     }
00152 
00160     public function setPrice($oPrice)
00161     {
00162         $this->_oPrice = $oPrice;
00163     }
00164 
00170     public function getFPrice()
00171     {
00172         if ( $oPrice = $this->getPrice() ) {
00173             return oxLang::getInstance()->formatCurrency( $oPrice->getBruttoPrice() );
00174         } else {
00175             return null;
00176         }
00177     }
00178 
00186     public function setParent($oParent)
00187     {
00188         $this->_oParent = $oParent;
00189     }
00190 
00196     public function getParent()
00197     {
00198         return $this->_oParent;
00199     }
00200 
00206     protected function _getParentPrice()
00207     {
00208 
00209         if (isset($this->_oParent->oxarticles__oxprice->value)) {
00210             return $this->_oParent->oxarticles__oxprice->value;
00211         }
00212 
00213         return 0;
00214     }
00215 }

Generated on Tue Sep 29 16:45:13 2009 for OXID eShop CE by  doxygen 1.5.5