¿cómo puedo eliminar el pedido de prueba de magento


He hecho un sitio web en magento. Ahora está en vivo y quiero eliminar todo el orden de prueba. Sé que hay alguna tabla en todo este orden se almacenan. pero no conozco el nombre de esa mesa. Si algún cuerpo tiene algún script que puede eliminar todos los datos de la orden.

Por favor, déme o mencione el nombre de todas las tablas que almacenan la información del pedido

 32
Author: Kara, 2010-12-24

9 answers

  1. Vaya a admin > ventas > pedidos
  2. Anote sus órdenes de prueba id incrementales, por ejemplo 100000001,100000002,100000003,100000111,100000112,100000199
  3. ahora cree un archivo php en el directorio raíz de magento y asígnele el nombre: remove_test_orders.php
  4. Pegue el siguiente código:

    require 'app/Mage.php';
    Mage::app('admin')->setUseSessionInUrl(false);                                                                                                                 
    //replace your own orders numbers here:
    $test_order_ids=array(
      '100000001',
      '100000002',
      '100000003',
      '100000111',
      '100000112',
      '100000199',
    );
    foreach($test_order_ids as $id){
        try{
            Mage::getModel('sales/order')->loadByIncrementId($id)->delete();
            echo "order #".$id." is removed".PHP_EOL;
        }catch(Exception $e){
            echo "order #".$id." could not be remvoved: ".$e->getMessage().PHP_EOL;
        }
    }
    echo "complete.";
    
  5. Ahora vaya a la línea de comandos y ejecute:

    Php remove_test_orders.php

  6. Al final, elimina remove_test_orders.php.

 64
Author: cubny,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-02 10:34:51

La respuesta anterior es demasiado antigua y hay un inconveniente de esta respuesta que no vacía las tablas de pago, por lo que hay una posibilidad de legado.
puede usar el siguiente código que también eliminará la información de pago.

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;

SET FOREIGN_KEY_CHECKS=1; 
 15
Author: urfusion,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-07-11 13:14:24

Echa un vistazo a Cómo eliminar pedidos de Magento

<?php
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
Mage::register('isSecureArea', 1);
//until here you gained access to the Magento models. The rest is custom code

$orderId = 156;//put here the id of the order you want to delete. THE ONE FROM THE DATABASE NOT THE INCREMENT_ID

$order = Mage::getModel('sales/order')->load($orderId);

$invoices = $order->getInvoiceCollection();
foreach ($invoices as $invoice){
   $invoice->delete();
}

$creditnotes = $order->getCreditmemosCollection();
foreach ($creditnotes as $creditnote){
   $creditnote->delete();
}

$shipments = $order->getShipmentsCollection();
foreach ($shipments as $shipment){
   $shipment->delete();
}

$order->delete();
?>
 8
Author: Renon Stewart,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-25 23:40:43

Configuré un repositorio para mantener scripts SQL simples para que se ejecuten antes de lanzar un nuevo sitio de Magento. Hasta ahora pueden ayudar:

  1. datos de prueba vacíos de Mage; órdenes, clientes, informes, registros, etc.
  2. datos de prueba vacíos de varias extensiones
  3. establezca los ID deseados para el siguiente pedido, factura, envío y creditmemos

Https://github.com/ccondrup/mage-reset
Ayudar a mejorar!

 4
Author: ccondrup,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-05-05 00:57:07

He creado una herramienta de línea de comandos de código abierto

Puedes usarlo así:

#delete order by increment id
php -f shell/delete-order.php -- --increment-id 100000001

#test delete order by increment id (wont actually delete it)
php -f shell/delete-order.php -- --dry-run --order-id 32

Https://github.com/mauricioprado00/magento-delete-order/releases

 3
Author: useless,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-06-01 16:42:14

Casi todas las respuestas anteriores tienen problemas con restricciones de clave foránea o nombres de tabla incorrectos. Pude lograr la eliminación en un Magento v 1.9.1.0 CE utilizando el SQL a continuación, modifiqué el SQL dado en respuestas anteriores:

    SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `mg_sales_flat_creditmemo`;
TRUNCATE `mg_sales_flat_creditmemo_comment`;
TRUNCATE `mg_sales_flat_creditmemo_grid`;
TRUNCATE `mg_sales_flat_creditmemo_item`;
TRUNCATE `mg_sales_flat_invoice`;
TRUNCATE `mg_sales_flat_invoice_comment`;
TRUNCATE `mg_sales_flat_invoice_grid`;
TRUNCATE `mg_sales_flat_invoice_item`;
TRUNCATE `mg_sales_flat_order`;
TRUNCATE `mg_sales_flat_order_address`;
TRUNCATE `mg_sales_flat_order_grid`;
TRUNCATE `mg_sales_flat_order_item`;
TRUNCATE `mg_sales_flat_order_payment`;
TRUNCATE `mg_sales_flat_order_status_history`;
TRUNCATE `mg_sales_flat_quote`;
TRUNCATE `mg_sales_flat_quote_address`;
TRUNCATE `mg_sales_flat_quote_address_item`;
TRUNCATE `mg_sales_flat_quote_item`;
TRUNCATE `mg_sales_flat_quote_item_option`;
TRUNCATE `mg_sales_flat_quote_payment`;
TRUNCATE `mg_sales_flat_quote_shipping_rate`;
TRUNCATE `mg_sales_flat_shipment`;
TRUNCATE `mg_sales_flat_shipment_comment`;
TRUNCATE `mg_sales_flat_shipment_grid`;
TRUNCATE `mg_sales_flat_shipment_item`;
TRUNCATE `mg_sales_flat_shipment_track`;
TRUNCATE `mg_sales_invoiced_aggregated`;
TRUNCATE `mg_sales_invoiced_aggregated_order`;
TRUNCATE `mg_sales_order_aggregated_created`;
TRUNCATE `mg_sendfriend_log`;
TRUNCATE `mg_tag`;
TRUNCATE `mg_tag_relation`;
TRUNCATE `mg_tag_summary`;
TRUNCATE `mg_wishlist`;
TRUNCATE `mg_log_quote`;
TRUNCATE `mg_report_event`;
ALTER TABLE `mg_sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `mg_sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `mg_sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `mg_tag` AUTO_INCREMENT=1;
ALTER TABLE `mg_tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `mg_tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `mg_wishlist` AUTO_INCREMENT=1;
ALTER TABLE `mg_log_quote` AUTO_INCREMENT=1;
ALTER TABLE `mg_report_event` AUTO_INCREMENT=1;

SET FOREIGN_KEY_CHECKS=1; 

Recuerde cambiar mg_ a su prefijo de tabla.

 1
Author: Abubakar Siddiq Ango,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-24 07:52:26
Create a file in the root directory and paste the following code.
It will remove all the orders from admin grid!

<?php

/**
 * @author Dejan Radic <[email protected]>
 */

if (version_compare(phpversion(), '5.2.0', '<')===true) {
    echo  '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
    exit;
}

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

$mageFilename = 'app/Mage.php';

if (!file_exists($mageFilename)) {
    echo $mageFilename." was not found";
    exit;
}

require_once $mageFilename;

Mage::app();

$executionPath = null;

/*
 * determine Magento Edition
 */
if (file_exists('LICENSE_EE.txt')) {
    $edition = 'EE';
}elseif (file_exists('LICENSE_PRO.html')) {
    $edition = 'PE';
} else {
    $edition = 'CE';    
}

if(($edition=='EE' && version_compare(Mage::getVersion(), '1.11.0.0.', '<')===true)
        || ($edition=='PE' && version_compare(Mage::getVersion(), '1.11.0.0.', '<')===true)
        || ($edition=='CE' && version_compare(Mage::getVersion(), '1.6.0.0.', '<')===true)
  ){
   $executionPath = 'old'; 
} else {
   $executionPath = 'new';  
}

$xpathEntity = 'global/models/sales_entity/entities//table';

if ($executionPath == 'old') {
    $xpathResource = 'global/models/sales_mysql4/entities//table';
} else {
    $xpathResource = 'global/models/sales_resource/entities//table';
}

$salesEntitiesConf = array_merge(
    Mage::getSingleton('core/config')->init()->getXpath($xpathEntity), 
    Mage::getSingleton('core/config')->init()->getXpath($xpathResource)
);

$resource = Mage::getSingleton('core/resource');
$connection = $resource->getConnection('core_write');


/*
 * If you want delete System/Order Statuses (Status and State) you
 * should comments below lines (46-51)
 */
$skipTables = array (
        $resource->getTableName('sales_order_status'),
        $resource->getTableName('sales_order_status_state'),
        $resource->getTableName('sales_order_status_label')
    );
$salesEntitiesConf = array_diff($salesEntitiesConf, $skipTables);


/*

Multiple RDBMS Support in Magento CE 1.6+ / EE 1.11+
    http://www.magentocommerce.com/images/uploads/RDBMS_Guide2.pdf

2.2. Adapters:

... The new Varien_DB_Adapter_Interface was added to sign a contract that all 
developed adapters must execute in order to get Magento working on an actual 
database. The interface describes the list of methods and constants that can be used by resource models...

Used below in the loop:

 * If $executionPath == 'old'
    * Varien_Db_Adapter_Pdo_Mysql::showTableStatus()
    * Varien_Db_Adapter_Pdo_Mysql::truncate()  
 * Else
    * Varien_Db_Adapter_Interface::isTableExists()
    * Varien_Db_Adapter_Interface::truncateTable()

*/

while ($table = current($salesEntitiesConf) ){
    $table = $resource->getTableName($table);

    if ($executionPath == 'old') {
        $isTableExists = $connection->showTableStatus($table);
    } else {
        $isTableExists = $connection->isTableExists($table);
    }
    if ($isTableExists) {
        try {
            if ($executionPath == 'old') {
                $connection->truncate($table);
            } else {
                $connection->truncateTable($table);
            }

            printf('Successfully truncated the <i style="color:green;">%s</i> table.<br />', $table);
        } catch(Exception $e) {
            printf('Error <i style="color:red;">%s</i> occurred truncating the <i style="color:red;">%s</i> table.<br />', $e->getMessage(), $table);
        }
    }

    next($salesEntitiesConf);
}

exit('All done...');

?>
 1
Author: Vivek Khandelwal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-19 09:29:27
 0
Author: Richard Feraro,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-01-04 15:53:14

Con esta extensión, no solo eliminará el(los) pedido(s), factura(s), envío(s), memo(s) de crédito, RMA (s), sino que también revertirá toda la información, como impuestos recaudados, productos eliminados, al inventario y restablecerá los ID de incremento.

Si comete un error al crear el pedido/factura/envío/nota de crédito/RMA y desea eliminarlo, esta extensión puede hacerlo muy bien.

Hay un sitio de prueba donde puede probarlo primero y ver si funciona para usted o ni.

Http://www.magentocommerce.com/magento-connect/ultimate-delete-order.html

 0
Author: user1801605,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-27 15:17:38