protected function _addProductStock( $productid, array $data )
	{
		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock/warehouse' );

		$warehouses = array();
		foreach( $manager->searchItems( $manager->createSearch() ) as $id => $item ) {
			$warehouses[ $item->getCode() ] = $id;
		}

		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock' );

		$item = $manager->createItem();
		$item->setProductId( $productid );

		foreach( $data as $entry )
		{
			$item->setId( null );
			$item->setDateBack( $entry['dateback'] );
			$item->setStockLevel( $entry['stocklevel'] );
			$item->setWarehouseId( $warehouses[ $entry['warehouse'] ] );

			$manager->saveItem( $item, false );
		}
	}
protected function _addProductStock( $productid, array $data )
	{
		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock/warehouse' );

		$warehouses = array();
		foreach( $manager->searchItems( $manager->createSearch() ) as $id => $item ) {
			$warehouses[ $item->getCode() ] = $id;
		}

		$manager = MShop_Factory::createManager( $this->_getContext(), 'product/stock' );

		$item = $manager->createItem();
		$item->setProductId( $productid );

		foreach( $data as $entry )
		{
			$item->setId( null );
			$item->setDateBack( $entry['dateback'] );
			$item->setStockLevel( $entry['stocklevel'] );
			$item->setWarehouseId( $warehouses[ $entry['warehouse'] ] );

			$manager->saveItem( $item, false );
		}
	}
protected function _addProductStock ( $ productid , array $ data ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product/stock/warehouse' ) ; $ warehouses = array ( ) ; foreach ( $ manager -> searchItems ( $ manager -> createSearch ( ) ) as $ id => $ item ) { $ warehouses [ $ item -> getCode ( ) ] = $ id ; } $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product/stock' ) ; $ item = $ manager -> createItem ( ) ; $ item -> setProductId ( $ productid ) ; foreach ( $ data as $ entry ) { $ item -> setId ( null ) ; $ item -> setDateBack ( $ entry [ 'dateback' ] ) ; $ item -> setStockLevel ( $ entry [ 'stocklevel' ] ) ; $ item -> setWarehouseId ( $ warehouses [ $ entry [ 'warehouse' ] ] ) ; $ manager -> saveItem ( $ item , false ) ; } }
Adds stock levels to the given product in the database.

@param string $productid ID of the product item where the stock levels should be associated to
@param array $data Two dimensional associative list of product stock data
Adds stock levels to the given product in the database .