controller/common/src/Controller/Common/Product/Import/Csv/Processor/Stock/Standard.php
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
		$manager->begin();

		try
		{
			$map = $this->getMappedChunk( $data, $this->getMapping() );
			$items = $this->getStockItems( $product->getCode() );

			foreach( $map as $pos => $list )
			{
				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
					continue;
				}

				$list['stock.productcode'] = $product->getCode();
				$list['stock.dateback'] = $this->getValue( $list, 'stock.dateback' );
				$list['stock.stocklevel'] = $this->getValue( $list, 'stock.stocklevel' );
				$list['stock.type'] = $this->getValue( $list, 'stock.type', 'default' );

				if( !in_array( $list['stock.type'], $this->types ) )
				{
					$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock' );
					throw new \Aimeos\Controller\Common\Exception( $msg );
				}

				if( ( $item = array_pop( $items ) ) === null ) {
					$item = $manager->createItem();
				}

				$manager->saveItem( $item->fromArray( $list ), false );
			}

			$manager->deleteItems( array_keys( $items ) );

			$data = $this->getObject()->process( $product, $data );

			$manager->commit();
		}
		catch( \Exception $e )
		{
			$manager->rollback();
			throw $e;
		}

		return $data;
	}
public function process( \Aimeos\MShop\Product\Item\Iface $product, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'stock' );
		$manager->begin();

		try
		{
			$map = $this->getMappedChunk( $data, $this->getMapping() );
			$items = $this->getStockItems( $product->getCode() );

			foreach( $map as $pos => $list )
			{
				if( !array_key_exists( 'stock.stocklevel', $list ) ) {
					continue;
				}

				$list['stock.productcode'] = $product->getCode();
				$list['stock.dateback'] = $this->getValue( $list, 'stock.dateback' );
				$list['stock.stocklevel'] = $this->getValue( $list, 'stock.stocklevel' );
				$list['stock.type'] = $this->getValue( $list, 'stock.type', 'default' );

				if( !in_array( $list['stock.type'], $this->types ) )
				{
					$msg = sprintf( 'Invalid type "%1$s" (%2$s)', $list['stock.type'], 'stock' );
					throw new \Aimeos\Controller\Common\Exception( $msg );
				}

				if( ( $item = array_pop( $items ) ) === null ) {
					$item = $manager->createItem();
				}

				$manager->saveItem( $item->fromArray( $list ), false );
			}

			$manager->deleteItems( array_keys( $items ) );

			$data = $this->getObject()->process( $product, $data );

			$manager->commit();
		}
		catch( \Exception $e )
		{
			$manager->rollback();
			throw $e;
		}

		return $data;
	}
public function process ( \ Aimeos \ MShop \ Product \ Item \ Iface $ product , array $ data ) { $ manager = \ Aimeos \ MShop :: create ( $ this -> getContext ( ) , 'stock' ) ; $ manager -> begin ( ) ; try { $ map = $ this -> getMappedChunk ( $ data , $ this -> getMapping ( ) ) ; $ items = $ this -> getStockItems ( $ product -> getCode ( ) ) ; foreach ( $ map as $ pos => $ list ) { if ( ! array_key_exists ( 'stock.stocklevel' , $ list ) ) { continue ; } $ list [ 'stock.productcode' ] = $ product -> getCode ( ) ; $ list [ 'stock.dateback' ] = $ this -> getValue ( $ list , 'stock.dateback' ) ; $ list [ 'stock.stocklevel' ] = $ this -> getValue ( $ list , 'stock.stocklevel' ) ; $ list [ 'stock.type' ] = $ this -> getValue ( $ list , 'stock.type' , 'default' ) ; if ( ! in_array ( $ list [ 'stock.type' ] , $ this -> types ) ) { $ msg = sprintf ( 'Invalid type "%1$s" (%2$s)' , $ list [ 'stock.type' ] , 'stock' ) ; throw new \ Aimeos \ Controller \ Common \ Exception ( $ msg ) ; } if ( ( $ item = array_pop ( $ items ) ) === null ) { $ item = $ manager -> createItem ( ) ; } $ manager -> saveItem ( $ item -> fromArray ( $ list ) , false ) ; } $ manager -> deleteItems ( array_keys ( $ items ) ) ; $ data = $ this -> getObject ( ) -> process ( $ product , $ data ) ; $ manager -> commit ( ) ; } catch ( \ Exception $ e ) { $ manager -> rollback ( ) ; throw $ e ; } return $ data ; }
Saves the product stock related data to the storage

@param \Aimeos\MShop\Product\Item\Iface $product Product item with associated items
@param array $data List of CSV fields with position as key and data as value
@return array List of data which hasn't been imported
Saves the product stock related data to the storage