Question

I want to fire an action when a user has downloaded a downloadable product (i.e. they have clicked the link for the download). I don't know what event I should be observing to do this. I tried to search through the list of Events here:

https://www.simicart.com/blog/magento-2-events-list

But none of them seem to correspond to the event I'm looking for. Any ideas on what event corresponds to this? Or another way of observing this action? (i.e. via plugin perhaps?)

Was it helpful?

Solution

You can use controller_action_postdispatch_downloadable_download_link. Note that this can include invalid requests for download etc. Additional validation will be required based on your requirements. To get product downloaded load (by link_hash) \Magento\Downloadable\Model\Link\Purchased\Item received in id GET parameter. Note that I also answered your question on Reddit :D

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top