I am developing custom module for 'Buy one get one free (BOGO)' functionality.
I am done with custom form and grid at admin side for setting mapping of product-X and product-Y for BOGO.
I have written observer for checkout_cart_product_add_after
event to check respective product-Y for currently added product and also successfully getting respective mapped product.
But I am stuck (since yesterday morning) at adding product-Y in cart programmatically.
I have tried below code:
$prodY = Mage::getModel('catalog/product')->load(<ID_OF_MAPPED_PROD-Y>);
if($prodY) {
$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->addProduct($prodY, array('product_id' => $prodY->getId(), 'qty' => 1));
$cart->save();
}
My web store is crashing here and I am unable to find any error.
What wrong I am doing here?
Can anyone please help me to get out of this situation?
Thanks in advance !!!
event handler was getting called recursively...
Issue is resolved.. Refer link https://magento.stackexchange.com/questions/112818/custom-module-for-buy-one-get-one-free-bogo-functionality