controller/jobs/src/Controller/Jobs/Customer/Email/Watch/Standard.php
protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers )
	{
		$prodIds = $custIds = [];
		$listItems = $this->getListItems( $context, array_keys( $customers ) );
		$listManager = \Aimeos\MShop::create( $context, 'customer/lists' );

		foreach( $listItems as $id => $listItem )
		{
			$refId = $listItem->getRefId();
			$custIds[ $listItem->getParentId() ][$id] = $refId;
			$prodIds[$refId] = $refId;
		}

		$date = date( 'Y-m-d H:i:s' );
		$products = $this->getProducts( $context, $prodIds, 'default' );

		foreach( $custIds as $custId => $list )
		{
			$custListItems = $listIds = [];

			foreach( $list as $listId => $prodId )
			{
				$listItem = $listItems[$listId];

				if( $listItem->getDateEnd() < $date ) {
					$listIds[] = $listId;
				}

				$custListItems[$listId] = $listItems[$listId];
			}

			try
			{
				$custProducts = $this->getProductList( $products, $custListItems );

				if( !empty( $custProducts ) )
				{
					$addr = $customers[$custId]->getPaymentAddress();
					$this->sendMail( $context, $addr, $custProducts );

					$str = sprintf( 'Sent product notification e-mail to "%1$s"', $addr->getEmail() );
					$context->getLogger()->log( $str, \Aimeos\MW\Logger\Base::DEBUG );

					$listIds += array_keys( $custProducts );
				}
			}
			catch( \Exception $e )
			{
				$str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s';
				$context->getLogger()->log( sprintf( $str, $custId, $e->getMessage() ) );
			}

			$listManager->deleteItems( $listIds );
		}
	}
protected function execute( \Aimeos\MShop\Context\Item\Iface $context, array $customers )
	{
		$prodIds = $custIds = [];
		$listItems = $this->getListItems( $context, array_keys( $customers ) );
		$listManager = \Aimeos\MShop::create( $context, 'customer/lists' );

		foreach( $listItems as $id => $listItem )
		{
			$refId = $listItem->getRefId();
			$custIds[ $listItem->getParentId() ][$id] = $refId;
			$prodIds[$refId] = $refId;
		}

		$date = date( 'Y-m-d H:i:s' );
		$products = $this->getProducts( $context, $prodIds, 'default' );

		foreach( $custIds as $custId => $list )
		{
			$custListItems = $listIds = [];

			foreach( $list as $listId => $prodId )
			{
				$listItem = $listItems[$listId];

				if( $listItem->getDateEnd() < $date ) {
					$listIds[] = $listId;
				}

				$custListItems[$listId] = $listItems[$listId];
			}

			try
			{
				$custProducts = $this->getProductList( $products, $custListItems );

				if( !empty( $custProducts ) )
				{
					$addr = $customers[$custId]->getPaymentAddress();
					$this->sendMail( $context, $addr, $custProducts );

					$str = sprintf( 'Sent product notification e-mail to "%1$s"', $addr->getEmail() );
					$context->getLogger()->log( $str, \Aimeos\MW\Logger\Base::DEBUG );

					$listIds += array_keys( $custProducts );
				}
			}
			catch( \Exception $e )
			{
				$str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s';
				$context->getLogger()->log( sprintf( $str, $custId, $e->getMessage() ) );
			}

			$listManager->deleteItems( $listIds );
		}
	}
protected function execute ( \ Aimeos \ MShop \ Context \ Item \ Iface $ context , array $ customers ) { $ prodIds = $ custIds = [ ] ; $ listItems = $ this -> getListItems ( $ context , array_keys ( $ customers ) ) ; $ listManager = \ Aimeos \ MShop :: create ( $ context , 'customer/lists' ) ; foreach ( $ listItems as $ id => $ listItem ) { $ refId = $ listItem -> getRefId ( ) ; $ custIds [ $ listItem -> getParentId ( ) ] [ $ id ] = $ refId ; $ prodIds [ $ refId ] = $ refId ; } $ date = date ( 'Y-m-d H:i:s' ) ; $ products = $ this -> getProducts ( $ context , $ prodIds , 'default' ) ; foreach ( $ custIds as $ custId => $ list ) { $ custListItems = $ listIds = [ ] ; foreach ( $ list as $ listId => $ prodId ) { $ listItem = $ listItems [ $ listId ] ; if ( $ listItem -> getDateEnd ( ) < $ date ) { $ listIds [ ] = $ listId ; } $ custListItems [ $ listId ] = $ listItems [ $ listId ] ; } try { $ custProducts = $ this -> getProductList ( $ products , $ custListItems ) ; if ( ! empty ( $ custProducts ) ) { $ addr = $ customers [ $ custId ] -> getPaymentAddress ( ) ; $ this -> sendMail ( $ context , $ addr , $ custProducts ) ; $ str = sprintf ( 'Sent product notification e-mail to "%1$s"' , $ addr -> getEmail ( ) ) ; $ context -> getLogger ( ) -> log ( $ str , \ Aimeos \ MW \ Logger \ Base :: DEBUG ) ; $ listIds += array_keys ( $ custProducts ) ; } } catch ( \ Exception $ e ) { $ str = 'Error while trying to send product notification e-mail for customer ID "%1$s": %2$s' ; $ context -> getLogger ( ) -> log ( sprintf ( $ str , $ custId , $ e -> getMessage ( ) ) ) ; } $ listManager -> deleteItems ( $ listIds ) ; } }
Sends product notifications for the given customers in their language

@param \Aimeos\MShop\Context\Item\Iface $context Context item object
@param array $customers List of customer items implementing \Aimeos\MShop\Customer\Item\Iface
Sends product notifications for the given customers in their language