删除 Magento 中的所有客户

发布于 2024-10-21 13:47:45 字数 81 浏览 2 评论 0原文

我需要从我的 Magento 安装中删除所有客户端,因为它们的日期不正确。我开发的网站中有 70,000 个客户。我怎样才能用 SQL 做到这一点?

I need remove all clients from my Magento install, because they have bad dates. I have 70,000 customers in my developed site. How can I do this with SQL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

赴月观长安 2024-10-28 13:47:45

首先进行备份并在开发服务器上进行测试! 这将删除包括日志在内的所有客户数据。

SET FOREIGN_KEY_CHECKS=0;
-- reset customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
TRUNCATE customer_entity_decimal;
TRUNCATE customer_entity_int;
TRUNCATE customer_entity_text;
TRUNCATE customer_entity_varchar;
TRUNCATE log_customer;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;

ALTER TABLE customer_address_entity AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE customer_entity AUTO_INCREMENT=1;
ALTER TABLE customer_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE log_customer AUTO_INCREMENT=1;
ALTER TABLE log_visitor AUTO_INCREMENT=1;
ALTER TABLE log_visitor_info AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

Make a BACKUP and test on a dev server first! This will DELETE all customer data including logs.

SET FOREIGN_KEY_CHECKS=0;
-- reset customers
TRUNCATE customer_address_entity;
TRUNCATE customer_address_entity_datetime;
TRUNCATE customer_address_entity_decimal;
TRUNCATE customer_address_entity_int;
TRUNCATE customer_address_entity_text;
TRUNCATE customer_address_entity_varchar;
TRUNCATE customer_entity;
TRUNCATE customer_entity_datetime;
TRUNCATE customer_entity_decimal;
TRUNCATE customer_entity_int;
TRUNCATE customer_entity_text;
TRUNCATE customer_entity_varchar;
TRUNCATE log_customer;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;

ALTER TABLE customer_address_entity AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_address_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE customer_entity AUTO_INCREMENT=1;
ALTER TABLE customer_entity_datetime AUTO_INCREMENT=1;
ALTER TABLE customer_entity_decimal AUTO_INCREMENT=1;
ALTER TABLE customer_entity_int AUTO_INCREMENT=1;
ALTER TABLE customer_entity_text AUTO_INCREMENT=1;
ALTER TABLE customer_entity_varchar AUTO_INCREMENT=1;
ALTER TABLE log_customer AUTO_INCREMENT=1;
ALTER TABLE log_visitor AUTO_INCREMENT=1;
ALTER TABLE log_visitor_info AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
聆听风音 2024-10-28 13:47:45
Mage::register('isSecureArea', true);

$customers = Mage::getModel("customer/customer")->getCollection();

foreach ($customers as $customer) {
    $customer->delete();
}

不过,请务必知道您在做什么。如果不需要删除,您也可以禁用客户。

Mage::register('isSecureArea', true);

$customers = Mage::getModel("customer/customer")->getCollection();

foreach ($customers as $customer) {
    $customer->delete();
}

Be sure to know what you are doing though.. You can disable the customer as well if delete is not what you need.

忘东忘西忘不掉你 2024-10-28 13:47:45

或者你只是构建一个 shell 脚本并执行类似的操作(速度不快,但很干净):

 /*
 * Starter
 * */
public function run()
{
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    ini_set('memory_limit', '4096M');
    if (!$this->getArg('iknowwhatido') || $this->getArg('iknowwhatido') != 'yes') {
        $this->usageHelp();
        echo "DEACTIVATED (call it with param '-iknowwhatido yes' to make it work!) \n";
        return -1;
    }
    Mage::register('isSecureArea', true);
    $customers = Mage::getModel("customer/customer")->getCollection()->delete();
}

Or you just build a shell script and do something like that (not fast, but it is clean):

 /*
 * Starter
 * */
public function run()
{
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    ini_set('memory_limit', '4096M');
    if (!$this->getArg('iknowwhatido') || $this->getArg('iknowwhatido') != 'yes') {
        $this->usageHelp();
        echo "DEACTIVATED (call it with param '-iknowwhatido yes' to make it work!) \n";
        return -1;
    }
    Mage::register('isSecureArea', true);
    $customers = Mage::getModel("customer/customer")->getCollection()->delete();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文