protected function _addProducts( $parentid, array $data, $domain )
	{
		$context =  $this->_getContext();
		$productManager = MShop_Factory::createManager( $context, 'product' );
		$listManager = MShop_Factory::createManager( $context, $domain . '/list' );


		$listItem = $listManager->createItem();
		$listItem->setParentId( $parentid );
		$listItem->setDomain( 'product' );


		$codes = array();

		foreach( $data as $entry ) {
			$codes[ $entry['code'] ] = null;
		}

		$search = $productManager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.code', array_keys( $codes ) ) );
		$products = $productManager->searchItems( $search );

		foreach( $products as $product ) {
			$codes[ $product->getCode() ] = $product->getId();
		}


		foreach( $data as $entry )
		{
			if( !isset( $codes[ $entry['code'] ] ) ) {
				throw new Exception( sprintf( 'No product for code "%1$s" found', $entry['code'] ) );
			}

			$listItem->setId( null );
			$listItem->setTypeId( $this->_getTypeId( $domain . '/list/type', 'product', $entry['list-type'] ) );
			$listItem->setDateStart( $entry['list-start'] );
			$listItem->setDateEnd( $entry['list-end'] );
			$listItem->setConfig( $entry['list-config'] );
			$listItem->setPosition( $entry['list-position'] );
			$listItem->setStatus( $entry['list-status'] );
			$listItem->setRefId( $codes[ $entry['code'] ] );

			$listManager->saveItem( $listItem, false );
		}
	}
protected function _addProducts( $parentid, array $data, $domain )
	{
		$context =  $this->_getContext();
		$productManager = MShop_Factory::createManager( $context, 'product' );
		$listManager = MShop_Factory::createManager( $context, $domain . '/list' );


		$listItem = $listManager->createItem();
		$listItem->setParentId( $parentid );
		$listItem->setDomain( 'product' );


		$codes = array();

		foreach( $data as $entry ) {
			$codes[ $entry['code'] ] = null;
		}

		$search = $productManager->createSearch();
		$search->setConditions( $search->compare( '==', 'product.code', array_keys( $codes ) ) );
		$products = $productManager->searchItems( $search );

		foreach( $products as $product ) {
			$codes[ $product->getCode() ] = $product->getId();
		}


		foreach( $data as $entry )
		{
			if( !isset( $codes[ $entry['code'] ] ) ) {
				throw new Exception( sprintf( 'No product for code "%1$s" found', $entry['code'] ) );
			}

			$listItem->setId( null );
			$listItem->setTypeId( $this->_getTypeId( $domain . '/list/type', 'product', $entry['list-type'] ) );
			$listItem->setDateStart( $entry['list-start'] );
			$listItem->setDateEnd( $entry['list-end'] );
			$listItem->setConfig( $entry['list-config'] );
			$listItem->setPosition( $entry['list-position'] );
			$listItem->setStatus( $entry['list-status'] );
			$listItem->setRefId( $codes[ $entry['code'] ] );

			$listManager->saveItem( $listItem, false );
		}
	}
protected function _addProducts ( $ parentid , array $ data , $ domain ) { $ context = $ this -> _getContext ( ) ; $ productManager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ listManager = MShop_Factory :: createManager ( $ context , $ domain . '/list' ) ; $ listItem = $ listManager -> createItem ( ) ; $ listItem -> setParentId ( $ parentid ) ; $ listItem -> setDomain ( 'product' ) ; $ codes = array ( ) ; foreach ( $ data as $ entry ) { $ codes [ $ entry [ 'code' ] ] = null ; } $ search = $ productManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.code' , array_keys ( $ codes ) ) ) ; $ products = $ productManager -> searchItems ( $ search ) ; foreach ( $ products as $ product ) { $ codes [ $ product -> getCode ( ) ] = $ product -> getId ( ) ; } foreach ( $ data as $ entry ) { if ( ! isset ( $ codes [ $ entry [ 'code' ] ] ) ) { throw new Exception ( sprintf ( 'No product for code "%1$s" found' , $ entry [ 'code' ] ) ) ; } $ listItem -> setId ( null ) ; $ listItem -> setTypeId ( $ this -> _getTypeId ( $ domain . '/list/type' , 'product' , $ entry [ 'list-type' ] ) ) ; $ listItem -> setDateStart ( $ entry [ 'list-start' ] ) ; $ listItem -> setDateEnd ( $ entry [ 'list-end' ] ) ; $ listItem -> setConfig ( $ entry [ 'list-config' ] ) ; $ listItem -> setPosition ( $ entry [ 'list-position' ] ) ; $ listItem -> setStatus ( $ entry [ 'list-status' ] ) ; $ listItem -> setRefId ( $ codes [ $ entry [ 'code' ] ] ) ; $ listManager -> saveItem ( $ listItem , false ) ; } }
Adds the products to the given parent in the database.

@param string $parentid ID of the parent item where the products should be associated to
@param array $data Two dimensional associative list of product data
@param string $domain Domain name the texts should be added to, e.g. 'catalog'
Adds the products to the given parent in the database .