controller/jobs/src/Controller/Jobs/Stock/Import/Csv/Standard.php
protected function importStocks( \Aimeos\MW\Container\Content\Iface $content, $maxcnt )
	{
		$total = 0;
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );

		do
		{
			$count = 0;
			$codes = $data = $items = $types = [];

			while( $content->valid() && $count < $maxcnt )
			{
				$row = $content->current();
				$content->next();

				if( $row[0] == '' ) {
					continue;
				}

				$type = $this->getValue( $row, 2, 'default' );
				$types[$type] = null;
				$codes[] = $row[0];
				$row[2] = $type;
				$data[] = $row;

				$count++;
			}

			if( $count === 0 ) {
				break;
			}

			$items = [];
			$map = $this->getStockItems( $codes, array_keys( $types ) );

			foreach( $data as $entry )
			{
				$code = $entry[0];
				$type = $entry[2];

				if( isset( $map[$code][$type] ) ) {
					$item = $map[$code][$type];
				} else {
					$item = $manager->createItem();
				}

				$items[] = $item->setProductCode( $code )->setType( $type )
					->setStocklevel( $this->getValue( $entry, 1 ) )
					->setDateBack( $this->getValue( $entry, 3 ) );

				unset( $map[$code][$type] );
			}

			$manager->saveItems( $items );
			unset( $items );

			$total += $count;
		}
		while( $count > 0 );

		return $total;
	}
protected function importStocks( \Aimeos\MW\Container\Content\Iface $content, $maxcnt )
	{
		$total = 0;
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );

		do
		{
			$count = 0;
			$codes = $data = $items = $types = [];

			while( $content->valid() && $count < $maxcnt )
			{
				$row = $content->current();
				$content->next();

				if( $row[0] == '' ) {
					continue;
				}

				$type = $this->getValue( $row, 2, 'default' );
				$types[$type] = null;
				$codes[] = $row[0];
				$row[2] = $type;
				$data[] = $row;

				$count++;
			}

			if( $count === 0 ) {
				break;
			}

			$items = [];
			$map = $this->getStockItems( $codes, array_keys( $types ) );

			foreach( $data as $entry )
			{
				$code = $entry[0];
				$type = $entry[2];

				if( isset( $map[$code][$type] ) ) {
					$item = $map[$code][$type];
				} else {
					$item = $manager->createItem();
				}

				$items[] = $item->setProductCode( $code )->setType( $type )
					->setStocklevel( $this->getValue( $entry, 1 ) )
					->setDateBack( $this->getValue( $entry, 3 ) );

				unset( $map[$code][$type] );
			}

			$manager->saveItems( $items );
			unset( $items );

			$total += $count;
		}
		while( $count > 0 );

		return $total;
	}
protected function importStocks ( \ Aimeos \ MW \ Container \ Content \ Iface $ content , $ maxcnt ) { $ total = 0 ; $ manager = \ Aimeos \ MShop :: create ( $ this -> getContext ( ) , 'stock' ) ; do { $ count = 0 ; $ codes = $ data = $ items = $ types = [ ] ; while ( $ content -> valid ( ) && $ count < $ maxcnt ) { $ row = $ content -> current ( ) ; $ content -> next ( ) ; if ( $ row [ 0 ] == '' ) { continue ; } $ type = $ this -> getValue ( $ row , 2 , 'default' ) ; $ types [ $ type ] = null ; $ codes [ ] = $ row [ 0 ] ; $ row [ 2 ] = $ type ; $ data [ ] = $ row ; $ count ++ ; } if ( $ count === 0 ) { break ; } $ items = [ ] ; $ map = $ this -> getStockItems ( $ codes , array_keys ( $ types ) ) ; foreach ( $ data as $ entry ) { $ code = $ entry [ 0 ] ; $ type = $ entry [ 2 ] ; if ( isset ( $ map [ $ code ] [ $ type ] ) ) { $ item = $ map [ $ code ] [ $ type ] ; } else { $ item = $ manager -> createItem ( ) ; } $ items [ ] = $ item -> setProductCode ( $ code ) -> setType ( $ type ) -> setStocklevel ( $ this -> getValue ( $ entry , 1 ) ) -> setDateBack ( $ this -> getValue ( $ entry , 3 ) ) ; unset ( $ map [ $ code ] [ $ type ] ) ; } $ manager -> saveItems ( $ items ) ; unset ( $ items ) ; $ total += $ count ; } while ( $ count > 0 ) ; return $ total ; }
Imports the CSV data and creates new stocks or updates existing ones

@param \Aimeos\MW\Container\Content\Iface $content Content object
@return integer Number of imported stocks
Imports the CSV data and creates new stocks or updates existing ones