5
  • Create Recently Viewed Products for Model file in Magento 2 ?
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

  • Can you be more specific with Business Logic ? – Yann Martel Dec 10 '18 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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