2011-03-11 11 views

Respuesta

32

Hacer un BACKUP y la prueba en el servidor dev primero! Esto BORRARÁ todos los datos de los clientes, incluidos los registros.

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; 
+0

THX. : D trabajo correctamente! – davidselo

+4

La estructura de la tabla de Magento está sujeta a cambios y podría verse afectada por las extensiones. Aconsejo precaución cuando hago esto en las versiones más nuevas de magento. – forsvunnet

+0

Recibí un error en MySQL ejecutando las consultas anteriores: 'Valor predeterminado no válido para 'created_at''. Se puede resolver agregando esta línea al inicio: '/ *! 40101 SET @OLD_SQL_MODE = @@ SQL_MODE, SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO' * /;' (más aquí: http://stackoverflow.com/a/23147829/3763649) – Andrea

1

w3schools article on SQL delete pueden ayudar. ¿Por qué eliminarlos? - los perderás a todos. ¿Por qué no corregir las malas fechas?

responsabilidad: Por favor, tenga cuidado y no intente esto si usted no sabe lo que está haciendo

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

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

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

Asegúrese de saber lo que está haciendo, aunque .. Puede desactivar el cliente, así si de eliminación no es lo que necesita.

+0

gracias Kervin! muy útil :) – huzefam

0

O simplemente construir un script de shell y hacer algo por el estilo (no es rápido, pero es limpio):

/* 
* 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(); 
} 
Cuestiones relacionadas