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;
	}