From ffb502bb5be34cc1ab2e1d2f701080173e4deefc Mon Sep 17 00:00:00 2001 From: Dominik Shaim Ulrich Date: Fri, 22 Aug 2025 01:02:23 +0200 Subject: [PATCH 1/5] Update dashproducts.php --- dashproducts.php | 116 ++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 57 deletions(-) diff --git a/dashproducts.php b/dashproducts.php index c06bae2..3daa261 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -216,64 +216,66 @@ public function getTableBestSellers($date_from, $date_to) ); $body = []; - foreach ($products as $product) { - $product_obj = new Product((int) $product['product_id'], false, $this->context->language->id); - if (!Validate::isLoadedObject($product_obj)) { - continue; - } - - $productCategoryId = $product_obj->getDefaultCategory(); - if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) { - $productCategoryId = $productCategoryId['id_category_default']; - } - $category = new Category($productCategoryId, $this->context->language->id); - - $img = ''; - if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { - $image = new Image((int) $row_image['id_image']); - $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; - $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); - } - - $productPrice = $product['price']; - if (isset($product['price_attribute']) && $product['price_attribute'] != '0.000000') { - $productPrice = $product['price_attribute']; - } - - $body[] = [ - [ - 'id' => 'product', - 'value' => $img, - 'class' => 'text-center', - ], - [ - 'id' => 'product', - 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . + if (!empty($products)){ + foreach ($products as $product) { + $product_obj = new Product((int) $product['product_id'], false, $this->context->language->id); + if (!Validate::isLoadedObject($product_obj)) { + continue; + } + + $productCategoryId = $product_obj->getDefaultCategory(); + if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) { + $productCategoryId = $productCategoryId['id_category_default']; + } + $category = new Category($productCategoryId, $this->context->language->id); + + $img = ''; + if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { + $image = new Image((int) $row_image['id_image']); + $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; + $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); + } + + $productPrice = $product['price']; + if (isset($product['price_attribute']) && $product['price_attribute'] != '0.000000') { + $productPrice = $product['price_attribute']; + } + + $body[] = [ + [ + 'id' => 'product', + 'value' => $img, + 'class' => 'text-center', + ], + [ + 'id' => 'product', + 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . $this->context->getCurrentLocale()->formatPrice($productPrice, $this->context->currency->iso_code), - 'class' => 'text-center', - ], - [ - 'id' => 'category', - 'value' => $category->name, - 'class' => 'text-center', - ], - [ - 'id' => 'total_sold', - 'value' => $product['total'], - 'class' => 'text-center', - ], - [ - 'id' => 'sales', - 'value' => $this->context->getCurrentLocale()->formatPrice($product['sales'], $this->context->currency->iso_code), - 'class' => 'text-center', - ], - [ - 'id' => 'net_profit', - 'value' => $this->context->getCurrentLocale()->formatPrice(($product['sales'] - $product['expenses']), $this->context->currency->iso_code), - 'class' => 'text-center', - ], - ]; - } + 'class' => 'text-center', + ], + [ + 'id' => 'category', + 'value' => $category->name, + 'class' => 'text-center', + ], + [ + 'id' => 'total_sold', + 'value' => $product['total'], + 'class' => 'text-center', + ], + [ + 'id' => 'sales', + 'value' => $this->context->getCurrentLocale()->formatPrice($product['sales'], $this->context->currency->iso_code), + 'class' => 'text-center', + ], + [ + 'id' => 'net_profit', + 'value' => $this->context->getCurrentLocale()->formatPrice(($product['sales'] - $product['expenses']), $this->context->currency->iso_code), + 'class' => 'text-center', + ], + ]; + } + } return ['header' => $header, 'body' => $body]; } From 3debf4d6b6762da8cc6e31313bcb86891b510b7e Mon Sep 17 00:00:00 2001 From: Dominik Shaim Ulrich Date: Fri, 22 Aug 2025 01:03:31 +0200 Subject: [PATCH 2/5] Update dashproducts.php --- dashproducts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dashproducts.php b/dashproducts.php index 3daa261..483a3be 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -193,7 +193,7 @@ public function getTableBestSellers($date_from, $date_to) ], ]; - $products = Db::getInstance()->ExecuteS( + $products = Db::getInstance()->executeS( ' SELECT product_id, From 772474dae4fc06d13b302d84bad520e61e9a5261 Mon Sep 17 00:00:00 2001 From: Dominik Shaim Ulrich Date: Fri, 22 Aug 2025 01:06:13 +0200 Subject: [PATCH 3/5] Update dashproducts.php --- dashproducts.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/dashproducts.php b/dashproducts.php index 483a3be..2830903 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -196,22 +196,22 @@ public function getTableBestSellers($date_from, $date_to) $products = Db::getInstance()->executeS( ' SELECT - product_id, - product_name, - SUM(product_quantity-product_quantity_refunded-product_quantity_return-product_quantity_reinjected) as total, - p.price as price, - pa.price as price_attribute, - SUM(total_price_tax_excl / conversion_rate) as sales, - SUM(product_quantity * purchase_supplier_price / conversion_rate) as expenses + `product_id`, + `product_name`, + SUM(`product_quantity`-`product_quantity_refunded`-`product_quantity_return`-`product_quantity_reinjected`) as total, + p.`price` as price, + pa.`price` as price_attribute, + SUM(`total_price_tax_excl` / `conversion_rate`) as sales, + SUM(`product_quantity` * `purchase_supplier_price` / `conversion_rate`) as expenses FROM `' . _DB_PREFIX_ . 'orders` o - LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` od ON o.id_order = od.id_order - LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.id_product = product_id - LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON pa.id_product_attribute = od.product_attribute_id + LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` od ON o.`id_order` = od.`id_order` + LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.`id_product` = `product_id` + LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON pa.`id_product_attribute` = od.`product_attribute_id` WHERE `invoice_date` BETWEEN "' . pSQL($date_from) . ' 00:00:00" AND "' . pSQL($date_to) . ' 23:59:59" - AND valid = 1 + AND `valid` = 1 ' . Shop::addSqlRestriction(false, 'o') . ' - GROUP BY product_id, product_attribute_id - ORDER BY total DESC + GROUP BY `product_id`, `product_attribute_id` + ORDER BY `total` DESC LIMIT ' . (int) Configuration::get('DASHPRODUCT_NBR_SHOW_BEST_SELLER') ); @@ -249,8 +249,7 @@ public function getTableBestSellers($date_from, $date_to) ], [ 'id' => 'product', - 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . - $this->context->getCurrentLocale()->formatPrice($productPrice, $this->context->currency->iso_code), + 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . $this->context->getCurrentLocale()->formatPrice($productPrice, $this->context->currency->iso_code), 'class' => 'text-center', ], [ From 53a89ed343a3dd1a9e59a5a64f43c94ef644b242 Mon Sep 17 00:00:00 2001 From: Dominik Shaim Ulrich Date: Fri, 22 Aug 2025 01:10:37 +0200 Subject: [PATCH 4/5] Update dashproducts.php --- dashproducts.php | 119 ++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/dashproducts.php b/dashproducts.php index 2830903..b009b3f 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -216,65 +216,66 @@ public function getTableBestSellers($date_from, $date_to) ); $body = []; - if (!empty($products)){ - foreach ($products as $product) { - $product_obj = new Product((int) $product['product_id'], false, $this->context->language->id); - if (!Validate::isLoadedObject($product_obj)) { - continue; - } - - $productCategoryId = $product_obj->getDefaultCategory(); - if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) { - $productCategoryId = $productCategoryId['id_category_default']; - } - $category = new Category($productCategoryId, $this->context->language->id); - - $img = ''; - if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { - $image = new Image((int) $row_image['id_image']); - $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; - $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); - } - - $productPrice = $product['price']; - if (isset($product['price_attribute']) && $product['price_attribute'] != '0.000000') { - $productPrice = $product['price_attribute']; - } - - $body[] = [ - [ - 'id' => 'product', - 'value' => $img, - 'class' => 'text-center', - ], - [ - 'id' => 'product', - 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . $this->context->getCurrentLocale()->formatPrice($productPrice, $this->context->currency->iso_code), - 'class' => 'text-center', - ], - [ - 'id' => 'category', - 'value' => $category->name, - 'class' => 'text-center', - ], - [ - 'id' => 'total_sold', - 'value' => $product['total'], - 'class' => 'text-center', - ], - [ - 'id' => 'sales', - 'value' => $this->context->getCurrentLocale()->formatPrice($product['sales'], $this->context->currency->iso_code), - 'class' => 'text-center', - ], - [ - 'id' => 'net_profit', - 'value' => $this->context->getCurrentLocale()->formatPrice(($product['sales'] - $product['expenses']), $this->context->currency->iso_code), - 'class' => 'text-center', - ], - ]; - } - } + if (!empty($products)) { + foreach ($products as $product) { + $product_obj = new Product((int)$product['product_id'], false, $this->context->language->id); + if (!Validate::isLoadedObject($product_obj)) { + continue; + } + + $productCategoryId = $product_obj->getDefaultCategory(); + if (is_array($productCategoryId) && isset($productCategoryId['id_category_default'])) { + $productCategoryId = $productCategoryId['id_category_default']; + } + $category = new Category($productCategoryId, $this->context->language->id); + + $img = ''; + if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { + $image = new Image((int)$row_image['id_image']); + $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; + $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); + } + + $productPrice = $product['price']; + if (isset($product['price_attribute']) && $product['price_attribute'] != '0.000000') { + $productPrice = $product['price_attribute']; + } + + $body[] = [ + [ + 'id' => 'product', + 'value' => $img, + 'class' => 'text-center', + ], + [ + 'id' => 'product', + 'value' => '' . Tools::htmlentitiesUTF8($product['product_name']) . '' . '
' . + $this->context->getCurrentLocale()->formatPrice($productPrice, $this->context->currency->iso_code), + 'class' => 'text-center', + ], + [ + 'id' => 'category', + 'value' => $category->name, + 'class' => 'text-center', + ], + [ + 'id' => 'total_sold', + 'value' => $product['total'], + 'class' => 'text-center', + ], + [ + 'id' => 'sales', + 'value' => $this->context->getCurrentLocale()->formatPrice($product['sales'], $this->context->currency->iso_code), + 'class' => 'text-center', + ], + [ + 'id' => 'net_profit', + 'value' => $this->context->getCurrentLocale()->formatPrice(($product['sales'] - $product['expenses']), $this->context->currency->iso_code), + 'class' => 'text-center', + ], + ]; + } + } return ['header' => $header, 'body' => $body]; } From 6336bbef31ee263b9c7a283a9ac133e3caf1009b Mon Sep 17 00:00:00 2001 From: Dominik Shaim Ulrich Date: Fri, 22 Aug 2025 01:12:55 +0200 Subject: [PATCH 5/5] CSFIXER --- dashproducts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashproducts.php b/dashproducts.php index b009b3f..cc1d2db 100755 --- a/dashproducts.php +++ b/dashproducts.php @@ -218,7 +218,7 @@ public function getTableBestSellers($date_from, $date_to) $body = []; if (!empty($products)) { foreach ($products as $product) { - $product_obj = new Product((int)$product['product_id'], false, $this->context->language->id); + $product_obj = new Product((int) $product['product_id'], false, $this->context->language->id); if (!Validate::isLoadedObject($product_obj)) { continue; } @@ -231,7 +231,7 @@ public function getTableBestSellers($date_from, $date_to) $img = ''; if (($row_image = Product::getCover($product_obj->id)) && $row_image['id_image']) { - $image = new Image((int)$row_image['id_image']); + $image = new Image((int) $row_image['id_image']); $path_to_image = (defined('_PS_PRODUCT_IMG_DIR_') ? _PS_PRODUCT_IMG_DIR_ : _PS_PROD_IMG_DIR_) . $image->getExistingImgPath() . '.' . $this->context->controller->imageType; $img = ImageManager::thumbnail($path_to_image, 'product_mini_' . $row_image['id_image'] . '.' . $this->context->controller->imageType, 45, $this->context->controller->imageType); }