From 9fdafc5e3858e56a86565c555a8eac8f075543b9 Mon Sep 17 00:00:00 2001 From: adamlevenson Date: Fri, 11 Dec 2015 15:48:34 -0800 Subject: [PATCH] Allow command line option to specify when created --- src/KJ/Magento/Command/Order/Create/DummyCommand.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/KJ/Magento/Command/Order/Create/DummyCommand.php b/src/KJ/Magento/Command/Order/Create/DummyCommand.php index 3550a3c..f5fe23c 100644 --- a/src/KJ/Magento/Command/Order/Create/DummyCommand.php +++ b/src/KJ/Magento/Command/Order/Create/DummyCommand.php @@ -46,6 +46,7 @@ protected function configure() ->addOption('payment', null, InputOption::VALUE_OPTIONAL, "A payment method code to use for the order. Defaults to 'checkmo'") ->addOption('cc_token', null, InputOption::VALUE_OPTIONAL, "Token to use for payment method, if applicable") ->addOption('email', null, InputOption::VALUE_OPTIONAL, "Send order email to customer (0/1)") + ->addOption('days_ago', null, InputOption::VALUE_OPTIONAL, "Number of days ago to create this order.") ->setDescription('(Experimental) Create a dummy order using a random customer, product, and date.') ; } @@ -216,7 +217,12 @@ protected function _loadRandomProduct($skuPattern = null) protected function getCreatedAt() { - $daysAgo = rand(1, 365 * 2); + $daysAgo = $this->_input->getOption('days_ago', null); + + if (is_null($daysAgo)) { + $daysAgo = rand(1, 365 * 2); + } + $createdAtTimestamp = time() - $daysAgo * 24 * 60 * 60; $createdAtString = date('Y-m-d', $createdAtTimestamp);