5
  • Create Recently Viewed Products for Model file in Magento 2 ?

1 Answer 1

3

Create an API with Mage2Gen

https://mage2gen.com/load/8cfec17a-a5ff-481e-9f36-2091e0237006

Now you can add the logic in

app/code/Vendor/ModuleName/Model/CustomerRecentlyViewedProductsManagement.php

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

Magento\Customer\Model\Session

1
  • Can you be more specific with Business Logic ? Dec 10, 2018 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.