src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php
private function checkProductsAvailability(OrderInterface $cart)
    {
        // no check needed
        if ($cart->getItems()->isEmpty()) {
            return true;
        }

        $containsInvalidProducts = false;
        /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */
        foreach ($cart->getItems() as $item) {
            if (!$item->getProduct() ||
                !$item->getProduct()->isValidShopProduct()
            ) {
                $containsInvalidProducts = true;
                $cart->removeItem($item);
                $this->em->remove($item);
            }
        }
        // persist new cart
        if ($containsInvalidProducts) {
            $this->em->flush();
        }

        return !$containsInvalidProducts;
    }
private function checkProductsAvailability(OrderInterface $cart)
    {
        // no check needed
        if ($cart->getItems()->isEmpty()) {
            return true;
        }

        $containsInvalidProducts = false;
        /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */
        foreach ($cart->getItems() as $item) {
            if (!$item->getProduct() ||
                !$item->getProduct()->isValidShopProduct()
            ) {
                $containsInvalidProducts = true;
                $cart->removeItem($item);
                $this->em->remove($item);
            }
        }
        // persist new cart
        if ($containsInvalidProducts) {
            $this->em->flush();
        }

        return !$containsInvalidProducts;
    }
private function checkProductsAvailability ( OrderInterface $ cart ) { // no check needed if ( $ cart -> getItems ( ) -> isEmpty ( ) ) { return true ; } $ containsInvalidProducts = false ; /** @var \Sulu\Bundle\Sales\CoreBundle\Entity\ItemInterface $item */ foreach ( $ cart -> getItems ( ) as $ item ) { if ( ! $ item -> getProduct ( ) || ! $ item -> getProduct ( ) -> isValidShopProduct ( ) ) { $ containsInvalidProducts = true ; $ cart -> removeItem ( $ item ) ; $ this -> em -> remove ( $ item ) ; } } // persist new cart if ( $ containsInvalidProducts ) { $ this -> em -> flush ( ) ; } return ! $ containsInvalidProducts ; }
Removes items from cart that have no valid shop products
applied; and returns if all products are still available

@param OrderInterface $cart

@return bool If all products are available
Removes items from cart that have no valid shop products applied ; and returns if all products are still available