1

I was notified by one of my customer that he was unable to download the file that he bought recently. Whenever he clicks the link, website gives this error message-"An error occurred while getting the requested content. Please contact the store owner."

I tried checking this and found that he's true! I'm not able to figure out the exact reason for this.

2

There may be multiple reason for this. First you need to find out whether Magento gives any errors (exception, errors, report) while you're trying to download the link. Go through - Fundamentals of Debug a Magento store and come again with more details.

For now I can say that, you need to dig in the method linkAction() which is available in the controller class Mage_Downloadable_DownloadController that is located at app/code/core/Mage/Downloadable/controllers/DownloadController.php. More specifically, this is the part of code that you need to dig into.

if ($status == Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_AVAILABLE
        && ($downloadsLeft || $linkPurchasedItem->getNumberOfDownloadsBought() == 0)
    ) {
        ...
        try {
            $this->_processDownload($resource, $resourceType);
            $linkPurchasedItem->setNumberOfDownloadsUsed($linkPurchasedItem->getNumberOfDownloadsUsed() + 1);

            if ($linkPurchasedItem->getNumberOfDownloadsBought() != 0 && !($downloadsLeft - 1)) {
                $linkPurchasedItem->setStatus(Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_EXPIRED);
            }
            $linkPurchasedItem->save();
            exit(0);
        }
        catch (Exception $e) {
            $this->_getCustomerSession()->addError(
                Mage::helper('downloadable')->__('An error occurred while getting the requested content. Please contact the store owner.')
            );
        }
    } elseif ($status == Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_EXPIRED) {
        $this->_getCustomerSession()->addNotice(Mage::helper('downloadable')->__('The link has expired.'));
    } elseif ($status == Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING
        || $status == Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PAYMENT_REVIEW
    ) {
        $this->_getCustomerSession()->addNotice(Mage::helper('downloadable')->__('The link is not available.'));
    } else {
        $this->_getCustomerSession()->addError(
            Mage::helper('downloadable')->__('An error occurred while getting the requested content. Please contact the store owner.')
        );
    }

See the catch section and last else section

Try to log the error happens there. You can use Mage::log() function for that. Use this for more details on logging.

  • PLease is anything wrong with this code – Tiza Nege Oct 18 '15 at 16:24
  • 1
    Thanks! It is very useful to know a good place where to start your search! – TheKitMurkit Jan 17 '18 at 17:12

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.