Added script to create AddressLink records from Order->billingaddress_id
This commit is contained in:
45
scripts/order-billingaddress-to-addresslink.php
Normal file
45
scripts/order-billingaddress-to-addresslink.php
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
/*
|
||||
* creates AddressLink records from Order->billingaddress_id, if it doesn't exist
|
||||
*/
|
||||
require("../config/config.php");
|
||||
|
||||
define('FRONKDB_SQLDEBUG',false);
|
||||
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
||||
|
||||
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
|
||||
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");
|
||||
|
||||
$me = new User(1);
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach(OrderModel::getAll() as $order) {
|
||||
if(!$order->billingaddress_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['address_id'] = $order->billingaddress_id;
|
||||
$data['origin_address_id'] = $order->owner_id;
|
||||
$data['type'] = "billing";
|
||||
|
||||
$link = AddressLinkModel::getFirst($data);
|
||||
if($link && $link->id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['create_by'] = $order->create_by;
|
||||
$data['edit_by'] = $order->edit_by;
|
||||
|
||||
$link = AddressLinkModel::create($data);
|
||||
if(!$link->save()) {
|
||||
echo "Unable to save billingaddress: ".$data['address_id'].", origin address: ".$data['origin_address_id']."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "Created $i billingaddress linkings\n";
|
||||
Reference in New Issue
Block a user