I just came across the same problem. If the product is not downloadable by itself, but is a configurable product with an associated child which is downloadable, then the link is not rendered in the mails. A quick fix to this problem is to copy the template email/order/invoice/items.phtml
to your own theme and edit the following if condition:
<?php if($_item->getOrderItem()->getParentItem()) continue; else $i++; ?>
With this condition in place, the child items are not rendered. I added another condition to it, so that child items are rendered if they are downloadable:
<?php if($_item->getOrderItem()->getParentItem() && $_item->getOrderItem()->getProductType() != Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) continue; else $i++; ?>
With this change, the download link appears in the invoice mail. The disadvantage of this method is that the item is rendered twice:
I now also came up with a nicer solution. Therefore, I changed the email/order/invoice/items.phtml
template like this:
<?php $_invoice = $this->getInvoice() ?>
<?php $_order = $this->getOrder() ?>
<?php if ($_invoice && $_order): ?>
<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
<thead>
<tr>
<th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Item') ?></th>
<th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Sku') ?></th>
<th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Qty') ?></th>
<th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
</tr>
</thead>
<?php $i=0; foreach ($_invoice->getAllItems() as $_item): ?>
<?php if($_item->getOrderItem()->getParentItem() && $_item->getOrderItem()->getProductType() != Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) continue; else $i++; ?>
<?php // do not use a new colour for the download link ?>
<?php if ($_item->getOrderItem()->getProductType() == Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE) { $i++; } ?>
<tbody<?php echo $i%2 ? ' bgcolor="#F6F6F6"' : '' ?>>
<?php if ($_item->getOrderItem()->getProductType() != Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE): ?>
<?php echo $this->getItemHtml($_item) ?>
<?php else: ?>
<?php // if this child is a download product, just print the download link as the product information is taken from the configurable product (the parent) ?>
<?php $_downloadLink = ''; ?>
<?php $_links = Mage::getModel('downloadable/link_purchased_item')->getCollection()->addFieldToFilter('order_item_id', $_item->getOrderItem()->getId()); ?>
<?php foreach ($_links as $_link): ?>
<?php if ($_link->getProductId() == $_item->getOrderItem()->getProduct()->getId()): ?>
<?php $_downloadLink = $this->getUrl('downloadable/download/link/', array('id' => $_link->getLinkHash())); ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if (!empty($_downloadLink)): ?>
<tr>
<td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;" colspan="4"><a href="<?php echo $_downloadLink; ?>">Download</a></td>
</tr>
<?php endif; ?>
<?php endif; ?>
</tbody>
<?php endforeach; ?>
<tfoot>
<?php echo $this->getChildHtml('invoice_totals')?>
</tfoot>
</table>
<?php endif; ?>
The result looks much nicer now:
This works for other mails accordingly (e.g. under email/order/items.phtml
for the normal order mail).
By default the Configurable product only allows simple and virtual products to be used, this is specified in the config.xml in Mage/Catalog/etc/:
<configurable translate="label" module="catalog">
<label>Configurable Product</label>
<model>catalog/product_type_configurable</model>
<price_model>catalog/product_type_configurable_price</price_model>
<composite>1</composite>
<allow_product_types>
<simple/>
<virtual/>
</allow_product_types>
<index_priority>30</index_priority>
<price_indexer>catalog/product_indexer_price_configurable</price_indexer>
To add a downloadable product to you configuration you have to create a small extension (do not change the core file!) to add this option:
Module init file (app/etc/modules/Example_DownloadableConfigurable.xml):
<?xml version="1.0"?>
<config>
<modules>
<Example_DownloadableConfigurable>
<active>true</active>
<codePool>community</codePool>
<depends>
<Mage_Bundle/>
<Mage_Downloadable/>
</depends>
</Example_DownloadableConfigurable>
</modules>
</config>
Module configuration file (app/code/community/Example/DownloadableConfigurable/etc/config.xml):
<?xml version="1.0"?>
<config>
<modules>
<Example_DownloadableConfigurable>
<version>14.293.1</version>
</Example_DownloadableConfigurable>
</modules>
<global>
<catalog>
<product>
<type>
<configurable>
<allowed_selection_types>
<downloadable/>
</allowed_selection_types>
</configurable>
</type>
</product>
</catalog>
</global>
</config>
Just tested this with an order and the downloadable product is added to the list with My Downloadable products. The code above can also be applied to the bundle products type (just change <configurable>
to <bundle>
).
Best Answer
As of Magento 2.2 the admin System Configuration Panel "Advanced" has been removed.
The following gives reference on how to disable a module's output.
https://devdocs.magento.com/guides/v2.3/config-guide/config/disable-module-output.html