protected function _loadCoupons( $id, $fresh, array $products )
	{
		$items = array();
		$manager = $this->getSubManager( 'coupon' );

		$criteria = $manager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.coupon.baseid', $id ) );

		foreach( $manager->searchItems( $criteria ) as $item )
		{
			if( !isset( $items[ $item->getCode() ] ) ) {
				$items[ $item->getCode() ] = array();
			}

			if( $item->getProductId() !== null )
			{
				foreach( $products as $product )
				{
					if( $product->getId() == $item->getProductId() ) {
						$items[ $item->getCode() ][] = $product;
					}
				}
			}
		}

		return $items;
	}
protected function _loadCoupons( $id, $fresh, array $products )
	{
		$items = array();
		$manager = $this->getSubManager( 'coupon' );

		$criteria = $manager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.coupon.baseid', $id ) );

		foreach( $manager->searchItems( $criteria ) as $item )
		{
			if( !isset( $items[ $item->getCode() ] ) ) {
				$items[ $item->getCode() ] = array();
			}

			if( $item->getProductId() !== null )
			{
				foreach( $products as $product )
				{
					if( $product->getId() == $item->getProductId() ) {
						$items[ $item->getCode() ][] = $product;
					}
				}
			}
		}

		return $items;
	}
protected function _loadCoupons ( $ id , $ fresh , array $ products ) { $ items = array ( ) ; $ manager = $ this -> getSubManager ( 'coupon' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.coupon.baseid' , $ id ) ) ; foreach ( $ manager -> searchItems ( $ criteria ) as $ item ) { if ( ! isset ( $ items [ $ item -> getCode ( ) ] ) ) { $ items [ $ item -> getCode ( ) ] = array ( ) ; } if ( $ item -> getProductId ( ) !== null ) { foreach ( $ products as $ product ) { if ( $ product -> getId ( ) == $ item -> getProductId ( ) ) { $ items [ $ item -> getCode ( ) ] [ ] = $ product ; } } } } return $ items ; }
Retrieves the coupons of the order from the storage.

@param integer $id Order base ID
@param boolean $fresh Create new items by copying the existing ones and remove their IDs
@param array List of order products from the basket
@return array Associative list of coupon codes as keys and items implementing MShop_Order_Item_Product_Interface
Retrieves the coupons of the order from the storage .