controller/jobs/src/Controller/Jobs/Coupon/Import/Csv/Code/Standard.php
protected function import( array $items, array $data, $couponId,
		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor )
	{
		$errors = 0;
		$context = $this->getContext();
		$manager = \Aimeos\MShop::create( $context, 'coupon/code' );

		foreach( $data as $code => $list )
		{
			$manager->begin();

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

				$item->setParentId( $couponId );
				$list = $processor->process( $item, $list );

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

				$msg = sprintf( 'Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage() );
				$context->getLogger()->log( $msg );

				$errors++;
			}
		}

		return $errors;
	}
protected function import( array $items, array $data, $couponId,
		\Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor )
	{
		$errors = 0;
		$context = $this->getContext();
		$manager = \Aimeos\MShop::create( $context, 'coupon/code' );

		foreach( $data as $code => $list )
		{
			$manager->begin();

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

				$item->setParentId( $couponId );
				$list = $processor->process( $item, $list );

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

				$msg = sprintf( 'Unable to import coupon with code "%1$s": %2$s', $code, $e->getMessage() );
				$context->getLogger()->log( $msg );

				$errors++;
			}
		}

		return $errors;
	}
protected function import ( array $ items , array $ data , $ couponId , \ Aimeos \ Controller \ Common \ Coupon \ Import \ Csv \ Processor \ Iface $ processor ) { $ errors = 0 ; $ context = $ this -> getContext ( ) ; $ manager = \ Aimeos \ MShop :: create ( $ context , 'coupon/code' ) ; foreach ( $ data as $ code => $ list ) { $ manager -> begin ( ) ; try { if ( isset ( $ items [ $ code ] ) ) { $ item = $ items [ $ code ] ; } else { $ item = $ manager -> createItem ( ) ; } $ item -> setParentId ( $ couponId ) ; $ list = $ processor -> process ( $ item , $ list ) ; $ manager -> commit ( ) ; } catch ( \ Exception $ e ) { $ manager -> rollback ( ) ; $ msg = sprintf ( 'Unable to import coupon with code "%1$s": %2$s' , $ code , $ e -> getMessage ( ) ) ; $ context -> getLogger ( ) -> log ( $ msg ) ; $ errors ++ ; } } return $ errors ; }
Imports the CSV data and creates new coupons or updates existing ones

@param \Aimeos\MShop\Coupon\Item\Code\Iface[] $items List of coupons code items
@param array $data Associative list of import data as index/value pairs
@param string $couponId ID of the coupon item the coupon code should be added to
@param \Aimeos\Controller\Common\Coupon\Import\Csv\Processor\Iface $processor Processor object
@return integer Number of coupons that couldn't be imported
@throws \Aimeos\Controller\Jobs\Exception
Imports the CSV data and creates new coupons or updates existing ones