src/Kunstmaan/SeoBundle/Helper/OrderPreparer.php
public function prepare(Order $order)
    {
        /** @var $orderItems OrderItem[] */
        $orderItems = $order->orderItems;

        /** @var $newOrderItems OrderItem[] */
        $newOrderItems = array();

        foreach ($orderItems as $item) {
            if (!isset($newOrderItems[$item->getSKU()])) {
                $newOrderItems[$item->getSKU()] = $item;
            } else {
                $newOrderItems[$item->getSKU()]->setQuantity($newOrderItems[$item->getSKU()]->getQuantity() + $item->getQuantity());
                $newOrderItems[$item->getSKU()]->setTaxes($newOrderItems[$item->getSKU()]->getTaxes() + $item->getTaxes());
            }
        }

        $order->orderItems = $newOrderItems;

        return $order;
    }
public function prepare(Order $order)
    {
        /** @var $orderItems OrderItem[] */
        $orderItems = $order->orderItems;

        /** @var $newOrderItems OrderItem[] */
        $newOrderItems = array();

        foreach ($orderItems as $item) {
            if (!isset($newOrderItems[$item->getSKU()])) {
                $newOrderItems[$item->getSKU()] = $item;
            } else {
                $newOrderItems[$item->getSKU()]->setQuantity($newOrderItems[$item->getSKU()]->getQuantity() + $item->getQuantity());
                $newOrderItems[$item->getSKU()]->setTaxes($newOrderItems[$item->getSKU()]->getTaxes() + $item->getTaxes());
            }
        }

        $order->orderItems = $newOrderItems;

        return $order;
    }
public function prepare ( Order $ order ) { /** @var $orderItems OrderItem[] */ $ orderItems = $ order -> orderItems ; /** @var $newOrderItems OrderItem[] */ $ newOrderItems = array ( ) ; foreach ( $ orderItems as $ item ) { if ( ! isset ( $ newOrderItems [ $ item -> getSKU ( ) ] ) ) { $ newOrderItems [ $ item -> getSKU ( ) ] = $ item ; } else { $ newOrderItems [ $ item -> getSKU ( ) ] -> setQuantity ( $ newOrderItems [ $ item -> getSKU ( ) ] -> getQuantity ( ) + $ item -> getQuantity ( ) ) ; $ newOrderItems [ $ item -> getSKU ( ) ] -> setTaxes ( $ newOrderItems [ $ item -> getSKU ( ) ] -> getTaxes ( ) + $ item -> getTaxes ( ) ) ; } } $ order -> orderItems = $ newOrderItems ; return $ order ; }
Fully prepares an order for conversion.
What it does for now is deduplicate the OrderItems.

Ensure every orderItem has a unique SKU.
Only one request is made per order/SKU.
So the same SKUs on multiple lines need to be grouped.

@param Order $order

@return Order
Fully prepares an order for conversion . What it does for now is deduplicate the OrderItems .