source/Application/Component/BasketComponent.php
protected function _addItems($products)
    {
        $activeView = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView();
        $errorDestination = $activeView->getErrorDestination();

        $basket = $this->getSession()->getBasket();
        $basketInfo = $basket->getBasketSummary();

        $basketItemAmounts = [];

        foreach ($products as $addProductId => $productInfo) {
            $data = $this->prepareProductInformation($addProductId, $productInfo);
            $productAmount = 0;
            if (isset($basketInfo->aArticles[$data['id']])) {
                $productAmount = $basketInfo->aArticles[$data['id']];
            }
            $products[$addProductId]['oldam'] = $productAmount;

            //If we already changed articles so they now exactly match existing ones,
            //we need to make sure we get the amounts correct
            if (isset($basketItemAmounts[$data['oldBasketItemId']])) {
                $data['amount'] = $data['amount'] + $basketItemAmounts[$data['oldBasketItemId']];
            }

            $basketItem = $this->addItemToBasket($basket, $data, $errorDestination);

            if (($basketItem instanceof \OxidEsales\Eshop\Application\Model\BasketItem)) {
                $basketItemKey = $basketItem->getBasketItemKey();
                if ($basketItemKey) {
                    if (! isset($basketItemAmounts[$basketItemKey])) {
                        $basketItemAmounts[$basketItemKey] = 0;
                    }
                    $basketItemAmounts[$basketItemKey] += $data['amount'];
                }
            }

            if (!$basketItem) {
                $info = $basket->getBasketSummary();
                $productAmount = $info->aArticles[$data['id']];
                $products[$addProductId]['am'] = isset($productAmount) ? $productAmount : 0;
            }
        }

        //if basket empty remove possible gift card
        if ($basket->getProductsCount() == 0) {
            $basket->setCardId(null);
        }

        // information that last call was tobasket
        $this->_setLastCall($this->_getLastCallFnc(), $products, $basketInfo);

        return $basketItem;
    }
protected function _addItems($products)
    {
        $activeView = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView();
        $errorDestination = $activeView->getErrorDestination();

        $basket = $this->getSession()->getBasket();
        $basketInfo = $basket->getBasketSummary();

        $basketItemAmounts = [];

        foreach ($products as $addProductId => $productInfo) {
            $data = $this->prepareProductInformation($addProductId, $productInfo);
            $productAmount = 0;
            if (isset($basketInfo->aArticles[$data['id']])) {
                $productAmount = $basketInfo->aArticles[$data['id']];
            }
            $products[$addProductId]['oldam'] = $productAmount;

            //If we already changed articles so they now exactly match existing ones,
            //we need to make sure we get the amounts correct
            if (isset($basketItemAmounts[$data['oldBasketItemId']])) {
                $data['amount'] = $data['amount'] + $basketItemAmounts[$data['oldBasketItemId']];
            }

            $basketItem = $this->addItemToBasket($basket, $data, $errorDestination);

            if (($basketItem instanceof \OxidEsales\Eshop\Application\Model\BasketItem)) {
                $basketItemKey = $basketItem->getBasketItemKey();
                if ($basketItemKey) {
                    if (! isset($basketItemAmounts[$basketItemKey])) {
                        $basketItemAmounts[$basketItemKey] = 0;
                    }
                    $basketItemAmounts[$basketItemKey] += $data['amount'];
                }
            }

            if (!$basketItem) {
                $info = $basket->getBasketSummary();
                $productAmount = $info->aArticles[$data['id']];
                $products[$addProductId]['am'] = isset($productAmount) ? $productAmount : 0;
            }
        }

        //if basket empty remove possible gift card
        if ($basket->getProductsCount() == 0) {
            $basket->setCardId(null);
        }

        // information that last call was tobasket
        $this->_setLastCall($this->_getLastCallFnc(), $products, $basketInfo);

        return $basketItem;
    }
protected function _addItems ( $ products ) { $ activeView = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveView ( ) ; $ errorDestination = $ activeView -> getErrorDestination ( ) ; $ basket = $ this -> getSession ( ) -> getBasket ( ) ; $ basketInfo = $ basket -> getBasketSummary ( ) ; $ basketItemAmounts = [ ] ; foreach ( $ products as $ addProductId => $ productInfo ) { $ data = $ this -> prepareProductInformation ( $ addProductId , $ productInfo ) ; $ productAmount = 0 ; if ( isset ( $ basketInfo -> aArticles [ $ data [ 'id' ] ] ) ) { $ productAmount = $ basketInfo -> aArticles [ $ data [ 'id' ] ] ; } $ products [ $ addProductId ] [ 'oldam' ] = $ productAmount ; //If we already changed articles so they now exactly match existing ones, //we need to make sure we get the amounts correct if ( isset ( $ basketItemAmounts [ $ data [ 'oldBasketItemId' ] ] ) ) { $ data [ 'amount' ] = $ data [ 'amount' ] + $ basketItemAmounts [ $ data [ 'oldBasketItemId' ] ] ; } $ basketItem = $ this -> addItemToBasket ( $ basket , $ data , $ errorDestination ) ; if ( ( $ basketItem instanceof \ OxidEsales \ Eshop \ Application \ Model \ BasketItem ) ) { $ basketItemKey = $ basketItem -> getBasketItemKey ( ) ; if ( $ basketItemKey ) { if ( ! isset ( $ basketItemAmounts [ $ basketItemKey ] ) ) { $ basketItemAmounts [ $ basketItemKey ] = 0 ; } $ basketItemAmounts [ $ basketItemKey ] += $ data [ 'amount' ] ; } } if ( ! $ basketItem ) { $ info = $ basket -> getBasketSummary ( ) ; $ productAmount = $ info -> aArticles [ $ data [ 'id' ] ] ; $ products [ $ addProductId ] [ 'am' ] = isset ( $ productAmount ) ? $ productAmount : 0 ; } } //if basket empty remove possible gift card if ( $ basket -> getProductsCount ( ) == 0 ) { $ basket -> setCardId ( null ) ; } // information that last call was tobasket $ this -> _setLastCall ( $ this -> _getLastCallFnc ( ) , $ products , $ basketInfo ) ; return $ basketItem ; }
Adds all articles user wants to add to basket. Returns
last added to basket item.

@param array $products products to add array

@return  object  $oBasketItem    last added basket item
Adds all articles user wants to add to basket . Returns last added to basket item .