Magento – Best Way of Adding Product to Wishlist

redirecturlwishlist

I have an option inside the cart to add a product to the wishlist which works fine.

   onclick="jQuery.get('<?php echo $this->getUrl('myaccount/checkout/wishlist') ?>', { product: <?php echo $_item->getProductId() ?> }).done(function(data) { location.reload(true); });

But if you are not logged in you are first taken to a log in page. After this I set up a redirect using the same url that is submitted from the cart to add a product to you wishlist.

   https://temperley.localhost/shop/myaccount/checkout/wishlist/product:25192

Problem is this url does not work in this situation. I've tried using http instead of https and vice versa which isn't working. I would appreciate if anyone could describe how exactly I can add a product to the wishlist from a redirect off the login page or add a product by id to the wishlist

Best Answer

Magento adds the parameter with / to the url, therefore the url must be

https://temperley.localhost/shop/myaccount/checkout/wishlist/product/25192

or (the classic way)

https://temperley.localhost/shop/myaccount/checkout/wishlist/?product=25192
Related Topic