<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How to delete millions of CommerceWishList entries?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120468177" />
  <subtitle>How to delete millions of CommerceWishList entries?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120468177</id>
  <updated>2026-06-01T17:11:40Z</updated>
  <dc:date>2026-06-01T17:11:40Z</dc:date>
  <entry>
    <title>RE: How to delete millions of CommerceWishList entries?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120647033" />
    <author>
      <name>Dieter Metzler</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120647033</id>
    <updated>2021-07-13T12:35:33Z</updated>
    <published>2021-02-23T08:18:39Z</published>
    <summary type="html">&lt;p&gt;I found a solution to delete the entries with a javascript portlet
  which is using the Liferay.service() method. I created a liferay
  module project in my eclipse IDE with the mvc-portlet template. Then I
  added the following code to the view.jsp and deployed the portlet. Now
  I can enter the start and the end commerceWishListId in a form.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;&lt;code class="language-javascript"&gt;&amp;lt;%@ include file=&amp;quot;/init.jsp&amp;quot; %&amp;gt;

&amp;lt;input id=&amp;quot;start&amp;quot; label=&amp;quot;Start&amp;quot;&amp;gt;&amp;lt;/input&amp;gt;
&amp;lt;input id=&amp;quot;end&amp;quot; label=&amp;quot;End&amp;quot;&amp;gt;&amp;lt;/input&amp;gt;

&amp;lt;button value='send' id=&amp;quot;submit&amp;quot; onclick=&amp;quot;myFunction()&amp;quot;&amp;gt;Delete&amp;lt;/button&amp;gt;

 &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
             
         function myFunction() {
             const start = document.getElementById(&amp;quot;start&amp;quot;).value;
             const end = document.getElementById(&amp;quot;end&amp;quot;).value;
             
             for (var i = start; i &amp;lt; end; i++) {    
                 console.log(i);
                 object = deleteWishlist(i);
                 console.log(object);
                 }
         }
    
         async function deleteWishlist(wlId) {
              
            const response = await Liferay.Service(
                      '/commerce.commercewishlist/delete-commerce-wish-list',
                      {
                        commerceWishListId: wlId
                      },
                      function(obj) {                  
                          console.log(wlId + &amp;quot;deleted&amp;quot;);    
                      }
                    );
                   return(obj);
            }    
&amp;lt;/script&amp;gt;
    &lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The program is working but sometimes it stops deleting after a few
  thousand entries. I hope a javascript expert can help me to improve
  the script. I think it's an issue with the async request.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>Dieter Metzler</dc:creator>
    <dc:date>2021-02-23T08:18:39Z</dc:date>
  </entry>
  <entry>
    <title>How to delete millions of CommerceWishList entries?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120468176" />
    <author>
      <name>Dieter Metzler</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120468176</id>
    <updated>2020-11-24T19:14:16Z</updated>
    <published>2020-11-24T10:29:47Z</published>
    <summary type="html">&lt;p&gt;When I tried to upgrade Liferay from 7.1ga4 to 7.3ga6 i recognized
  that i have got more then 2 millions default entries in my
  CommerceWishList tables. First I don't know from where they are
  coming? Is there a script running in the background or is my server hacked?&lt;/p&gt;
&lt;p&gt;Now I would like to delete the entries. I know it is strongly
  forbidden to delete them directly in the database. So I tried to
  delete the entries with a Groovy script. I figured out that the
  following script is working when there are only a few entries in the Database.&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;
  &lt;em&gt;import com.liferay.commerce.wish.list.model.CommerceWishList;&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;
  &lt;em&gt;import com.liferay.commerce.wish.list.service.CommerceWishListLocalServiceUtil;&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;
  &lt;em&gt;import java.util.List;&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt; &lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;
  &lt;em&gt;CommerceWishListLocalServiceUtil.deleteCommerceWishListsByUserId(20120);&lt;/em&gt;&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt; &lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;But when I try this
  Groovy script to delete the more then 2 million entries it does not work.&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;Have someone any
  Idee how I can delete these CommereceWishList entires in my database?&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt; &lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;Thank you&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt; &lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt;Dieter&lt;/p&gt;
&lt;p style="margin-bottom: 0.0cm;line-height: 100.0%;"&gt; &lt;/p&gt;</summary>
    <dc:creator>Dieter Metzler</dc:creator>
    <dc:date>2020-11-24T10:29:47Z</dc:date>
  </entry>
</feed>
