client/html/src/Client/Html/Account/Favorite/Standard.php
protected function addFavorites( array $ids )
	{
		$context = $this->getContext();

		/** client/html/account/favorite/standard/maxitems
		 * Maximum number of products that can be favorites
		 *
		 * This option limits the number of products users can add to their
		 * favorite list. It must be a positive integer value greater than 0.
		 *
		 * @param integer Number of products
		 * @since 2019.04
		 * @category User
		 * @category Developer
		 */
		$max = $context->getConfig()->get( 'client/html/account/favorite/standard/maxitems', 100 );

		$cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' );
		$item = $cntl->uses( ['product' => ['favorite']] )->get();

		if( count( $item->getRefItems( 'product', null, 'favorite' ) ) + count( $ids ) > $max )
		{
			$msg = sprintf( $context->getI18n()->dt( 'client', 'You can only save up to %1$s products as favorites' ), $max );
			throw new \Aimeos\Client\Html\Exception( $msg );
		}

		foreach( $ids as $id )
		{
			if( ( $listItem = $item->getListItem( 'product', 'favorite', $id ) ) === null ) {
				$listItem = $cntl->createListItem();
			}
			$cntl->addListItem( 'product', $listItem->setType( 'favorite' )->setRefId( $id ) );
		}

		$cntl->store();
	}
protected function addFavorites( array $ids )
	{
		$context = $this->getContext();

		/** client/html/account/favorite/standard/maxitems
		 * Maximum number of products that can be favorites
		 *
		 * This option limits the number of products users can add to their
		 * favorite list. It must be a positive integer value greater than 0.
		 *
		 * @param integer Number of products
		 * @since 2019.04
		 * @category User
		 * @category Developer
		 */
		$max = $context->getConfig()->get( 'client/html/account/favorite/standard/maxitems', 100 );

		$cntl = \Aimeos\Controller\Frontend::create( $context, 'customer' );
		$item = $cntl->uses( ['product' => ['favorite']] )->get();

		if( count( $item->getRefItems( 'product', null, 'favorite' ) ) + count( $ids ) > $max )
		{
			$msg = sprintf( $context->getI18n()->dt( 'client', 'You can only save up to %1$s products as favorites' ), $max );
			throw new \Aimeos\Client\Html\Exception( $msg );
		}

		foreach( $ids as $id )
		{
			if( ( $listItem = $item->getListItem( 'product', 'favorite', $id ) ) === null ) {
				$listItem = $cntl->createListItem();
			}
			$cntl->addListItem( 'product', $listItem->setType( 'favorite' )->setRefId( $id ) );
		}

		$cntl->store();
	}
protected function addFavorites ( array $ ids ) { $ context = $ this -> getContext ( ) ; /** client/html/account/favorite/standard/maxitems
		 * Maximum number of products that can be favorites
		 *
		 * This option limits the number of products users can add to their
		 * favorite list. It must be a positive integer value greater than 0.
		 *
		 * @param integer Number of products
		 * @since 2019.04
		 * @category User
		 * @category Developer
		 */ $ max = $ context -> getConfig ( ) -> get ( 'client/html/account/favorite/standard/maxitems' , 100 ) ; $ cntl = \ Aimeos \ Controller \ Frontend :: create ( $ context , 'customer' ) ; $ item = $ cntl -> uses ( [ 'product' => [ 'favorite' ] ] ) -> get ( ) ; if ( count ( $ item -> getRefItems ( 'product' , null , 'favorite' ) ) + count ( $ ids ) > $ max ) { $ msg = sprintf ( $ context -> getI18n ( ) -> dt ( 'client' , 'You can only save up to %1$s products as favorites' ) , $ max ) ; throw new \ Aimeos \ Client \ Html \ Exception ( $ msg ) ; } foreach ( $ ids as $ id ) { if ( ( $ listItem = $ item -> getListItem ( 'product' , 'favorite' , $ id ) ) === null ) { $ listItem = $ cntl -> createListItem ( ) ; } $ cntl -> addListItem ( 'product' , $ listItem -> setType ( 'favorite' ) -> setRefId ( $ id ) ) ; } $ cntl -> store ( ) ; }
Adds new product favorite references to the given customer

@param array $ids List of product IDs
Adds new product favorite references to the given customer