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) {


Your Answer

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

Browse other questions tagged or ask your own question.