Magento – How to associate downloadable product to configurable products in magento

configurable-productdownloadablemagento-1.7

I have a product with two format one downloadable and another non-downloadeable. How can I show both format together on frontend with that product.

Best Answer

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>).