Doug Sparling

Mobile/Web Developer

Category: magento

Delete Magento Orders

by Doug Sparling

require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);                                   
$order_ids = array(
  'ordernumber1',
  'ordernumber2',
  'ordernumber3',
);

foreach ( $order_ids as $id ) {
    try {
        Mage::getModel('sales/order')->loadByIncrementId($id)->delete();
        echo "order #" . $id . " has been removed" . PHP_EOL;
    }catch(Exception $e){
        echo "order #" . $id . " could not be removed: " . $e->getMessage() . PHP_EOL;
    }
}
echo "Done..." . PHP_EOL;

Magento – Command Line Installation

by Doug Sparling

You may be like me and have encountered errors trying to install Magento on Dreamhost. Or maybe you’d just prefer to bypass the whole web install. Either way, here’s how you can install Magento via PHP CLI. Of course, you’ll want to replace the path to PHP to match your server environment and update the values of the arguments to work with your setup.

$ /usr/local/bin/php -f install.php -- \
--license_agreement_accepted "yes" \
--locale "en_US" \
--timezone "America/Los_Angeles" \
--default_currency "USD" \
--db_host "mysql.example.com" \
--db_name "your_db_name" \
--db_user "your_db_username" \
--db_pass "your_db_password" \
--db_prefix "" \
--admin_frontname "admin" \
--url "http://www.examplesite.com/store" \
--use_rewrites "yes" \
--use_secure "no" \
--secure_base_url "" \
--use_secure_admin "no" \
--admin_firstname "your_first_name" \
--admin_lastname "your_last_name" \
--admin_email "your_email@example.com" \
--admin_username "your_admin_username" \
--admin_password "your_admin_password"

The install will take some time, so be patient. Once it’s all done (and assuming the installation is successful), you will see output similar to the following:

SUCCESS: 90f02d045c51767ccee093107b2c5eee

Hang on to that string. It’s your Magento encryption key. But if you forget, fear not, it can be found here:

app/etc/local.xml