public function buildXML( MShop_Order_Item_Interface $invoice )
	{
		$orderBaseManager = MShop_Factory::createManager( $this->_getContext(), 'order/base' );
		$criteria = $orderBaseManager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.id', $invoice->getBaseId() ) );
		$result = $orderBaseManager->searchItems( $criteria );

		if( ( $base = reset( $result ) ) === false )
		{
			throw new MShop_Order_Exception( sprintf(
				'Order base item with order ID "%1$s" not found', $invoice->getId()
			) );
		}


		try
		{
			$dom = new DOMDocument('1.0', 'UTF-8');

			$orderlist = $dom->createElement( 'orderlist');
			$orderitem = $dom->createElement( 'orderitem');

			$this->_buildXMLHeader( $invoice, $base, $dom, $orderitem );
			$this->_buildXMLService( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLPrice( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLProducts( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLAddresses( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLAdditional( $orderBaseManager, $base, $dom, $orderitem );

			$orderlist->appendChild( $orderitem );
			$dom->appendChild( $orderlist );
		}
		catch( DOMException $e )
		{
			throw new MShop_Service_Exception(
					sprintf( 'Creating XML file with order data for delivery provider failed: %1$s', $e->getMessage() ), 0, $e );
		}

		$requestXSD = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-request_v1.xsd';

		if( $dom->schemaValidate( $requestXSD ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf('Validation of XML response from delivery provider against schema "%1$s" failed: %2$s', $requestXSD, $dom->saveXML()), parent::ERR_SCHEMA);
		}

		if ( ( $xml = $dom->saveXML() ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'DOM tree of XML response from delivery provider could not be converted to XML string' ), parent::ERR_XML );
		}

		return $xml;
	}
public function buildXML( MShop_Order_Item_Interface $invoice )
	{
		$orderBaseManager = MShop_Factory::createManager( $this->_getContext(), 'order/base' );
		$criteria = $orderBaseManager->createSearch();
		$criteria->setConditions( $criteria->compare( '==', 'order.base.id', $invoice->getBaseId() ) );
		$result = $orderBaseManager->searchItems( $criteria );

		if( ( $base = reset( $result ) ) === false )
		{
			throw new MShop_Order_Exception( sprintf(
				'Order base item with order ID "%1$s" not found', $invoice->getId()
			) );
		}


		try
		{
			$dom = new DOMDocument('1.0', 'UTF-8');

			$orderlist = $dom->createElement( 'orderlist');
			$orderitem = $dom->createElement( 'orderitem');

			$this->_buildXMLHeader( $invoice, $base, $dom, $orderitem );
			$this->_buildXMLService( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLPrice( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLProducts( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLAddresses( $orderBaseManager, $base, $dom, $orderitem );
			$this->_buildXMLAdditional( $orderBaseManager, $base, $dom, $orderitem );

			$orderlist->appendChild( $orderitem );
			$dom->appendChild( $orderlist );
		}
		catch( DOMException $e )
		{
			throw new MShop_Service_Exception(
					sprintf( 'Creating XML file with order data for delivery provider failed: %1$s', $e->getMessage() ), 0, $e );
		}

		$requestXSD = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-request_v1.xsd';

		if( $dom->schemaValidate( $requestXSD ) !== true ) {
			throw new MShop_Service_Exception(
				sprintf('Validation of XML response from delivery provider against schema "%1$s" failed: %2$s', $requestXSD, $dom->saveXML()), parent::ERR_SCHEMA);
		}

		if ( ( $xml = $dom->saveXML() ) === false ) {
			throw new MShop_Service_Exception( sprintf( 'DOM tree of XML response from delivery provider could not be converted to XML string' ), parent::ERR_XML );
		}

		return $xml;
	}
public function buildXML ( MShop_Order_Item_Interface $ invoice ) { $ orderBaseManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base' ) ; $ criteria = $ orderBaseManager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.id' , $ invoice -> getBaseId ( ) ) ) ; $ result = $ orderBaseManager -> searchItems ( $ criteria ) ; if ( ( $ base = reset ( $ result ) ) === false ) { throw new MShop_Order_Exception ( sprintf ( 'Order base item with order ID "%1$s" not found' , $ invoice -> getId ( ) ) ) ; } try { $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ orderlist = $ dom -> createElement ( 'orderlist' ) ; $ orderitem = $ dom -> createElement ( 'orderitem' ) ; $ this -> _buildXMLHeader ( $ invoice , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLService ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLPrice ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLProducts ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLAddresses ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLAdditional ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ orderlist -> appendChild ( $ orderitem ) ; $ dom -> appendChild ( $ orderlist ) ; } catch ( DOMException $ e ) { throw new MShop_Service_Exception ( sprintf ( 'Creating XML file with order data for delivery provider failed: %1$s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } $ requestXSD = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-request_v1.xsd' ; if ( $ dom -> schemaValidate ( $ requestXSD ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Validation of XML response from delivery provider against schema "%1$s" failed: %2$s' , $ requestXSD , $ dom -> saveXML ( ) ) , parent :: ERR_SCHEMA ) ; } if ( ( $ xml = $ dom -> saveXML ( ) ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'DOM tree of XML response from delivery provider could not be converted to XML string' ) , parent :: ERR_XML ) ; } return $ xml ; }
Builds a complete XML string including the order data

@param MShop_Order_Item_Interface $invoice Order of the customer
@return string Validated XML string with order data
@throws MShop_Service_Exception If an error occurs
Builds a complete XML string including the order data