With the changes to addresses in Craft 4 I'm trying to do a cleanup of 80 000 addresses I have, many who does not have a valid user or commerce orders connceted to them.

Trying to fetch all addresses I get an error trying to echo the address ID or just simply var_dump it.

Exception 'yii\base\InvalidConfigException' with message 'Invalid owner ID: 676980'

I suspect this is becase they do not have a valud user connected to them, since we on craft 3 cleaned up users and orders after a certain amount of time, but did nothing to the addresses...

There are also a lot of duplicates, since the original vue cart created a new address every time they updated anything in the address, since guest userrs could not edit existing addresses.

Is there a way to get around this error? Since it seems to go off as soon as I try to do anything with the address object

The code I'm currently trying to execute looks like this, the final verrsion would delete any orders not connected to an user or order.

$addresses = Address::find()->all();

    foreach ($addresses as $key => $address) {
  • Also receiving this error after updating from Craft CMS 3.9.x. Can't see any reason for this happening after having ran ./craft commerce/upgrade. Received the same error when ./craft resave/addresses. Have you managed to find a solution or at the least have any idea what the issue might be caused by? Thanks Commented Dec 11, 2023 at 23:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.