Helper/Recommended.php
public function getProductsToDisplay($items, $mode, &$productsToDisplayCounter, $limit, $maxPerChild)
    {
        $productsToDisplay = [];

        foreach ($items as $item) {
            //parent product
            $productModel = $item->getProduct();
            //check for product exists
            if ($productModel->getId()) {
                //get single product for current mode
                $recommendedProductIds = $this->getRecommendedProduct($productModel, $mode);
                $recommendedProducts = $this->catalog->getProductCollectionFromIds($recommendedProductIds);

                $this->addRecommendedProducts(
                    $productsToDisplayCounter,
                    $limit,
                    $maxPerChild,
                    $recommendedProducts,
                    $productsToDisplay
                );
            }
            //have reached the limit don't loop for more
            if ($productsToDisplayCounter == $limit) {
                break;
            }
        }

        return $productsToDisplay;
    }
public function getProductsToDisplay($items, $mode, &$productsToDisplayCounter, $limit, $maxPerChild)
    {
        $productsToDisplay = [];

        foreach ($items as $item) {
            //parent product
            $productModel = $item->getProduct();
            //check for product exists
            if ($productModel->getId()) {
                //get single product for current mode
                $recommendedProductIds = $this->getRecommendedProduct($productModel, $mode);
                $recommendedProducts = $this->catalog->getProductCollectionFromIds($recommendedProductIds);

                $this->addRecommendedProducts(
                    $productsToDisplayCounter,
                    $limit,
                    $maxPerChild,
                    $recommendedProducts,
                    $productsToDisplay
                );
            }
            //have reached the limit don't loop for more
            if ($productsToDisplayCounter == $limit) {
                break;
            }
        }

        return $productsToDisplay;
    }
public function getProductsToDisplay ( $ items , $ mode , & $ productsToDisplayCounter , $ limit , $ maxPerChild ) { $ productsToDisplay = [ ] ; foreach ( $ items as $ item ) { //parent product $ productModel = $ item -> getProduct ( ) ; //check for product exists if ( $ productModel -> getId ( ) ) { //get single product for current mode $ recommendedProductIds = $ this -> getRecommendedProduct ( $ productModel , $ mode ) ; $ recommendedProducts = $ this -> catalog -> getProductCollectionFromIds ( $ recommendedProductIds ) ; $ this -> addRecommendedProducts ( $ productsToDisplayCounter , $ limit , $ maxPerChild , $ recommendedProducts , $ productsToDisplay ) ; } //have reached the limit don't loop for more if ( $ productsToDisplayCounter == $ limit ) { break ; } } return $ productsToDisplay ; }
Get products to display

@param array $items
@param string $mode
@param int $productsToDisplayCounter
@param int $limit
@param int $maxPerChild

@return array
Get products to display