-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdeleteQuote.php
More file actions
102 lines (87 loc) · 4.82 KB
/
deleteQuote.php
File metadata and controls
102 lines (87 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
require dirname(__FILE__) . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
class Outslide extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$myClass = $this->_objectManager->create('DeleteQuote');
$myClass->deleteQuotes();
return $this->_response;
}
}
class DeleteQuote{
protected $_objectManager;
protected $_registry;
/**
* @var CustomerRepositoryInterface
*/
protected $customerRepository;
public function __construct(
\Magento\Framework\Registry $registry
)
{
$this->_registry = $registry;
$this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
}
public function deleteQuotes() {
$this->_registry->register("isSecureArea", true);
$limit = 50000;
$collection = $this->_objectManager->create('\Magento\Quote\Model\Quote');
$quotes = $collection->getCollection()
// ->addFieldToFilter("customer_email", ["like" => "%@qq.com"])
// ->addFieldToFilter("customer_firstname", ["like" => "%\.com%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%点com%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%\.top%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%点top%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%\.blog%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%http%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%www%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%link%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Bitcоin%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%USDT%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%USDC%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%USDD%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Notify%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Attach%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%ACCOUNT%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%BALANCE%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%TRONLINK%"])
->addFieldToFilter("customer_firstname", ["like" => "%TRIAL%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Customer%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%client%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%friend%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Hello%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%your%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%Message%"])
// ->addFieldToFilter("customer_firstname", ["like" => "%private%"])
->setPageSize($limit)->setCurPage(1);
$quotesDeleted = 0;
$quotesAddressDeleted = 0;
foreach ($quotes as $quote) {
// echo $quote->getData('customer_email');
// continue;
// if ($quote->getId() && !$quote->getIsActive() && !$quote->getReservedOrderId()) {
if ($quote->getId() && !$quote->getReservedOrderId()) {
$addressCollection = $quote->getAddressesCollection();
foreach ($addressCollection as $address) {
// You can choose to delete either the shipping or billing address
// Delete all addresses associated with the quote
$address->delete();
$quotesAddressDeleted++;
}
$quote->delete();
$quotesDeleted++;
}
}
if ($quotesDeleted) {
echo __('A total of %1 record(s) Quotes were deleted.', $quotesDeleted);
}
if ($quotesAddressDeleted) {
echo __('A total of %1 record(s) Quotes Address were deleted.', $quotesAddressDeleted);
}
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('Outslide');
$bootstrap->run($app);