- Create Recently Viewed Products for Model file in Magento 2 ?
Create an API with Mage2Gen
Now you can add the logic in
Based on the following function in which a Recently Viewed Product Collection is returned when a Customer Id is available. Don't include the class in your construct because it is a block but copy it and add your own logic.
getItemsCollection in vendor/magento/module-reports/Block/Product/AbstractProduct.php
Then retrieve the current Customer Id through the