How to add product in wishlist with custom options magento
After a few hour debugging i got the solution about How to add custom option in wishlist. By default Magento has no functionality to add custom option with product in wishlist. Kindly follow the below steps to add product in wishlist with custom option.
Open app/design/frontend/default/yourtheme/template/catalog/product/view.phtml
Remove the default Add to wishlist button and replace the below one
<?php $_wishlistSubmitUrl = $this->helper('wishlist')->getAddUrl($_product); ?>
<span onclick="wishlistWithOption('<?php echo $_wishlistSubmitUrl; ?>');" style="cursor:pointer"><i class="pd-wishlist"></i>Add to Wishlist</span>
After this code put the below javascript function
<script type="text/javascript">
function wishlistWithOption(url){
var sel = jQuery('select').attr("id");
if(sel){
var selId = sel.split('_');
setLocation(url+selId[1]+'/'+jQuery('#'+sel).val());
}else{
setLocation(url);
}
}
</script>
Now open the app/code/core/Mage/Wishlist/controllers/IndexController.php file. you can also create Observer for this functionlity.
Add the below code in _addItemToWishList() function. After the $requestParams = $this->getRequest()->getParams(); line.
$i = 1;
foreach($requestParams as $key=> $_requestParams){
if($i == 3){
$requestParams = array(
'product' => $productId,
'store_id' => $storeId,
'qty' => 1,
'options' => array($key=>$_requestParams)
);
}
$i++;
}
Note : The above code works only that products which have select(Dropdown) custom option like Size, Color..
That's it. Enjoy Chandresh Rana Coding..