We currently have a post explaining how to associated simple products that have required options to a parent grouped product (link), but another product configuration that many people ask about is associating configurable products within a grouped product. This association allows a Magento store to more intuitively display their products on a single page, rather than forcing the user to navigate to multiple configurable product pages.
There are quite a few steps to get this working correctly, but since we’ve implemented this for a few clients, we’ve bundled the code into a module that you can download here: groupedconfigurable.
Here, I’ll list the basic steps to get this working, and you can download the code and modify to your liking.
Step 1: Allow the Association
By default, Magento wont allow you to link a configurable product from a grouped product. If you check config.xml in the module we wrote, we updated the allowable product types for a grouped product.
Step 2. Add our product.js File to your layout
Step 3. Check for a configurable product, and use our new configurable template
In the grouped.phtml file, while it is iterating through the associated products, check if the product is configurable. If it is, use our Helper class to echo out the configurable template. This would look something like: (this is basically pseudo code)
if($_item->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE): echo Mage::helper('groupedconfigured')->getAssociatedConfigurableProductHtml($this, $_item) ; else: // default to original behavior
Within the method getAssociatedConfigurableProductHtml, it will create a block using the configurable template we’ve provided.
Another thing to mention is that since Magento by default has a single form for adding products to cart, you’ll want to remove the form declaration from the grouped.phtml file, and instead, just use the forms that are provided by our template.
The screen shown above isn’t pretty (I didn’t style anything), but as you can see, you can display a configurable product anywhere in your store using a convenient helper method. We’ve provided the code necessary in this post, but if anyone has specific customization questions or needs any help, send us an email through our site’s contact form or comment below.
– UPDATE –
Jason (see comments below) pointed out a flaw in my config.xml file and the lack of some required overrides. I’ve updated my module, and the link above is the latest version.
– Update (8/5/11) –