Block/Recommended/Mostviewed.php
public function getLoadedProductCollection()
    {
        $params = $this->getRequest()->getParams();
        if (! isset($params['code']) || ! $this->helper->isCodeValid($params['code'])) {
            $this->helper->log('Most viewed no valid code is set');
            return [];
        }

        $productsToDisplay = [];
        $mode = $this->getRequest()->getActionName();
        $limit = $this->recommnededHelper->getDisplayLimitByMode($mode);
        $from  = $this->recommnededHelper->getTimeFromConfig($mode);
        $to = $this->_localeDate->date()->format(\Zend_Date::ISO_8601);
        $catId = $this->getRequest()->getParam('category_id');
        $catName = $this->getRequest()->getParam('category_name');

        $reportProductCollection = $this->catalog->getMostViewedProductCollection($from, $to, $limit, $catId, $catName);

        //product ids from the report product collection
        $productIds = $reportProductCollection->getColumnValues('entity_id');

        $productCollection = $this->catalog->getProductCollectionFromIds($productIds);

        //product collection
        foreach ($productCollection as $_product) {
            //add only saleable products
            if ($_product->isSalable()) {
                $productsToDisplay[] = $_product;
            }
        }

        return $productsToDisplay;
    }
public function getLoadedProductCollection()
    {
        $params = $this->getRequest()->getParams();
        if (! isset($params['code']) || ! $this->helper->isCodeValid($params['code'])) {
            $this->helper->log('Most viewed no valid code is set');
            return [];
        }

        $productsToDisplay = [];
        $mode = $this->getRequest()->getActionName();
        $limit = $this->recommnededHelper->getDisplayLimitByMode($mode);
        $from  = $this->recommnededHelper->getTimeFromConfig($mode);
        $to = $this->_localeDate->date()->format(\Zend_Date::ISO_8601);
        $catId = $this->getRequest()->getParam('category_id');
        $catName = $this->getRequest()->getParam('category_name');

        $reportProductCollection = $this->catalog->getMostViewedProductCollection($from, $to, $limit, $catId, $catName);

        //product ids from the report product collection
        $productIds = $reportProductCollection->getColumnValues('entity_id');

        $productCollection = $this->catalog->getProductCollectionFromIds($productIds);

        //product collection
        foreach ($productCollection as $_product) {
            //add only saleable products
            if ($_product->isSalable()) {
                $productsToDisplay[] = $_product;
            }
        }

        return $productsToDisplay;
    }
public function getLoadedProductCollection ( ) { $ params = $ this -> getRequest ( ) -> getParams ( ) ; if ( ! isset ( $ params [ 'code' ] ) || ! $ this -> helper -> isCodeValid ( $ params [ 'code' ] ) ) { $ this -> helper -> log ( 'Most viewed no valid code is set' ) ; return [ ] ; } $ productsToDisplay = [ ] ; $ mode = $ this -> getRequest ( ) -> getActionName ( ) ; $ limit = $ this -> recommnededHelper -> getDisplayLimitByMode ( $ mode ) ; $ from = $ this -> recommnededHelper -> getTimeFromConfig ( $ mode ) ; $ to = $ this -> _localeDate -> date ( ) -> format ( \ Zend_Date :: ISO_8601 ) ; $ catId = $ this -> getRequest ( ) -> getParam ( 'category_id' ) ; $ catName = $ this -> getRequest ( ) -> getParam ( 'category_name' ) ; $ reportProductCollection = $ this -> catalog -> getMostViewedProductCollection ( $ from , $ to , $ limit , $ catId , $ catName ) ; //product ids from the report product collection $ productIds = $ reportProductCollection -> getColumnValues ( 'entity_id' ) ; $ productCollection = $ this -> catalog -> getProductCollectionFromIds ( $ productIds ) ; //product collection foreach ( $ productCollection as $ _product ) { //add only saleable products if ( $ _product -> isSalable ( ) ) { $ productsToDisplay [ ] = $ _product ; } } return $ productsToDisplay ; }
Get product collection.

@return array
Get product collection .