Mukesh Chapagain
Mukesh Chapagain

Reputation: 25996

Magento: Track number of downloads of downloadable product links

I would like to display the number of downloads being done for any downloadable links of a downloadable product in Magento.

I don't think there is such feature in Magento.

Seems we need to program it.

Any help please?

Upvotes: 1

Views: 1376

Answers (2)

Pavel Novitsky
Pavel Novitsky

Reputation: 1694

Look at the number_of_downloads_bought and number_of_downloads_used in downloadable_link_purchased_item table (Mage_Downloadable_Model_Link_Purchased_Item model)

Magento uses those fields to define how many times user can download file:

$linkPurchased = Mage::getModel('downloadable/link_purchased')->load($linkPurchasedItem->getPurchasedId());
$downloadsLeft = $linkPurchasedItem->getNumberOfDownloadsBought()
    - $linkPurchasedItem->getNumberOfDownloadsUsed();

So you can use $linkPurchasedItem->getNumberOfDownloadsUsed() as number of downloads in selected order. If you count number of doewnloads for every order you can get total number of downloads.

Or you can make your own counter for calling Mage_Downloadable_DownloadController::_processDownload()

Upvotes: 4

Lucas Moeskops
Lucas Moeskops

Reputation: 5443

Isn't it the field 'number_of_downloads' in the table 'downloadable_link'?

Upvotes: 0

Related Questions