浏览文章

文章信息

magento2 获取最近浏览产品 12876

<?php
/**
* Created by PhpStorm.
* User: 秋枫雁飞
* Date: 2020/1/16
* Time: 13:37
* Web:www.aiweline.com
* Copyright © 2016 Aiweline. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Aiweline\Search\Model;


use Magento\Reports\Block\Product\Viewed;

class CustomerManagement implements CustomerInterface
{
   private $viewed;
   private $productRepositoryInterface;

   function __construct(
       Viewed $viewed
   )
   {
       $this->viewed = $viewed;
   }

   /**
    * 最近浏览产品
    * @param int $customerId
    * @param int $pageSize
    * @param int $page
    * @return mixed
    */
   function getRecentViewedProduct($customerId, $pageSize, $page)
   {
       return $this->viewed->setCustomerId($customerId)->getItemsCollection();
   }
}


原创