I have been tasked for creating a order for a downloadable product and placing a order via Paypal and fortunately I've done the task pretty well.

But when the customer get his order email the download link for the product is not showing.

Below in my code that I've used :

    $msg = '<h2>Wrong data passed!!</h2>';
$product = Mage::getModel('catalog/product')->load($_GET['p']);
$cancel_url = Mage::getURL('').'paypal/standard/cancel/';
$return_url = Mage::getURL('').'paypal/standard/success/';
$notify_url = Mage::getURL('').'paypal/ipn/';

    $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
    $paypal_url = 'https://www.paypal.com/cgi-bin/webscr?';
$price = number_format((float)$product->getPrice(),2,'.',''); 
$quote = Mage::getModel('sales/quote');

$quote->setCustomerEmail('[email protected]');


$quoteItem = Mage::getModel('sales/quote_item')->setProduct($product);

$addressData = array(
'firstname' => 'Guest',
'lastname' => 'Customer',
'street' => 'Some address on the earth',
'city' => 'Somewhere',
'postcode' => '123456',
'telephone' => '123456',
'country_id' => 'US',
'region_id' => 12, // id from directory_country_region table,

$billingAddress = $quote->getBillingAddress()->addData($addressData);
/*$shippingAddress = $quote->getShippingAddress()->addData($addressData);

$service = Mage::getModel('sales/service_quote', $quote);
try {
    $order = $service->getOrder();
    $invoice = $order->getIncrementId();
} catch (Exception $e){   

Order is creating properly. Don't know what little extra I'm missing in the above. Please help me on this. Thanks

  • Any one has any answer?
    – Ravi Soni
    Mar 24, 2014 at 16:03
  • did you ever solve this problem? May 24, 2014 at 6:34

2 Answers 2


the download link for the product is not showing

This could mean the link as a whole does not show up, the link target is empty or it is not generated at all (no link_hash value) in the database.

The link to the downloadable Product gets generated within the sales_order_item_save_commit_after event in the saveDownloadableOrderItem method in Mage_Downloadable_Model_Observer.

So if it is not generated at all, have a look in your downloadable_link_purchased_item database table and check if there are values under link_hash and link_url or link_file fields.

If not, you might have another problem, with your e-mail template maybe.


add this, inspired from https://stackoverflow.com/questions/13712475/magento-adding-to-customers-available-downloadable-products

$order = $service->getOrder();
$orderItems = Mage::getModel('sales/order')->load($order->getId());
        foreach ($orderItems->getAllItems() as $itemId => $orderItem) {
            $product = Mage::getModel('catalog/product')->load($orderItem->getProductId());
            if($product->getTypeId()=='downloadable') {
                $product_links = Mage::getModel('downloadable/product_type')->getLinks( $product );
                foreach ($product_links as $link) {
                    $downloadPurchase = Mage::getModel('downloadable/link_purchased')
                        ->setCreatedAt(date('Y-m-d H:i:s'))
                        ->setUpdatedAt(date('Y-m-d H:i:s'))
                        ->setLinkSectionTitle('Click here to download');


                    $linkHash = strtr(base64_encode(microtime() . $downloadPurchase->getId() . $orderItem->getId() . $product->getId()), '+/=', '-_,');
                    $downloadItem = Mage::getModel('downloadable/link_purchased_item')
                        ->setCreatedAt(date('Y-m-d H:i:s'))
                        ->setUpdatedAt(date('Y-m-d H:i:s'))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.