From e88dd1624cdeb5f59f361af76663e453f785542f Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Wed, 28 Apr 2021 13:40:04 +0200 Subject: [PATCH] add key figures example export --- src/Application/Model/Configuration.php | 2 + src/Application/Model/Exports/KeyFigures.php | 62 ++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/Application/Model/Exports/KeyFigures.php diff --git a/src/Application/Model/Configuration.php b/src/Application/Model/Configuration.php index 380ad91..a0a210b 100644 --- a/src/Application/Model/Configuration.php +++ b/src/Application/Model/Configuration.php @@ -21,6 +21,7 @@ use OxidEsales\Eshop\Core\Registry; class Configuration { + const GROUP_SHOP = 'D3_DATAWIZARD_GROUP_SHOP'; const GROUP_CATEGORY = 'D3_DATAWIZARD_GROUP_CATEGORIES'; const GROUP_ARTICLES = 'D3_DATAWIZARD_GROUP_ARTICLES'; const GROUP_USERS = 'D3_DATAWIZARD_GROUP_USERS'; @@ -38,6 +39,7 @@ class Configuration { if (false === Registry::getConfig()->getConfigParam('d3datawizard_hideexamples', false)) { $this->registerExport(self::GROUP_CATEGORY, oxNew(InactiveCategories::class)); + $this->registerExport(self::GROUP_SHOP, oxNew(KeyFigures::class)); } } diff --git a/src/Application/Model/Exports/KeyFigures.php b/src/Application/Model/Exports/KeyFigures.php new file mode 100644 index 0000000..831b66e --- /dev/null +++ b/src/Application/Model/Exports/KeyFigures.php @@ -0,0 +1,62 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\DataWizard\Application\Model\Exports; + +use D3\DataWizard\Application\Model\ExportBase; +use OxidEsales\Eshop\Application\Model\Order; +use OxidEsales\Eshop\Core\Registry; + +class KeyFigures extends ExportBase +{ + /** + * Shopkennzahlen + */ + + /** + * @return string + */ + public function getTitle() : string + { + return Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES'); + } + + /** + * @return array + */ + public function getQuery() : array + { + $orderTable = oxNew(Order::class)->getCoreTableName(); + $ordersTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_ORDERSPERMONTH'); + $basketsTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_BASKETSIZE'); + $monthTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_MONTH'); + + return [ + 'SELECT + DATE_FORMAT(oo.oxorderdate, "%Y-%m") as :monthTitle, + FORMAT(COUNT(oo.oxid), 0) AS :ordersTitle, + FORMAT(SUM(oo.OXTOTALBRUTSUM / oo.oxcurrate) / COUNT(oo.oxid), 2) as :basketsTitle + FROM '.$orderTable.' AS oo + GROUP BY :monthTitle + ORDER BY :monthTitle DESC + LIMIT 30', + [ + 'monthTitle' => $monthTitle, + 'ordersTitle' => $ordersTitle, + 'basketsTitle' => $basketsTitle + ] + ]; + } +} \ No newline at end of file