Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset all commerce data command (CLI) #581

Closed
goellner opened this issue Nov 23, 2018 · 3 comments
Closed

Reset all commerce data command (CLI) #581

goellner opened this issue Nov 23, 2018 · 3 comments
Labels
💡 enhancement Ideas and suggestions 🧾 orders

Comments

@goellner
Copy link

After testing and development on a local machine, it would be nice to clear the orders and customers, to have a clean database on production.

Is there any other way to achieve that in the meantime?

@lukeholder lukeholder added the 💡 enhancement Ideas and suggestions label Nov 24, 2018
@lukeholder
Copy link
Member

lukeholder commented Nov 24, 2018

Deletion of all Orders would be done in PHP like this:

$query = \craft\commerce\elements\Orders::find();
$elementsService = Craft::$app->getElements();
foreach ($query->limit(null)->all() as $element) {
     $elementsService->deleteElement($element);
}

Deletion of all customers:

\craft\commerce\records\Customer::deleteAll();

Will keep the ticket open as an enhancement.

@lukeholder lukeholder added this to the 3.0 milestone Oct 11, 2019
@lukeholder
Copy link
Member

See #1043

@lukeholder lukeholder changed the title Clear Orders and Customers via command line Reset all commerce data command (CLI) Oct 21, 2019
@lukeholder lukeholder self-assigned this Nov 11, 2019
@lukeholder lukeholder modified the milestones: 3.0, 3.x Dec 13, 2019
@nfourtythree nfourtythree modified the milestones: 3.x, Backlog Apr 1, 2020
@lukeholder lukeholder removed their assignment Oct 5, 2020
@lukeholder
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 enhancement Ideas and suggestions 🧾 orders
Projects
None yet
Development

No branches or pull requests

3 participants