protected function _getServiceItem( MShop_Order_Item_Base_Interface $order, $type, $code = null )
	{
		$context = $this->_getContext();
		$serviceManager = MShop_Factory::createManager( $context, 'service' );

		$search = $serviceManager->createSearch( true );

		$expr = array();

		if( $code !== null ) {
			$expr[] = $search->compare( '==', 'service.code', $code );
		}

		$expr[] = $search->compare( '==', 'service.type.code', $type );
		$expr[] = $search->getConditions();

		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSortations( array( $search->sort( '+', 'service.position' ) ) );

		$result = $serviceManager->searchItems( $search, array( 'media', 'price', 'text' ) );

		foreach( $result as $item )
		{
			$provider = $serviceManager->getProvider( $item );

			if( $provider->isAvailable( $order ) === true )
			{
				$orderServiceManager = MShop_Factory::createManager( $context, 'order/base/service' );
				$orderServiceItem = $orderServiceManager->createItem();
				$orderServiceItem->copyFrom( $item );
				$orderServiceItem->setPrice( $provider->calcPrice( $order ) );

				return $orderServiceItem;
			}
		}
	}
protected function _getServiceItem( MShop_Order_Item_Base_Interface $order, $type, $code = null )
	{
		$context = $this->_getContext();
		$serviceManager = MShop_Factory::createManager( $context, 'service' );

		$search = $serviceManager->createSearch( true );

		$expr = array();

		if( $code !== null ) {
			$expr[] = $search->compare( '==', 'service.code', $code );
		}

		$expr[] = $search->compare( '==', 'service.type.code', $type );
		$expr[] = $search->getConditions();

		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSortations( array( $search->sort( '+', 'service.position' ) ) );

		$result = $serviceManager->searchItems( $search, array( 'media', 'price', 'text' ) );

		foreach( $result as $item )
		{
			$provider = $serviceManager->getProvider( $item );

			if( $provider->isAvailable( $order ) === true )
			{
				$orderServiceManager = MShop_Factory::createManager( $context, 'order/base/service' );
				$orderServiceItem = $orderServiceManager->createItem();
				$orderServiceItem->copyFrom( $item );
				$orderServiceItem->setPrice( $provider->calcPrice( $order ) );

				return $orderServiceItem;
			}
		}
	}
protected function _getServiceItem ( MShop_Order_Item_Base_Interface $ order , $ type , $ code = null ) { $ context = $ this -> _getContext ( ) ; $ serviceManager = MShop_Factory :: createManager ( $ context , 'service' ) ; $ search = $ serviceManager -> createSearch ( true ) ; $ expr = array ( ) ; if ( $ code !== null ) { $ expr [ ] = $ search -> compare ( '==' , 'service.code' , $ code ) ; } $ expr [ ] = $ search -> compare ( '==' , 'service.type.code' , $ type ) ; $ expr [ ] = $ search -> getConditions ( ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'service.position' ) ) ) ; $ result = $ serviceManager -> searchItems ( $ search , array ( 'media' , 'price' , 'text' ) ) ; foreach ( $ result as $ item ) { $ provider = $ serviceManager -> getProvider ( $ item ) ; if ( $ provider -> isAvailable ( $ order ) === true ) { $ orderServiceManager = MShop_Factory :: createManager ( $ context , 'order/base/service' ) ; $ orderServiceItem = $ orderServiceManager -> createItem ( ) ; $ orderServiceItem -> copyFrom ( $ item ) ; $ orderServiceItem -> setPrice ( $ provider -> calcPrice ( $ order ) ) ; return $ orderServiceItem ; } } }
Returns the order service item for the given type and code if available.

@param MShop_Order_Item_Base_Interface $order Basket of the customer
@param string $type Service type constant from MShop_Order_Item_Base_Service_Abstract
@param string|null $code Service item code
@param MShop_Order_Item_Base_Service_Interface|null Order service item if available or null otherwise
Returns the order service item for the given type and code if available .