Model/ResourceModel/Catalog.php
public function getRecentlyViewed($customerId, $limit)
    {
        $attributes = $this->config->getProductAttributes();

        $this->productIndexcollection->addAttributeToSelect($attributes);
        $this->productIndexcollection->setCustomerId($customerId);
        $this->productIndexcollection->addUrlRewrite()->setPageSize(
            $limit
        )->setCurPage(
            1
        );

        /* Price data is added to consider item stock status using price index */
        $collection = $this->productIndexcollection->addPriceData()
            ->addIndexFilter()
            ->setAddedAtOrder()
            ->setVisibility($this->productVisibility->getVisibleInSiteIds());

        return $collection->getColumnValues('product_id');
    }
public function getRecentlyViewed($customerId, $limit)
    {
        $attributes = $this->config->getProductAttributes();

        $this->productIndexcollection->addAttributeToSelect($attributes);
        $this->productIndexcollection->setCustomerId($customerId);
        $this->productIndexcollection->addUrlRewrite()->setPageSize(
            $limit
        )->setCurPage(
            1
        );

        /* Price data is added to consider item stock status using price index */
        $collection = $this->productIndexcollection->addPriceData()
            ->addIndexFilter()
            ->setAddedAtOrder()
            ->setVisibility($this->productVisibility->getVisibleInSiteIds());

        return $collection->getColumnValues('product_id');
    }
public function getRecentlyViewed ( $ customerId , $ limit ) { $ attributes = $ this -> config -> getProductAttributes ( ) ; $ this -> productIndexcollection -> addAttributeToSelect ( $ attributes ) ; $ this -> productIndexcollection -> setCustomerId ( $ customerId ) ; $ this -> productIndexcollection -> addUrlRewrite ( ) -> setPageSize ( $ limit ) -> setCurPage ( 1 ) ; /* Price data is added to consider item stock status using price index */ $ collection = $ this -> productIndexcollection -> addPriceData ( ) -> addIndexFilter ( ) -> setAddedAtOrder ( ) -> setVisibility ( $ this -> productVisibility -> getVisibleInSiteIds ( ) ) ; return $ collection -> getColumnValues ( 'product_id' ) ; }
Get recently viewed.

@param int $customerId
@param int $limit

@return array
Get recently viewed .