Magento: Programmatically Add Grouped Product to Cart

Adding simple products to cart through PHP code is easy to understand and pretty straightforward. You just need to call the $cart->addProduct() function with the product_id and quantity as parameters. But if you want to add grouped products to cart through your code, you will need to execute a few extra steps. The procedure is very easy – make a $super_group array of the associated products with the specified quantities. Then you need to pass the array to the addProduct() function. See the code snippet below that makes it work:

Leave a Reply

Your email address will not be published. Required fields are marked *