Skip to main content
added 15 characters in body
Source Link
Sukeshini
  • 10k
  • 18
  • 73
  • 126

Try this, (you can use an external script to run the below code snippet. Magento CE 1.8)

    // Test orders collection.
    $collection = Mage::getModel('sales/order')->getCollection();
                    ->addFieldToFilter('entity_id', (array) $orderIds);
        
    // Retrieve the write connection.
    $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
    
    foreach($collection as $order) {
        $orderIncrementId = $order->getIncrementId();
        $query = "SET @orderId = '".$orderIncrementId."';
                SET FOREIGN_KEY_CHECKS = 1;
                DELETE FROM sales_flat_quote
                WHERE reserved_order_id = @orderId;
                DELETE FROM sales_flat_order
                WHERE increment_id = @orderId;
                ";
        
        // Execute the query.
        $writeConnection->query($query);
    }

NOTE: This code is not according to the standards since it uses direct SQL queries. But it will do what you want

Try this, (you can use an external script to run the below code snippet.)

    // Test orders collection.
    $collection = Mage::getModel('sales/order')->getCollection();
                    ->addFieldToFilter('entity_id', (array) $orderIds);
        
    // Retrieve the write connection.
    $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
    
    foreach($collection as $order) {
        $orderIncrementId = $order->getIncrementId();
        $query = "SET @orderId = '".$orderIncrementId."';
                SET FOREIGN_KEY_CHECKS = 1;
                DELETE FROM sales_flat_quote
                WHERE reserved_order_id = @orderId;
                DELETE FROM sales_flat_order
                WHERE increment_id = @orderId;
                ";
        
        // Execute the query.
        $writeConnection->query($query);
    }

NOTE: This code is not according to the standards since it uses direct SQL queries. But it will do what you want

Try this, (you can use an external script to run the below code snippet. Magento CE 1.8)

    // Test orders collection.
    $collection = Mage::getModel('sales/order')->getCollection();
                    ->addFieldToFilter('entity_id', (array) $orderIds);
        
    // Retrieve the write connection.
    $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
    
    foreach($collection as $order) {
        $orderIncrementId = $order->getIncrementId();
        $query = "SET @orderId = '".$orderIncrementId."';
                SET FOREIGN_KEY_CHECKS = 1;
                DELETE FROM sales_flat_quote
                WHERE reserved_order_id = @orderId;
                DELETE FROM sales_flat_order
                WHERE increment_id = @orderId;
                ";
        
        // Execute the query.
        $writeConnection->query($query);
    }

NOTE: This code is not according to the standards since it uses direct SQL queries. But it will do what you want

Source Link
Sukeshini
  • 10k
  • 18
  • 73
  • 126

Try this, (you can use an external script to run the below code snippet.)

    // Test orders collection.
    $collection = Mage::getModel('sales/order')->getCollection();
                    ->addFieldToFilter('entity_id', (array) $orderIds);
        
    // Retrieve the write connection.
    $writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
    
    foreach($collection as $order) {
        $orderIncrementId = $order->getIncrementId();
        $query = "SET @orderId = '".$orderIncrementId."';
                SET FOREIGN_KEY_CHECKS = 1;
                DELETE FROM sales_flat_quote
                WHERE reserved_order_id = @orderId;
                DELETE FROM sales_flat_order
                WHERE increment_id = @orderId;
                ";
        
        // Execute the query.
        $writeConnection->query($query);
    }

NOTE: This code is not according to the standards since it uses direct SQL queries. But it will do what you want