All the code you need can be found in
You will need to load the product by it's ID and load the wish list by customer. The code would look roughly something like this.
<?php
You can obtain the url via
app/code/core/Mage/Wishlist/controllers/IndexController.php
method _addItemToWishList
.You will need to load the product by it's ID and load the wish list by customer. The code would look roughly something like this.
<?php
$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(); ?>
Just out of curiosity. Why not use the addAction
provided by the wishlist controller to add the products?You can obtain the url via
echo Mage::helper('wishlist')->getAddUrl($product);
No comments:
Post a Comment