For adding product to wishlist, we need customer id & product id . Let see example.
<?php require_once 'app/Mage.php'; Mage::app('default'); Mage::getSingleton("core/session", array("name" => "frontend")); ?> <?php if(Mage::getSingleton('customer/session')->isLoggedIn()) { $customer = Mage::getSingleton('customer/session')->getCustomer(); $customerId=$customer->getId(); $productId=$_REQUEST['productId']; if($_REQUEST['productId']) { $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customerId, true); $product = Mage::getModel('catalog/product')->load($productId); $buyRequest = new Varien_Object(array()); // any possible options that are configurable and you want to save with the product $result = $wishlist->addNewItem($product, $buyRequest); $wishlist->save(); $data['responseCode']='1'; $data['msg']="Add Product to wishlist Successfully"; } else { $data['responseCode']='0'; $data['msg']='Please select Customer Or Product'; } } else { $data['responseCode']='0'; $data['msg']='Please Login First'; } $data2=json_encode($data); echo $data2; ?>
EmoticonEmoticon