protected function _loadProducts( $id, $fresh )
	{
		$attributes = $products = $subProducts = array();
		$manager = $this->getSubManager( 'product' );
		$attrManager = $manager->getSubManager( 'attribute' );

		$criteria = $manager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.product.baseid', $id ) );
		$criteria->setSortations( array( $criteria->sort( '-', 'order.base.product.position' ) ) );
		$items = $manager->searchItems( $criteria );


		$criteria = $attrManager->createSearch();
		$expr = $criteria->compare( '==', 'order.base.product.attribute.productid', array_keys( $items ) );
		$criteria->setConditions( $expr );

		foreach( $attrManager->searchItems( $criteria ) as $id => $attribute )
		{
			if(  $fresh == true )
			{
				$attributes[ $attribute->getProductId() ][] = $attribute;
				$attribute->setProductId( null );
				$attribute->setId( null );
			}
			else
			{
				$attributes[ $attribute->getProductId() ][$id] = $attribute;
			}
		}

		foreach( $items as $id => $item )
		{
			if( isset( $attributes[$id] ) ) {
				$item->setAttributes( $attributes[$id] );
			}

			if( $item->getOrderProductId() === null )
			{
				$item->setProducts( $subProducts );
				$products[ $item->getPosition() ] = $item;

				$subProducts = array();
			}
			else
			{	// in case it's a sub-product
				$subProducts[ $item->getPosition() ] = $item ;
			}

			if( $fresh == true )
			{
				$item->setPosition( null );
				$item->setBaseId( null );
				$item->setId( null );
			}
		}

		return array_reverse( $products, true );
	}
protected function _loadProducts( $id, $fresh )
	{
		$attributes = $products = $subProducts = array();
		$manager = $this->getSubManager( 'product' );
		$attrManager = $manager->getSubManager( 'attribute' );

		$criteria = $manager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.product.baseid', $id ) );
		$criteria->setSortations( array( $criteria->sort( '-', 'order.base.product.position' ) ) );
		$items = $manager->searchItems( $criteria );


		$criteria = $attrManager->createSearch();
		$expr = $criteria->compare( '==', 'order.base.product.attribute.productid', array_keys( $items ) );
		$criteria->setConditions( $expr );

		foreach( $attrManager->searchItems( $criteria ) as $id => $attribute )
		{
			if(  $fresh == true )
			{
				$attributes[ $attribute->getProductId() ][] = $attribute;
				$attribute->setProductId( null );
				$attribute->setId( null );
			}
			else
			{
				$attributes[ $attribute->getProductId() ][$id] = $attribute;
			}
		}

		foreach( $items as $id => $item )
		{
			if( isset( $attributes[$id] ) ) {
				$item->setAttributes( $attributes[$id] );
			}

			if( $item->getOrderProductId() === null )
			{
				$item->setProducts( $subProducts );
				$products[ $item->getPosition() ] = $item;

				$subProducts = array();
			}
			else
			{	// in case it's a sub-product
				$subProducts[ $item->getPosition() ] = $item ;
			}

			if( $fresh == true )
			{
				$item->setPosition( null );
				$item->setBaseId( null );
				$item->setId( null );
			}
		}

		return array_reverse( $products, true );
	}
protected function _loadProducts ( $ id , $ fresh ) { $ attributes = $ products = $ subProducts = array ( ) ; $ manager = $ this -> getSubManager ( 'product' ) ; $ attrManager = $ manager -> getSubManager ( 'attribute' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.product.baseid' , $ id ) ) ; $ criteria -> setSortations ( array ( $ criteria -> sort ( '-' , 'order.base.product.position' ) ) ) ; $ items = $ manager -> searchItems ( $ criteria ) ; $ criteria = $ attrManager -> createSearch ( ) ; $ expr = $ criteria -> compare ( '==' , 'order.base.product.attribute.productid' , array_keys ( $ items ) ) ; $ criteria -> setConditions ( $ expr ) ; foreach ( $ attrManager -> searchItems ( $ criteria ) as $ id => $ attribute ) { if ( $ fresh == true ) { $ attributes [ $ attribute -> getProductId ( ) ] [ ] = $ attribute ; $ attribute -> setProductId ( null ) ; $ attribute -> setId ( null ) ; } else { $ attributes [ $ attribute -> getProductId ( ) ] [ $ id ] = $ attribute ; } } foreach ( $ items as $ id => $ item ) { if ( isset ( $ attributes [ $ id ] ) ) { $ item -> setAttributes ( $ attributes [ $ id ] ) ; } if ( $ item -> getOrderProductId ( ) === null ) { $ item -> setProducts ( $ subProducts ) ; $ products [ $ item -> getPosition ( ) ] = $ item ; $ subProducts = array ( ) ; } else { // in case it's a sub-product $ subProducts [ $ item -> getPosition ( ) ] = $ item ; } if ( $ fresh == true ) { $ item -> setPosition ( null ) ; $ item -> setBaseId ( null ) ; $ item -> setId ( null ) ; } } return array_reverse ( $ products , true ) ; }
Retrieves the ordered products from the storage.

@param integer $id Order base ID
@param boolean $fresh Create new items by copying the existing ones and remove their IDs
@return array List of items implementing MShop_Order_Item_Product_Interface
Retrieves the ordered products from the storage .