Cart table growing in size - 400,000 records!

  • Posts: 297
  • Thank you received: 5
  • Hikashop Business
1 month 3 days ago #365301

-- HikaShop version -- : 5.1.2
-- Joomla version -- : 5.2
-- PHP version -- : 8.2

Looking at a couple of sites realised the cart table is growing to a ridiculous size.
The cart retaining period is setup.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83303
  • Thank you received: 13468
  • MODERATOR
1 month 3 days ago #365302

Hi,

You want to reduce the frequency as much as possible. That way, the old records will be deleted more often.
With a 1 day delay, only 50 carts will be deleted each day. If, for example, you have 2000 carts being created on the website every day, with 50 old carts being deleted every day, that's 1950 carts piling up every day. And that will quickly grow to 400K records.

Please Log in or Create an account to join the conversation.

  • Posts: 297
  • Thank you received: 5
  • Hikashop Business
1 month 3 days ago #365305

Thanks, just been looking at hikashop_cleanCart().

I see the default for cart_batch_removal_quantity is defaults to 50 and I cannot see anyway in Hikashop code for changing that without adding some coding. That's no problem but I wonder if core Hikashop could be improved.

i.e. Ability to remove the quantity limit (i.e. set it to 0) and purge all carts older than, say, 7 days.

Please Log in or Create an account to join the conversation.

  • Posts: 83303
  • Thank you received: 13468
  • MODERATOR
1 month 2 days ago #365308

Hi,

That's a hidden option.
If you want to change the value, you can do so by adding an entry to the hikashop_config table of your database with the namekey cart_batch_removal_quantity and the value you want via your PHPMyAdmin.
So no code is needed.

Please Log in or Create an account to join the conversation.

  • Posts: 297
  • Thank you received: 5
  • Hikashop Business
4 weeks 9 hours ago #365358

Looking at admin/customers/cart page:
..../administrator/index.php?option=com_hikashop&ctrl=cart&cart_type=cart&limitstart=40&limit=20

Then cross referencing the IP addresses with the server access log I see that all these carts are being created by robots.

216.244.66.231 - - [25/Jan/2025:06:40:32 +0000] "GET ... (compatible; DotBot/1.2; +https://opensiteexplorer.org/dotbot; This email address is being protected from spambots. You need JavaScript enabled to view it.)"
54.36.149.61 - - [25/Jan/2025:06:40:36 +0000] "GET ... (compatible; AhrefsBot/7.0; +http://ahrefs.com/robot/)"
85.208.96.197 - - [25/Jan/2025:06:40:44 +0000] "GET ... (compatible; SemrushBot/7~bl; +http://www.semrush.com/bot.html)"
74.125.212.193 - - [25/Jan/2025:06:40:45 +0000] "GET ... (X11; Linux x86_64; Storebot-Google/1.0)

Should robots be allowed to add things to the cart, is it necessary for search engine crawlers?

In helper.php there is a function hikashop_checkRobots() which does not appear to be being used anywhere.

There is this Joomla function which does a search through a massive list (incomplete) of known robots.
Joomla\CMS\Environment\Browser\isRobot()

Are there better ways of handling this?

I suppose a plugin which handles the onBeforeCartSave event and calls isRobot() might be one way of preventing the #__hikashop_cart table from filling up with robot visits.

Please Log in or Create an account to join the conversation.

  • Posts: 83303
  • Thank you received: 13468
  • MODERATOR
4 weeks 3 hours ago #365360

Hi,

No, it is not necessary to allow bots the creation of carts.
The first thing to do would be to use the robots.txt file of your website to forbid access to the add to cart URLs for bots.

Indeed, having a small plugin checking the isRobot status with the onBeforeCartSave event would be a more agressive solution.

Please Log in or Create an account to join the conversation.

Time to create page: 0.126 seconds
Powered by Kunena Forum