Block/Recommended/Product.php
public function getLoadedProductCollection()
    {
        $params = $this->getRequest()->getParams();
        //check for param code and id
        if (! isset($params['order_id']) ||
            ! isset($params['code']) ||
            ! $this->helper->isCodeValid($params['code'])
        ) {
            $this->helper->log('Product recommendation for this order not found or invalid code');
            return [];
        }

        //products to be displayed for recommended pages
        $orderId = (int) $this->getRequest()->getParam('order_id');
        //display mode based on the action name
        $mode = $this->getRequest()->getActionName();
        $orderModel = $this->orderFactory->create();
        $this->orderResource->load($orderModel, $orderId);
        //number of product items to be displayed
        $limit = $this->recommendedHelper
            ->getDisplayLimitByMode($mode);
        $orderItems = $orderModel->getAllItems();
        $numItems = count($orderItems);

        //no product found to display
        if ($numItems == 0 || !$limit) {
            return [];
        } elseif ($numItems > $limit) {
            $maxPerChild = 1;
        } else {
            $maxPerChild = number_format($limit / $numItems);
        }

        $this->helper->log(
            'DYNAMIC PRODUCTS : limit ' . $limit . ' products : '
            . $numItems . ', max per child : ' . $maxPerChild
        );

        $productsToDisplayCounter = 0;
        $productsToDisplay = $this->recommendedHelper->getProductsToDisplay(
            $orderItems,
            $mode,
            $productsToDisplayCounter,
            $limit,
            $maxPerChild
        );

        //check for more space to fill up the table with fallback products
        if ($productsToDisplayCounter < $limit) {
            $productsToDisplay = $this->recommendedHelper->fillProductsToDisplay(
                $productsToDisplay,
                $productsToDisplayCounter,
                $limit
            );
        }

        $this->helper->log('loaded product to display ' . count($productsToDisplay));

        return $productsToDisplay;
    }
public function getLoadedProductCollection()
    {
        $params = $this->getRequest()->getParams();
        //check for param code and id
        if (! isset($params['order_id']) ||
            ! isset($params['code']) ||
            ! $this->helper->isCodeValid($params['code'])
        ) {
            $this->helper->log('Product recommendation for this order not found or invalid code');
            return [];
        }

        //products to be displayed for recommended pages
        $orderId = (int) $this->getRequest()->getParam('order_id');
        //display mode based on the action name
        $mode = $this->getRequest()->getActionName();
        $orderModel = $this->orderFactory->create();
        $this->orderResource->load($orderModel, $orderId);
        //number of product items to be displayed
        $limit = $this->recommendedHelper
            ->getDisplayLimitByMode($mode);
        $orderItems = $orderModel->getAllItems();
        $numItems = count($orderItems);

        //no product found to display
        if ($numItems == 0 || !$limit) {
            return [];
        } elseif ($numItems > $limit) {
            $maxPerChild = 1;
        } else {
            $maxPerChild = number_format($limit / $numItems);
        }

        $this->helper->log(
            'DYNAMIC PRODUCTS : limit ' . $limit . ' products : '
            . $numItems . ', max per child : ' . $maxPerChild
        );

        $productsToDisplayCounter = 0;
        $productsToDisplay = $this->recommendedHelper->getProductsToDisplay(
            $orderItems,
            $mode,
            $productsToDisplayCounter,
            $limit,
            $maxPerChild
        );

        //check for more space to fill up the table with fallback products
        if ($productsToDisplayCounter < $limit) {
            $productsToDisplay = $this->recommendedHelper->fillProductsToDisplay(
                $productsToDisplay,
                $productsToDisplayCounter,
                $limit
            );
        }

        $this->helper->log('loaded product to display ' . count($productsToDisplay));

        return $productsToDisplay;
    }
public function getLoadedProductCollection ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; //check for param code and id if ( ! isset ( $ params [ 'order_id' ] ) || ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Product recommendation for this order not found or invalid code' ) ; return [ ] ; } //products to be displayed for recommended pages $ orderId = ( int ) $ this -> getRequest ( ) -> getParam ( 'order_id' ) ; //display mode based on the action name $ mode = $ this -> getRequest ( ) -> getActionName ( ) ; $ orderModel = $ this -> orderFactory -> create ( ) ; $ this -> orderResource -> load ( $ orderModel , $ orderId ) ; //number of product items to be displayed $ limit = $ this -> recommendedHelper -> getDisplayLimitByMode ( $ mode ) ; $ orderItems = $ orderModel -> getAllItems ( ) ; $ numItems = count ( $ orderItems ) ; //no product found to display if ( $ numItems == 0 || ! $ limit ) { return [ ] ; } elseif ( $ numItems > $ limit ) { $ maxPerChild = 1 ; } else { $ maxPerChild = number_format ( $ limit / $ numItems ) ; } $ this -> helper -> log ( 'DYNAMIC PRODUCTS : limit ' . $ limit . ' products : ' . $ numItems . ', max per child : ' . $ maxPerChild ) ; $ productsToDisplayCounter = 0 ; $ productsToDisplay = $ this -> recommendedHelper -> getProductsToDisplay ( $ orderItems , $ mode , $ productsToDisplayCounter , $ limit , $ maxPerChild ) ; //check for more space to fill up the table with fallback products if ( $ productsToDisplayCounter < $ limit ) { $ productsToDisplay = $ this -> recommendedHelper -> fillProductsToDisplay ( $ productsToDisplay , $ productsToDisplayCounter , $ limit ) ; } $ this -> helper -> log ( 'loaded product to display ' . count ( $ productsToDisplay ) ) ; return $ productsToDisplay ; }
Get the products to display for recommendation.

@return array
Get the products to display for recommendation .