Call our sales line
08000 484 679
Home > Magento > Simple Products with Custom Options in a Grouped Product

Simple Products with Custom Options in a Grouped Product

Posted on: 10th Feb 2011 By: Adam Moss 9 Comments

It shouldn’t really be an issue given the complexity of Magento’s code already but my God what a lifesaver this blog post turned out to be. A grouped product as we all know allows for multiple simple products to be displayed on on page and practically purchased at the same time. But what happens when you want one of these simple products to have custom options attached? Well, by default the grouped product ceases to work. However with this excellent module programmed by Tim Millhouse, the ability to do this becomes available instantly.

You can read the original blog post here: http://www.brimllc.com/2010/07/magento-associating-simple-products-with-required-options-to-a-grouped-product/

You can download the module from here: http://www.brimllc.com/wp-content/uploads/2011/02/Groupedsimple.zip

Once you’ve uploaded the files, open app > design > frontend > base > default > template > catalog > product > view > type > grouped.phtml (*phew)

 <?php
			$options = $_item->getProductOptionsCollection();
			foreach($options as $option){
				$select = $this->getLayout()->createBlock('core/html_select');
				$select->setClass('product-custom-option');
				$select->setName('super_options['.$_item->getId().']['.$option->getId().']');
				$select->addOption('', '– Select '.$option->getTitle().' –');

				foreach ($option->getValues() as $value) {
					$select->addOption($value->getOptionTypeId(), $value->getTitle());
				}

				echo $select->getHtml();
			}
			?>

The module worked perfectly in 1.4.1.0, but I think further consideration should be made for earlier versions in case it’s not quite compatible. In a recent website of mine I was able to use a grouped product with simple products, which had tier pricing and custom options and I’m happy to say that with this module, the whole thing worked perfectly.

Thanks for reading the Magento Blog at Ecommerce Web Design, and thanks once again to Tim Millhouse.

By Adam Moss

Adam is Ecommerce Manager and a PHP developer at Creare Group. Adam is responsible for training Magento development within the company. Follow Adam on Twitter: http://twitter.com/adampmoss. - .

9 Responses to “ Simple Products with Custom Options in a Grouped Product ”

  1. Tim
    #1 | 11th February 2011

    Thanks for the kind words Adam. I was just as shocked that Magento didn’t support this feature “out of the box”, but luckily we were able to get it working using the approach you mentioned above. I would think this association would come standard in future versions of Magento, but I haven’t heard anything as of yet.

  2. Nico
    #2 | 31st March 2011

    Wow, I was searching for hours for this solution. Thanks man…Why don’t you get it plugged at brimllc… I think this will spare a lot of lost hours for other users..

    gr. Nico

  3. Tim Elliott
    #3 | 6th April 2011

    Thanks for this post. Do you know what code you would need to put into grouped.phtml when your custom option is a text field?

    Thanks
    Tim

  4. Jonas
    #4 | 26th May 2011

    This should work if I want to use a text box as custom options too right? Or any other type of custom option for that matter? Since the for loop retrievs the custom option type… Have you tried this?

    Thanks for the blog post, much appreciated.

  5. klw
    #5 | 14th June 2011

    Thanks for the post, however, the simple product options are not saved.

  6. Nath
    #6 | 20th June 2011

    this works great but how can I show the price in the drop down? kind of important otherwise customer doesn’t know that the price is different..

  7. leprehcaunHuntez
    #7 | 30th September 2011

    Was this module free?

  8. remchard
    #8 | 3rd October 2011

    Hi,

    This does show the custom option.
    You guys are genius ^_^

    Now I just need to update the price for each product when selecting an option. Or did I miss something?
    Thanks in advance

  9. r patel
    #9 | 8th February 2013

    thax for this code it work but when i select the attribute of configurable product and add qty then press add to cart the attribute is not add in the cart please post this problem’s solution.

Post A Comment

Your comments:
Enclose code snippets within the appropriate tags: [php][/php]   [js][/js]   [xml][/xml]   [css][/css]   [html][/html]
E.g: [php]<?php echo "hello world"; ?>[/php]

Search Blog

Follow us on Twitter

Archives

For the record...

Views & opinions in this blog are those of the individual and do not necessarily reflect those of E-commerce Web Design or the Creare Group.