I'm looking for the correct way to delete all of the products and related variants from my Commerce site. This is just for my local development environment as I'm debugging an import job. The delete() function is the wrong code in the following console controller:

public function actionNuke()
    $products = Product::findAll();
    foreach($products as $product){
    $this->stdout("Deleted All Products", Console::FG_GREEN);
    return ExitCode::OK;

1 Answer 1


This should do it:


Then run garbage collection.

  • 1
    Ran the command php craft gc --delete-all-trashed=1 afterwards for the garbage collection. Works great, thanks!
    – cherrykoda
    Commented Mar 9, 2023 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.