#__hikashop_address keeps growing?

  • Posts: 2143
  • Thank you received: 747
8 years 7 months ago #213949

-- url of the page with the problem -- : local
-- HikaShop version -- : 2.5.0 Starter
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.3

Hi,

I'm presently in dev mode and playing with 3-5 users who I register in checkout with minimal address details: "Ask address on registration" = yes, published are only 1st & last names, country & state, "Use the same address as for billing" is checked for shipping address.

These dummy users order something, and then I'm deleting them to start all over again. Deletion goes "by the book", supposedly: in the backend only, first orders, then J users. I have also tried deleting shop users after the orders, then J users, but it's all the same as far as the "issue" goes.
BTW, Emerald is involved, but no extra action, subscription are deleted without a trace upon J user deletion.

Upon checking the database just to verify that all goes by the infamous book, indeed all is good and clean. With the exception of the table #__hikashop_address. And that's the issue: after a few cycles I'm left with some 20 rows there. Most fields are NULL, also the aforementioned ones which had been in use.
Further testing shows that it keeps going this way: address details are being stored in a new row, but upon user deletion the row stays - mostly NULL except for
address_id (= auto_increment number maintained)
address_user_id (= 0)
address_published (= 1)
address_default (= 1)

What is preventing from proper housekeeping?

I have no problem deleting those rows now with no user other than admin around, but my concern is the future:
Upon launch, the database will hold >10k addresses, hopefully growing, but with a certain fluctuation including deletions. At some point housekeeping might become a big mess, or this table will just keep growing... who knows to what size.

So, it'd be great if you could take a look at what is yet a small issue. Should be easily reproducible, otherwise it must be uniquely my problem, and I'll take any hint and get you what you need to find the culprit.

Thanks again!

P.S.: I should maybe add that it's really only J!3.4.4, HikaShop and Emerald, and not one file modded, even still Protostar ;)


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 8 years 7 months ago by lousyfool.
The following user(s) said Thank You: nyanginator

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

  • Posts: 2143
  • Thank you received: 747
8 years 7 months ago #214242

Friendly "bump"...

Maybe it takes a bit longer to dig into this, or maybe my post only fell off the edge of the world. No stress, but would be nice hearing something. Thanks!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
8 years 7 months ago #214260

Hi,

I'm sorry but we didn't had the time to look at that.
It's not a priority as it doesn't causes any problem and it's not going to be easy to debug.
We'll add that to the todo list as a low priority issue.
If you want to look at it yourself, it should be in either in the delete function of the administrator/components/com_hikashop/classes/user.php or administrator/components/com_hikashop/classes/address.php
Even with a few tens of thousands of entries like that, it shouldn't slow down the website. And it's easy to remove them if necessary with a SQL query that you can run on your phpmyadmin like that:
DELETE FROM #__hikashop_address WHERE address_country=NULL;
(the country should never be null in an address as you cannot not select a country when you edit/create an address)

The following user(s) said Thank You: lousyfool

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

  • Posts: 2143
  • Thank you received: 747
8 years 7 months ago #214346

Hi again,

I understand it's not a priority - as I said, it's only a small issue, obviously, and there are more important things to do.
Was just wondering because usually no question here goes without reply within a few hours unless the OP answers it himself.

Anyway, glad you took the time to answer, and thanks for the hints on function and SQL query. That'll do!


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

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

  • Posts: 31
  • Thank you received: 1
6 years 11 months ago #270057

Following the previous posts, adding the following at the end of the delete() function in /administrator/components/com_hikashop/classes/address.php seems to do the trick:

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $conditions = array(
          $db->quoteName('address_country') . ' IS NULL'
        );
        $query->delete($db->quoteName('#__hikashop_address'));
        $query->where($conditions);
        $db->setQuery($query);
        $result = $db->execute();

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
6 years 11 months ago #270074

Hi,

Note however that this can't be a generic solution since the address_country field can actually really be empty when the address_country field is disabled in the menu Display>Custom fields, and that often happens when you sell your goods in only one country.

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

  • Posts: 31
  • Thank you received: 1
6 years 11 months ago #270096

Thanks for the input. Would it be better to delete records where address_user_id=0 then? I noticed that was another common value in deleted users.

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

  • Posts: 26000
  • Thank you received: 4004
  • MODERATOR
6 years 11 months ago #270097

Hello,

An address with address_user_id set with 0 is not attach to a user ; so it can be deleted.
Afterwards, that's not the case you're talking about ; because when you delete a user, his addresses are still using his ID. So the idea would be more to delete addresses with non corresponding ID in the HikaShop user table.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: nyanginator

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

  • Posts: 31
  • Thank you received: 1
6 years 11 months ago #270210

It seems like the deleted users are having their address_user_id fields properly zeroed out (and other fields also become NULL). Using address_user_id=0 has been working in my tests so far.

Is there a case where an address would be in the #__hikashop_address table with the ID of a user who's already been deleted?

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

  • Posts: 81515
  • Thank you received: 13069
  • MODERATOR
6 years 11 months ago #270228

Hi,

No, normally, when you delete a Joomla user account, the user entry in HikaShop is kept and the addresses of th user entry in HikaShop too. So an address with an address_user_id equal to 0 shouldn't happen normally.
But there is always the possibility after an import from a third party ecommerce solution where the import system would be able to import the orders (and the addresses attached to them) without importing the users of these orders, even though that should not happen in most cases.

The following user(s) said Thank You: nyanginator

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

  • Posts: 31
  • Thank you received: 1
6 years 10 months ago #270278

I think it's much clearer now. When I was testing before, I forgot to put in some orders. That's why I didn't come across the case where Hikashop users were kept when Joomla users were deleted :oops:

My adjusted SQL statement:

$db = JFactory::getDbo();
$sql = 'DELETE FROM #__hikashop_address WHERE address_user_id NOT IN (SELECT user_id FROM #__hikashop_user)';
$db->setQuery($sql);
$result = $db->execute();

I am still new to Hikashop but am impressed with it very much already. Thanks very much for your time and all the hard work.

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

Time to create page: 0.073 seconds
Powered by Kunena Forum