我需要删除所有客户从我的Magento安装,因为他们有错误的日期。我有70,000客户在我的开发网站。我怎么能用SQL做到这一点?
zvokhttg1#
首先在开发服务器上进行备份和测试!这将删除包括日志在内的所有客户数据。
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;
eivgtgni2#
Mage::register('isSecureArea', true); $customers = Mage::getModel("customer/customer")->getCollection(); foreach ($customers as $customer) { $customer->delete(); }
一定要知道你在做什么,虽然..你可以禁用客户,以及如果删除不是你需要的。
yduiuuwa3#
或者,您只需构建一个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(); }
3条答案
按热度按时间zvokhttg1#
首先在开发服务器上进行备份和测试!这将删除包括日志在内的所有客户数据。
eivgtgni2#
一定要知道你在做什么,虽然..你可以禁用客户,以及如果删除不是你需要的。
yduiuuwa3#
或者,您只需构建一个shell脚本并执行类似的操作(速度不快,但很干净):