The store I am working on is for downloadable products only. During the checkout if we have a book of a particular attribute set we send a SOAP request to an external company (to get the ebook's downloadable URL from the external company). I have wrote a module which overrides the saveOrderAction
of the OnepageController.php
I have created an extra database table which stores the information about the item's downloadable URL which is updated on the saveOrderAction
.
As during the checkout the Order ID isn't generated I have created an Observer which checks for the order being saved event, during this it finds the Order ID of the current products which I update the database table I created.
The problem I'm having now is how to update the downloadable URLs when the user clicks download on their downloadable products section of their customer account.
In the DownloadController.php
I have found the function linkAction
which I believe is called when the download button is clicked for an product. In there I have print_r
the $linkPurchasedItem
variable which shows an purchased_id
and item_id
which appear to be unique for the product.
To return the downloadable URL which is saved in the database (on my custom table) and given from the external company I will need to update the database table I have created at some point to insert the 'purchased_id' or 'item_id' so in the DownloadController.php
on the linkAction
I can run another database call to get the right downloadable URL for the product this function is being called for.
Therefore my questions are:
- At what point is the
purchased_id
and/oritem_id
generated? - Is it possible to get them in the
OnepageController.php
? - What is the best way to uniquely identify each product in each order in my custom database table so I can reference it in the
DownloadController.php
?
Thanks for any help in advance.