Hi,
Yes. I was able to do the necessary debugging.
Here is the report:
In the file administrator/components/com_hikashop/classes/address.php I've left the code:
$query = 'UPDATE '.hikashop_table('address').' SET address_state = \'\' WHERE address_id = '.(int)$addressData->address_id;
$this->database->setQuery($query);
$this->database->execute();
$query = 'SELECT * FROM '.hikashop_table('address').' WHERE address_id = '.(int)$addressData->address_id;
$this->database->setQuery($query);
$ret = $this->database->loadObject();
This code clears the address_state in the database from the address being updated before the saving of the address.
That way, we're sure that the state we see in the log doesn't come from the address data already in the database.
I've also left the code:
hikashop_writeToLog($addressData, 'before onAfterAddressUpdate');
$query = 'SELECT * FROM '.hikashop_table('address').' WHERE address_id = '.(int)$addressData->address_id;
$this->database->setQuery($query);
$ret = $this->database->loadObject();
hikashop_writeToLog($ret, 'Address Table');
and:
hikashop_writeToLog($addressData, 'after onAfterAddressUpdate');
$query = 'SELECT * FROM '.hikashop_table('address').' WHERE address_id = '.(int)$addressData->address_id;
$this->database->setQuery($query);
$ret = $this->database->loadObject();
hikashop_writeToLog($ret, 'Address Table');
which checks the address state in the database before and after the 'onAfterAddressUpdate' event.
I had to modify the code a bit as your code was basing itself on the address_user_id instead of the address_id and thus it was not always logging the correct address and thus provided false results in some of my tests.
Finally, I've left the code:
if($event== 'onafteraddressupdate'){
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_address WHERE address_id = '.$args[0]->address_id);
$address = $db->loadObject();
hikashop_writeToLog($address, 'xxx');
hikashop_writeToLog(get_class($this->_observers[$key]), 'xxx');
$db->setQuery('SELECT * FROM #__hikashop_address WHERE address_id = '.$args[0]->address_id);
$address = $db->loadObject();
hikashop_writeToLog($address, 'xxx');
}
in the file libraries/joomla/event/dispatcher;php
That code will log the address data from the database before and after each plugin has been called as well as the plugin class.
All these pieces of code can now be removed (you can keep the first one in case you still have addresses with the wrong address_state already in the database).
If you check the folder media/com_hikashop/upload/safe/logs you will see many log files. I've basically incremented the number of the report by 1 for each test I've made. These log files can also be deleted after you review them.
The interesting ones are report_483062856.log and report_483062858.log
If you check report_483062856.log, you'll see that :
- the address_state is empty before the call to triggerEvent
- the address_state is empty before the trigger of the address mass action plugin (with the log line plgHikashopMassaction_address)
- the address_state is empty after the trigger of the address mass action plugin
- the address_state is set to state_malta_2408 after the call to triggerEvent
So first, thanks to that debug you can see that there is only one plugin being called by the triggerEvent call and it's the address mass action plugin.
And the strange thing here is that the address_state is not changed by the mass action plugin but still, after the triggerEvent call, the address_state happens to be state_malta_2408 for some reason.
So I'm tempted to say that the issue might come from a Stored Procedure in your MySQL which would be triggered automatically by the saving of the address with the address mass action, but not having direct access to the database, I can't say for sure.
But since it seems to be linked to the mass action "Staat veldje" saving the address, I decided to disable that mass action in your backend to see if it would prevent that from happening. And the result is what you can see in the report_483062858.log file.
In it, the mass action plugin is still called but the address_state stays empty from start to finish.
So to conclude, disabling the "Staat veldje" mass action you created fixes the problem, but I'm not sure why since it doesn't have that malta state filled in it and thus it might be linked to something on the database side triggered by that mass action.
I spent more or less one hour on the debugging and analysis. Here is the payment link for that time:
www.hikashop.com/component/hikashop/prod...d-4/quantity-16.html