Customers - Cart menu item in the backend not working - Memory issue

  • Posts: 196
  • Thank you received: 11
  • Hikashop Business
7 years 8 months ago #276681

-- HikaShop version -- : 3.1.1
-- Joomla version -- : 3.7.5
-- PHP version -- : 5.6.31
-- Browser(s) name and version -- : FF

When I go to the Customers -> Cart menu item in the backend I get an Error. Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 53 bytes) in /public_html/administrator/components/com_hikashop/classes/cart.php on line 2736

We have 30 carts (xxx_hikashop_cart) with a total of 1150 products in the Database (xxx_hikashop_cart_product). Maybe the Serialize / Unserialize is eating to much memory. Or maybe it is something else...

I hope you can provide a solution

Attachments:

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

  • Posts: 12953
  • Thank you received: 1778
7 years 8 months ago #276685

Hello,

It probably means that the memory requirements exceed your default memory limit, I think that you can maybe solve this by adding a line like this to your server’s php.ini file:

memory_limit = 128M

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

  • Posts: 196
  • Thank you received: 11
  • Hikashop Business
7 years 8 months ago #276818

Hi,

It is indeed a solution but in my humble opinion, the code could be optimized to reduce memory load. (Un)Serialize functions could be changed to deep cloning to reduce the memory used in the process.

Regards

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

  • Posts: 83798
  • Thank you received: 13570
  • MODERATOR
7 years 8 months ago #276826

Hi,

The problem is not really the serialize / unserialize functions.
The problem is that for each cart, the system does a full load of the whole cart, the products, the shipping, the payment, the custom fields, the addresses, etc. The same data loaded during the checkout.
We do that because it is easy to get the full total and the number of products in the carts that way. We could optimize and load the carts with way less queries and memory and processing. The problem is that the triggers that are called during the loading of a cart wouldn't work without the normal data.
For example a plugin modifying the price of a product during the cart loading might crash without the standard data available in the trigger and not calling the triggers would means that the plugins wouldn't be able to do what they are supposed to do on the data of the cart. So for example, the donation plugin wouldn't be called and you would see a cart amount at 0 instead of the amount entered by the customer.
It would also be complex to take into account the discounts, the coupons, etc.
In short, doing it like we do simplifies a lot of things on that page and allows us to display accurate information. The drawback is that this page consumes an important amount of resources compared to the rest of HikaShop.
That's a choice we made as before we regularily had support requests that the amounts displayed there were not accurate as they didn't take everything into account like on the frontend.

The following user(s) said Thank You: Rixters

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

Time to create page: 0.083 seconds
Powered by Kunena Forum