Thursday, 7 July 2016

how to remove product wishlist remove custom page on magento

Customer account controllers path :-
/app/code/local/Companyname/Customer/controllers

public function wishlistRemoveAction(){
        $proid= $_REQUEST['proid'];
        $customerid= $_REQUEST['customerid'];
       
        $itemCollection = Mage::getModel('wishlist/item')->getCollection()->addCustomerIdFilter($customerid);
        foreach($itemCollection as $item) {
        if($item->getProductId()==$proid)
            $item->delete();
        }
       
    }

 List page :-

<input type="hidden" id="remove_url" value="<?php echo $this->getUrl();?>customer/account/wishlistRemove"/>

<a href="javascript:void(0)" class="link-wishlist click-remove" data-proid="<?php echo $_product->getId(); ?>" data-customerid="<?php echo $customerId; ?>">
                                <i class="fa fa-star-o"></i>
                            </a>

JQuery :-


jQuery('.click-remove').click(function() {
    var base_url=jQuery.trim(jQuery("#remove_url").val());
    var pro_Id=jQuery(this).data('proid');
    var customerid=jQuery(this).data('customerid');
    //alert(base_url);
    jQuery.ajax({
           url: base_url,
           type:  'post',
           data:({'proid':pro_Id,'customerid':customerid}),
           success: function(msg){
        location.reload();
           }
       });
      
    });

No comments:

Post a Comment