43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\ZNZBundle\Resources\script;
|
|
|
|
use KupShop\AdminBundle\Util\Script\Script;
|
|
use KupShop\KupShopBundle\Util\FileUtil;
|
|
use Query\Operator;
|
|
|
|
class ImportOrderEmailsScript extends Script
|
|
{
|
|
protected static $name = '[ZNZ] Import order emails';
|
|
protected static $defaultParameters = [
|
|
'file' => 'data/files/emails.csv',
|
|
];
|
|
|
|
protected function run(array $arguments)
|
|
{
|
|
$updated = 0;
|
|
foreach (FileUtil::loadCSV($arguments['file'], "\t") as $key => $item) {
|
|
// skip header
|
|
if ($key == 0) {
|
|
continue;
|
|
}
|
|
|
|
$this->progress();
|
|
|
|
$number = substr($item[0], 2);
|
|
|
|
$updated += sqlQueryBuilder()
|
|
->update('orders')
|
|
->directValues(['invoice_email' => $item[1]])
|
|
->where(Operator::equals(['order_no' => $number]))
|
|
->execute();
|
|
}
|
|
|
|
$this->log('Updated: '.$updated);
|
|
}
|
|
}
|
|
|
|
return ImportOrderEmailsScript::class;
|