controller/jobs/src/Controller/Jobs/Product/Bought/Standard.php
protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date )
	{
		$refIds = [];
		$context = $this->getContext();

		$catalogListManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );


		$search = $baseProductManager->createSearch();
		$func = $search->createFunction( 'order.base.product.count', array( (string) $id ) );
		$expr = array(
			$search->compare( '==', 'order.base.product.productid', $prodIds ),
			$search->compare( '>', 'order.base.product.ctime', $date ),
			$search->compare( '==', $func, 1 ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		$relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );


		$search = $catalogListManager->createSearch();
		$expr = array(
			$search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ),
			$search->compare( '==', 'catalog.lists.domain', 'product' ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		foreach( $catalogListManager->searchItems( $search ) as $listItem ) {
			$refIds[$listItem->getRefId()] = true;
		}


		unset( $relativeCounts[$id] );
		$supportA = $count / $total;
		$products = [];

		foreach( $relativeCounts as $prodId => $relCnt )
		{
			if( !isset( $refIds[$prodId] ) ) {
				continue;
			}

			$supportAB = $relCnt / $total;

			if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) {
				$products[$prodId] = $conf;
			}
		}

		arsort( $products );

		return array_keys( array_slice( $products, 0, $maxItems, true ) );
	}
protected function getSuggestions( $id, $prodIds, $count, $total, $maxItems, $minSupport, $minConfidence, $date )
	{
		$refIds = [];
		$context = $this->getContext();

		$catalogListManager = \Aimeos\MShop::create( $context, 'catalog/lists' );
		$baseProductManager = \Aimeos\MShop::create( $context, 'order/base/product' );


		$search = $baseProductManager->createSearch();
		$func = $search->createFunction( 'order.base.product.count', array( (string) $id ) );
		$expr = array(
			$search->compare( '==', 'order.base.product.productid', $prodIds ),
			$search->compare( '>', 'order.base.product.ctime', $date ),
			$search->compare( '==', $func, 1 ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		$relativeCounts = $baseProductManager->aggregate( $search, 'order.base.product.productid' );


		$search = $catalogListManager->createSearch();
		$expr = array(
			$search->compare( '==', 'catalog.lists.refid', array_keys( $relativeCounts ) ),
			$search->compare( '==', 'catalog.lists.domain', 'product' ),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );

		foreach( $catalogListManager->searchItems( $search ) as $listItem ) {
			$refIds[$listItem->getRefId()] = true;
		}


		unset( $relativeCounts[$id] );
		$supportA = $count / $total;
		$products = [];

		foreach( $relativeCounts as $prodId => $relCnt )
		{
			if( !isset( $refIds[$prodId] ) ) {
				continue;
			}

			$supportAB = $relCnt / $total;

			if( $supportAB > $minSupport && ( $conf = ( $supportAB / $supportA ) ) > $minConfidence ) {
				$products[$prodId] = $conf;
			}
		}

		arsort( $products );

		return array_keys( array_slice( $products, 0, $maxItems, true ) );
	}
protected function getSuggestions ( $ id , $ prodIds , $ count , $ total , $ maxItems , $ minSupport , $ minConfidence , $ date ) { $ refIds = [ ] ; $ context = $ this -> getContext ( ) ; $ catalogListManager = \ Aimeos \ MShop :: create ( $ context , 'catalog/lists' ) ; $ baseProductManager = \ Aimeos \ MShop :: create ( $ context , 'order/base/product' ) ; $ search = $ baseProductManager -> createSearch ( ) ; $ func = $ search -> createFunction ( 'order.base.product.count' , array ( ( string ) $ id ) ) ; $ expr = array ( $ search -> compare ( '==' , 'order.base.product.productid' , $ prodIds ) , $ search -> compare ( '>' , 'order.base.product.ctime' , $ date ) , $ search -> compare ( '==' , $ func , 1 ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ relativeCounts = $ baseProductManager -> aggregate ( $ search , 'order.base.product.productid' ) ; $ search = $ catalogListManager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'catalog.lists.refid' , array_keys ( $ relativeCounts ) ) , $ search -> compare ( '==' , 'catalog.lists.domain' , 'product' ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; foreach ( $ catalogListManager -> searchItems ( $ search ) as $ listItem ) { $ refIds [ $ listItem -> getRefId ( ) ] = true ; } unset ( $ relativeCounts [ $ id ] ) ; $ supportA = $ count / $ total ; $ products = [ ] ; foreach ( $ relativeCounts as $ prodId => $ relCnt ) { if ( ! isset ( $ refIds [ $ prodId ] ) ) { continue ; } $ supportAB = $ relCnt / $ total ; if ( $ supportAB > $ minSupport && ( $ conf = ( $ supportAB / $ supportA ) ) > $ minConfidence ) { $ products [ $ prodId ] = $ conf ; } } arsort ( $ products ) ; return array_keys ( array_slice ( $ products , 0 , $ maxItems , true ) ) ; }
Returns the IDs of the suggested products.

@param string $id Product ID to calculate the suggestions for
@param string[] $prodIds List of product IDs to create suggestions for
@param integer $count Number of ordered products
@param integer $total Total number of orders
@param integer $maxItems Maximum number of suggestions
@param float $minSupport Minium support value for calculating the suggested products
@param float $minConfidence Minium confidence value for calculating the suggested products
@param string $date Date in YYYY-MM-DD HH:mm:ss format after which orders should be used for calculations
@return array List of suggested product IDs as key and their confidence as value
Returns the IDs of the suggested products .