Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 2
To many downloadable links after PayPal payment
 
JohnM
Jr. Member
 
Total Posts:  6
Joined:  2008-11-25
 

@hlang.... thanks for the code workaround… I’ll use it until Magento fixes.

I’m getting double (2) links (not triple) using live PayPal Express Checkout.

My product download works. Files were uploaded from desktop (not using URL pointer). BTW, the upload was sometime defective if multiple products were ready for upload at the same time...it mixed up some of them, so I did it for 1 product at a time.

Magento created the following LINK in the database:  /f/i/file_14.mp3
Which points to: http://mydomain.com/media/downloadable/files/links/f/i/file_14.mp3
The LINK record is_sharable=2 and link_type=file
The stored file attributes were 777

The attached JPG is my Catalog Downloadable Setting.

Image Attachments
downloadable_settings.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
rupen
Jr. Member
 
Total Posts:  14
Joined:  2009-01-27
 

Thanks John for the attachment and info.

You said that your Database setting points to http://mydomain.com/media/downloadable/files/links/f/i/file_14.mp3

But is this the link which opens when you click the download link in “my downloadable products” section?
Cause my url for that link is sometihng like http://mydomain.com/magento/index.php/downloadable/download/link/id/20/

I know that thi should convert to the link you mentioned, but I dont know why it is not happening.
Which file has the code where I can see this conversion happen?

I can see the DB having the data, and the server having the file, and my settings are the same as yours.\
Please throw in some light
thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
JohnM
Jr. Member
 
Total Posts:  6
Joined:  2008-11-25
 

My link in the store (MyDownloadble Products) is formatted: https://mydomain/downloadable/download/link/id/4

Which is probably pointing to the “item_id” field in the “downloadable_link_purchased_item” table which has the “link_file” field which would be the download pointer. (I’m not going to take the time to verify this by looking at the code now ... but its possible Magento actually starts this process using the “purchased_id” field in the “downloadable_link_purchased” table which is indexed to the table I referenced)

 
Magento Community Magento Community
Magento Community
Magento Community
 
rupen
Jr. Member
 
Total Posts:  14
Joined:  2009-01-27
 

After hours of looking at the code, I finally got the solution to get the download functionality to work for me.

Try this..
1. Make the following writable (777) by your web server:
magento/var/.htaccess – single file
magento/app/etc - directory
magento/var – directory
magento/media – directory and all the directories under

2. In the app/code/core/Mage/Downloadable/controllers/DowloadController.php file, linkSampleAction() and linkAction() functions;
add exit() at the end of the “try{” block for “$this->_processDownload($resource, $resourceType)” ;
just before the catch (Exception $e) {

This is similar to the way Magento has it for sampleAction(). they seemed to have missed it for the other two functions.This is needed to avoid the statement return $this->_redirectReferer() from running after the download is successfully completed.

After adding the exit(), both these functions will look like this.. 
/**
* Download link’s sample action
*
*/
public function linkSampleAction()
{
$linkId = $this->getRequest()->getParam(’link_id’, 0);
$link = Mage::getModel(’downloadable/link’)->load($linkId);
if ($link->getId()) {
if ($link->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_URL) {
$resource = $link->getSampleUrl();
$resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_URL;
} elseif ($link->getSampleType() == Mage_Downloadable_Helper_Download::LINK_TYPE_FILE) {
$resource = Mage::helper(’downloadable/file’)->getFilePath(
Mage_Downloadable_Model_Link::getBaseSamplePath(), $link->getSampleFile()
);
$resourceType = Mage_Downloadable_Helper_Download::LINK_TYPE_FILE;
}
try {
$this->_processDownload($resource, $resourceType);
//added to get the link samples to download
exit();
} catch (Mage_Core_Exception $e) {
$this->_getCustomerSession()->addError(Mage::helper(’downloadable’)->__(’Sorry, there was an error getting requested content. Please contact store owner.’));
}
}
return $this->_redirectReferer();
}

AND..  the other function..

/**
* Download link action
*/
public function linkAction()
{.........................................................
try {
$this->_processDownload($resource, $resourceType);
$linkPurchasedItem->setNumberOfDownloadsUsed(
$linkPurchasedItem->getNumberOfDownloadsUsed()+1
);
if ($linkPurchasedItem->getNumberOfDownloadsBought() != 0
&& !($linkPurchasedItem->getNumberOfDownloadsBought() - $linkPurchasedItem->getNumberOfDownloadsUsed())) {
$linkPurchasedItem->setStatus(Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_EXPIRED);
}
$linkPurchasedItem->save();
//added by to get the link to download
exit();
}
catch (Exception $e) {
$this->_getCustomerSession()->addError(
Mage::helper(’downloadable’)->__(’Sorry, there was an error getting requested content. Please contact store owner.’)
);
}
.....................................
................................

Hope this helps someone! Let me know smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
JohnM
Jr. Member
 
Total Posts:  6
Joined:  2008-11-25
 

Good Job and Thanks.. I will study the code.  But remember I was able to download the product without your fix… so there may be some other “glitch” or setting that is causing your problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rupen
Jr. Member
 
Total Posts:  14
Joined:  2009-01-27
 

Yes John. I thought of the same. I too would like to know what that “glitch” could be. My initial findings did not get me any solutions, so I went to modify the code..
Would it be possible for you to send me the output of your server’s phpinfo()? I think it could be a server setup issue..

thanks again

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 2