View Issue Details

IDProjectCategoryView StatusLast Update
0004563OXID eShop (all versions)1.02. Price calculations (discounts, coupons, additional costs etc.)public2012-12-07 15:20
ReporterWBL_BjoernLange 
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionPast development 
Target VersionFixed in Version4.6.6 revision 54646 
Summary0004563: Broken article price "calculation" after template change
DescriptionoxArticle::getBasePrice depends on oxArticle::_getAmountPrice. And oxArticle::_getAmountPrice uses the class property oxArticle::_oAmountPriceList. oxArticle::_oAmountPriceList is also used for displaying the amount price info with oxArticle::loadAmountPriceInfo:

        if ( $this->_oAmountPriceInfo === null ) {
            $this->_oAmountPriceInfo = array();
            if ( count( ( $oAmPriceList = $this->_getAmountPriceList() ) ) ) {
                $this->_oAmountPriceInfo = $this->_fillAmountPriceList( $oAmPriceList );
            }
        }

But there is a flaw hidden in oxArticle::_fillAmountPriceList(). You change the the numeric value of oxprice2article__oxaddabs in the formatted currency and save it in an object which is referenced in oxArticle::_oAmountPriceList:

$oAmPriceList[$sId]->oxprice2article__oxaddabs = new oxField( $oLang->formatCurrency( $myUtils->fRound( $oItemPrice->getBruttoPrice(), $oCur ) ) );
$oAmPriceList[$sId]->fnetprice = $oLang->formatCurrency( $myUtils->fRound($oItemPrice->getNettoPrice(), $oCur ) );
$oAmPriceList[$sId]->fbrutprice = $oLang->formatCurrency( $myUtils->fRound($oItemPrice->getBruttoPrice(), $oCur ) )

If you call oxArticle::getPrice(1), after a previous call of oxArticle::loadAmountPriceInfo with an saved amount price for the amount 1, the base price calculation fails, because oxprice2article__oxaddabs for the amount 1 contains a string:

    public function getPrice( $dAmount = 1 )
    {
        $myConfig = $this->getConfig();
        // Performance
        if ( !$myConfig->getConfigParam( 'bl_perfLoadPrice' ) || !$this->_blLoadPrice ) {
            return;
        }

        // return cached result, since oPrice is created ONLY in this function [or function of EQUAL level]
        if ( $dAmount != 1 || $this->_oPrice === null ) {
            $oPrice = oxNew( 'oxPrice' );

            // get base
            $oPrice->setPrice( $this->getBasePrice( $dAmount ) ); // <--- This returns the formatted currency

            // price handling
            if ( !$this->_blCalcPrice && $dAmount == 1 ) {
                return $this->_oPrice = $oPrice;
            }

            $this->_calculatePrice( $oPrice );

TagsScale Price
ThemeBoth
BrowserAll
PHP Versionany
MySQL Versionany

Relationships

related to 0004210 resolvedLinas Kukulskis oxArticle::getPrice( $iAmount ) doesn't calculate scale prices after the method oxArticle::loadAmountPriceInfo() is called 

Activities

WBL_BjoernLange

2012-09-27 17:59

reporter   ~0007505

"You change the the numeric value of oxprice2article__oxaddabs to the formatted currency string and save it in an object which is referenced in oxArticle::_oAmountPriceList"

Linas Kukulskis

2012-10-04 17:25

reporter   ~0007557

removed unnecessary formating