source/Application/Model/OrderArticle.php
public function setNewAmount($iNewAmount)
    {
        if ($iNewAmount >= 0) {
            // to update stock we must first check if it is possible - article exists?
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            if ($oArticle->load($this->oxorderarticles__oxartid->value)) {
                // updating stock info
                $iStockChange = $iNewAmount - $this->oxorderarticles__oxamount->value;
                if ($iStockChange > 0 && ($iOnStock = $oArticle->checkForStock($iStockChange)) !== false) {
                    if ($iOnStock !== true) {
                        $iStockChange = $iOnStock;
                        $iNewAmount = $this->oxorderarticles__oxamount->value + $iStockChange;
                    }
                }

                $this->updateArticleStock($iStockChange * -1, \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blAllowNegativeStock'));

                // updating self
                $this->oxorderarticles__oxamount = new \OxidEsales\Eshop\Core\Field($iNewAmount, \OxidEsales\Eshop\Core\Field::T_RAW);
                $this->save();
            }
        }
    }
public function setNewAmount($iNewAmount)
    {
        if ($iNewAmount >= 0) {
            // to update stock we must first check if it is possible - article exists?
            $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
            if ($oArticle->load($this->oxorderarticles__oxartid->value)) {
                // updating stock info
                $iStockChange = $iNewAmount - $this->oxorderarticles__oxamount->value;
                if ($iStockChange > 0 && ($iOnStock = $oArticle->checkForStock($iStockChange)) !== false) {
                    if ($iOnStock !== true) {
                        $iStockChange = $iOnStock;
                        $iNewAmount = $this->oxorderarticles__oxamount->value + $iStockChange;
                    }
                }

                $this->updateArticleStock($iStockChange * -1, \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blAllowNegativeStock'));

                // updating self
                $this->oxorderarticles__oxamount = new \OxidEsales\Eshop\Core\Field($iNewAmount, \OxidEsales\Eshop\Core\Field::T_RAW);
                $this->save();
            }
        }
    }
public function setNewAmount ( $ iNewAmount ) { if ( $ iNewAmount >= 0 ) { // to update stock we must first check if it is possible - article exists? $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; if ( $ oArticle -> load ( $ this -> oxorderarticles__oxartid -> value ) ) { // updating stock info $ iStockChange = $ iNewAmount - $ this -> oxorderarticles__oxamount -> value ; if ( $ iStockChange > 0 && ( $ iOnStock = $ oArticle -> checkForStock ( $ iStockChange ) ) !== false ) { if ( $ iOnStock !== true ) { $ iStockChange = $ iOnStock ; $ iNewAmount = $ this -> oxorderarticles__oxamount -> value + $ iStockChange ; } } $ this -> updateArticleStock ( $ iStockChange * - 1 , \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blAllowNegativeStock' ) ) ; // updating self $ this -> oxorderarticles__oxamount = new \ OxidEsales \ Eshop \ Core \ Field ( $ iNewAmount , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; $ this -> save ( ) ; } } }
Ordered article stock setter. Before setting new stock value additionally checks for
original article stock value. Is stock values <= preferred, adjusts order stock according
to it

@param int $iNewAmount new ordered items amount
Ordered article stock setter . Before setting new stock value additionally checks for original article stock value . Is stock values < = preferred adjusts order stock according to it