Added script for magenta PNO order id match
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
//require 'vendor/autoload.php';
|
||||
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);
|
||||
|
||||
$folder = __DIR__."/import/";
|
||||
$csvname = "magenta-missing_rml_pno_order_ids.csv";
|
||||
$filename = $folder.$csvname;
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$log = mfLoghandler::singleton();
|
||||
|
||||
$input = fopen($filename, "r");
|
||||
|
||||
echo "order_id;cam_id;rml_order_code\n";
|
||||
|
||||
$l = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$l++;
|
||||
if($l == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ext_order_id = $db->escape($csv[0]);
|
||||
$ext_cam_id = $db->escape($csv[1]);
|
||||
$ucode = "";
|
||||
|
||||
$res = $db->select("Preorder", "*", "addon_data LIKE '%$ext_order_id%' AND (deleted = 0 OR deleted IS NULL)");
|
||||
if(!$db->num_rows($res)) {
|
||||
file_put_contents("php://stderr", "!!! No order found for $ext_order_id\n");
|
||||
} elseif($db->num_rows($res) > 1) {
|
||||
file_put_contents("php://stderr", "!!! Multiple orders found for $ext_order_id!\n");
|
||||
} else {
|
||||
$order = $db->fetch_object($res);
|
||||
$ucode = $order->ucode;
|
||||
}
|
||||
|
||||
echo "$ext_order_id;$ext_cam_id;$ucode\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user