/**
  * Initialize product(s) for add to cart process
  *
  * @param   Varien_Object $buyRequest
  * @return  array|string
  */
 public function prepareForCart(Varien_Object $buyRequest)
 {
     $product = $this->getProduct();
     /* @var Mage_Catalog_Model_Product $product */
     // try to add custom options
     $options = $this->_prepareOptionsForCart($buyRequest->getOptions());
     if (is_string($options)) {
         return $options;
     }
     // try to found super product configuration
     // (if product was buying within grouped product)
     $superProductConfig = $buyRequest->getSuperProductConfig();
     if (!empty($superProductConfig['product_id']) && !empty($superProductConfig['product_type'])) {
         $superProductId = (int) $superProductConfig['product_id'];
         if ($superProductId) {
             if (!($superProduct = Mage::registry('used_super_product_' . $superProductId))) {
                 $superProduct = Mage::getModel('catalog/product')->load($superProductId);
                 Mage::register('used_super_product_' . $superProductId, $superProduct);
             }
             if ($superProduct->getId()) {
                 $assocProductIds = $superProduct->getTypeInstance()->getAssociatedProductIds();
                 if (in_array($product->getId(), $assocProductIds)) {
                     $productType = $superProductConfig['product_type'];
                     $product->addCustomOption('product_type', $productType, $superProduct);
                     $buyRequest->setData('super_product_config', array('product_type' => $productType, 'product_id' => $superProduct->getId()));
                 }
             }
         }
     }
     $product->addCustomOption('info_buyRequest', serialize($buyRequest->getData()));
     if ($options) {
         $optionIds = array_keys($options);
         $product->addCustomOption('option_ids', implode(',', $optionIds));
         foreach ($options as $optionId => $optionValue) {
             $product->addCustomOption('option_' . $optionId, $optionValue);
         }
     }
     // set quantity in cart
     $product->setCartQty($buyRequest->getQty());
     return array($product);
 }