Skip to content

Commit

Permalink
Merge pull request #6 from SpiriitLabs/dev
Browse files Browse the repository at this point in the history
Bump 1.0.2
Improve Creation of dummy order with existing and compatible products
  • Loading branch information
RaphaelSpiriit authored Dec 12, 2023
2 parents c716bd9 + 4d0e076 commit a5f4276
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
12 changes: 10 additions & 2 deletions classes/orderCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ public function createDummyOrders($nb = 50)
{
for ($o = 1; $o <= $nb; ++$o) {
$customer_id = Db::getInstance()->getValue('SELECT id_customer FROM `' . _DB_PREFIX_ . 'customer` ORDER BY RAND()');
$address_id = Db::getInstance()->getValue('SELECT id_address FROM `' . _DB_PREFIX_ . 'address` ORDER BY RAND()');
$sql = new DbQuery();
$sql->select('a.id_address');
$sql->from('address', 'a');
$sql->innerJoin('country', 'c', 'c.id_country = a.id_country');
$sql->where('c.active = 1');
$sql->orderBy('RAND()');
$address_id = Db::getInstance()->getValue($sql);
$carrier_id = Db::getInstance()->getValue('SELECT id_carrier FROM `' . _DB_PREFIX_ . 'carrier` ORDER BY RAND()');
$state_id = Db::getInstance()->getValue('SELECT id_order_state FROM `' . _DB_PREFIX_ . 'order_state` ORDER BY RAND()');

Expand All @@ -210,7 +216,8 @@ public function createDummyOrders($nb = 50)

$new_cart->add();

for ($p = 1; $p <= 5; ++$p) {
$products = Db::getInstance()->executeS('SELECT id_product FROM ' . _DB_PREFIX_ . 'product ORDER BY RAND() LIMIT 5');
foreach (array_column($products, 'id_product') as $p) {
$result = $new_cart->updateQty(rand(1, 5), $p);
}

Expand All @@ -231,6 +238,7 @@ public function createDummyOrders($nb = 50)

$history = new OrderHistory();
$history->id_order = (int) $id_order;
$history->id_order_state = (int) $state_id;
$history->changeIdOrderState((int) $state_id, (int) $history->id_order);
$history->save();
}
Expand Down
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion prestaclean.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct()
{
$this->name = 'prestaclean';
$this->tab = 'administration';
$this->version = '1.0.1';
$this->version = '1.0.2';
$this->author = 'Spiriit';
$this->need_instance = 0;
$this->bootstrap = true;
Expand Down
38 changes: 38 additions & 0 deletions views/js/order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 2013-2022 In Spiriit
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author In Spiriit <tech@inspiriit.io>
* @copyright 2013-2022 In Spiriit
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

document.addEventListener("DOMContentLoaded", function() {
const deleteBtn = document.querySelector('.delete-order');

// Confirm delete button click
deleteBtn && deleteBtn.addEventListener('click', function(e) {
if(!confirm(confirmDeleteLang)) {
e.preventDefault();
e.stopPropagation();
return;
}
});

});

0 comments on commit a5f4276

Please sign in to comment.