move example tasks to Data Wizard tasks module

This commit is contained in:
Daniel Seifert 2021-07-27 15:15:21 +02:00
bovenliggende f2935209ed
commit 148f4f8213
Getekend door: DanielS
GPG sleutel-ID: 8A7C4C6ED1915C6F
8 gewijzigde bestanden met toevoegingen van 9 en 305 verwijderingen

Bestand weergeven

@ -1,89 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\DataWizard\Application\Model\Actions;
use D3\DataWizard\Application\Model\ActionBase;
use OxidEsales\Eshop\Core\Model\BaseModel;
use OxidEsales\Eshop\Core\Model\MultiLanguageModel;
use OxidEsales\Eshop\Core\Registry;
class FixArtextendsItems extends ActionBase
{
/**
* fehlende oxartextends-Einträge nachtragen
*/
/**
* @return string
*/
public function getTitle() : string
{
return Registry::getLang()->translateString('D3_DATAWIZARD_ACTIONS_FIXARTEXTENDSITEMS');
}
/**
* @return array
*/
public function getQuery() : array
{
$aDefaultValueFields = array(
'oxtimestamp' => "''",
);
$aNonArtExtendsFields = array(
'oxid' => 'oxarticles.oxid',
);
$aArtExtendsFields = array_fill_keys($this->getArtExtendsFields(), "''");
$aMergedFields = array_merge($aNonArtExtendsFields, $aArtExtendsFields);
$aQueryFields = array_diff_key($aMergedFields, $aDefaultValueFields);
$sArtExtendsFields = implode(', ', array_keys($aQueryFields));
$select = "SELECT ".implode(', ', $aQueryFields).
" FROM oxarticles".
" LEFT JOIN oxartextends AS arx ON oxarticles.oxid = arx.oxid".
" WHERE arx.oxid IS NULL";
$query = "INSERT INTO oxartextends ($sArtExtendsFields) ".
$select;
return [$query, []];
}
/**
* @return array
*/
public function getArtExtendsFields(): array
{
/** @var $oArtExtends MultiLanguageModel */
$oArtExtends = oxNew(BaseModel::class);
$oArtExtends->init('oxartextends', false);
$aFieldNames = $oArtExtends->getFieldNames();
if (false == $aFieldNames) {
$oArtExtends->disableLazyLoading();
$aFieldNames = $oArtExtends->getFieldNames();
}
unset($aFieldNames[array_search('oxid', $aFieldNames)]);
return $aFieldNames;
}
}

Bestand weergeven

@ -29,6 +29,7 @@ class Configuration
const GROUP_USERS = 'D3_DATAWIZARD_GROUP_USERS';
const GROUP_ORDERS = 'D3_DATAWIZARD_GROUP_ORDERS';
const GROUP_REMARKS = 'D3_DATAWIZARD_GROUP_REMARKS';
const GROUP_CMS = 'D3_DATAWIZARD_GROUP_CMS';
protected $actions = [];
protected $exports = [];
@ -40,12 +41,7 @@ class Configuration
public function configure()
{
if (false === Registry::getConfig()->getConfigParam('d3datawizard_hideexamples', false)) {
$this->registerAction(self::GROUP_ARTICLES, oxNew(FixArtextendsItems::class));
$this->registerExport(self::GROUP_CATEGORY, oxNew(InactiveCategories::class));
$this->registerExport(self::GROUP_SHOP, oxNew(KeyFigures::class));
}
// extend to add exports and actions via 'registerAction()' or 'registerExport()' method
}
/**

Bestand weergeven

@ -1,77 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\DataWizard\Application\Model\Exports;
use D3\DataWizard\Application\Model\ExportBase;
use OxidEsales\Eshop\Application\Model\Article;
use OxidEsales\Eshop\Application\Model\Category;
use OxidEsales\Eshop\Application\Model\Object2Category;
use OxidEsales\Eshop\Core\Registry;
class InactiveCategories extends ExportBase
{
/**
* Kategorien -deaktiviert, mit aktiven Artikeln
*/
/**
* @return string
*/
public function getTitle() : string
{
return Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES');
}
/**
* @return array
*/
public function getQuery() : array
{
$categoryTableName = oxNew(Category::class)->getCoreTableName();
$object2categoryTableName = oxNew(Object2Category::class)->getCoreTableName();
$articleTableName = oxNew(Article::class)->getCoreTableName();
$treeTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TREE');
$titleTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TITLE');
$countTitle = Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_COUNT');
return [
"SELECT
oc.OXID,
oc.OXSHOPID,
oc.oxtitle as :titleTitle,
(
SELECT GROUP_CONCAT(oxtitle ORDER BY oxleft ASC SEPARATOR ' > ')
from ".$categoryTableName."
WHERE OXLEFT < oc.oxleft AND OXRIGHT > oc.oxright AND OXROOTID = oc.OXROOTID AND OXSHOPID = oc.OXSHOPID
) as :treeTitle,
COUNT(oa.oxid) as :countTitle
FROM ".$categoryTableName." oc
LEFT JOIN ".$object2categoryTableName." o2c ON oc.OXID = o2c.OXCATNID
LEFT JOIN ".$articleTableName." oa ON o2c.OXOBJECTID = oa.OXID
WHERE oc.OXACTIVE = :categoryActive AND oa.OXACTIVE = :articleActive
GROUP BY oc.oxid
ORDER BY oc.oxleft ASC",
[
'categoryActive' => 0,
'articleActive' => 1,
'titleTitle' => $titleTitle,
'treeTitle' => $treeTitle,
'countTitle' => $countTitle
]
];
}
}

Bestand weergeven

@ -1,98 +0,0 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\DataWizard\Application\Model\Exports;
use D3\DataWizard\Application\Model\ExportBase;
use FormManager\Inputs\Date;
use OxidEsales\Eshop\Application\Model\Order;
use OxidEsales\Eshop\Core\Registry;
use FormManager\Factory as FormFactory;
class KeyFigures extends ExportBase
{
const STARTDATE_NAME = 'startdate';
const ENDDATE_NAME = 'enddate';
/**
* Shopkennzahlen
*/
public function __construct()
{
/** @var Date $startDate */
$startDateValue = Registry::getRequest()->getRequestEscapedParameter(self::STARTDATE_NAME);
$startDate = FormFactory::date(
Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_STARTDATE'),
[
'name' => self::STARTDATE_NAME,
'value' => $startDateValue
]
);
$this->registerFormElement($startDate);
/** @var Date $endDate */
$endDateValue = Registry::getRequest()->getRequestEscapedParameter(self::ENDDATE_NAME);
$endDate = FormFactory::date(
Registry::getLang()->translateString('D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_ENDDATE'),
[
'name' => self::ENDDATE_NAME,
'value' => $endDateValue
]
);
$this->registerFormElement($endDate);
}
/**
* @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');
$startDateValue = Registry::getRequest()->getRequestEscapedParameter(self::STARTDATE_NAME) ?: '1970-01-01';
$endDateValue = Registry::getRequest()->getRequestEscapedParameter(self::ENDDATE_NAME) ?: date('Y-m-d');
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
WHERE oo.oxorderdate >= :startDate AND oo.oxorderdate <= :endDate
GROUP BY DATE_FORMAT(oo.oxorderdate, "%Y-%m")
ORDER BY DATE_FORMAT(oo.oxorderdate, "%Y-%m") DESC
LIMIT 30',
[
'startDate' => $startDateValue,
'endDate' => $endDateValue,
'monthTitle' => $monthTitle,
'ordersTitle' => $ordersTitle,
'basketsTitle' => $basketsTitle
]
];
}
}

Bestand weergeven

@ -27,13 +27,13 @@ $aLang = array(
'SHOP_MODULE_GROUP_d3datawizard_general' => 'Grundeinstellungen',
'SHOP_MODULE_d3datawizard_debug' => 'zeigt Abfragen anstatt diese auszuführen',
'SHOP_MODULE_d3datawizard_hideexamples' => 'Beispielexporte ausblenden',
'D3_DATAWIZARD_GROUP_ARTICLES' => 'Artikel',
'D3_DATAWIZARD_GROUP_CATEGORIES' => 'Kategorien',
'D3_DATAWIZARD_GROUP_ORDERS' => 'Bestellungen',
'D3_DATAWIZARD_GROUP_REMARKS' => 'Bewertungen',
'D3_DATAWIZARD_GROUP_SHOP' => 'Shop',
'D3_DATAWIZARD_GROUP_CMS' => 'CMS-Texte',
'D3_DATAWIZARD_GROUP_USERS' => 'Benutzer',
'D3_DATAWIZARD_EXPORT_SUBMIT' => 'Export starten',
@ -50,21 +50,8 @@ $aLang = array(
'D3_DATAWIZARD_ERR_NOSUITABLERENDERER' => 'kein Renderer für Format "%1$s" registriert',
'D3_DATAWIZARD_ERR_EXPORTFILEERROR' => 'Exportdatei "%1$s" kann nicht angelegt werden',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES' => 'deaktivierte Kategorien, mit aktiven Artikeln',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TREE' => 'Baum',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TITLE' => 'Titel',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_COUNT' => 'Anzahl',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES' => 'Bestellungskennzahlen nach Monat',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_STARTDATE'=> 'Startdatum (optional)',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_ENDDATE' => 'Enddatum (optional)',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_ORDERSPERMONTH' => 'Bestellungen pro Monat',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_BASKETSIZE' => 'Warenkorbhöhe',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_MONTH' => 'Monat',
'D3_DATAWIZARD_ERR_ACTIONSELECT' => 'Aktion kann nicht ausgeführt werden. Aktionen können keine SELECTs exportieren.',
'D3_DATAWIZARD_ERR_NOACTION_INSTALLED' => 'Es sind keine Aktionen installiert oder aktiviert.',
'D3_DATAWIZARD_ERR_ACTIONRESULT' => '%1$s Eintrag verändert',
'D3_DATAWIZARD_ERR_ACTIONRESULTS' => '%1$s Einträge verändert',
'D3_DATAWIZARD_ACTIONS_FIXARTEXTENDSITEMS' => 'fehlende oxartextends-Einträge nachtragen',
);

Bestand weergeven

@ -27,13 +27,13 @@ $aLang = array(
'SHOP_MODULE_GROUP_d3datawizard_general' => 'basic settings',
'SHOP_MODULE_d3datawizard_debug' => 'shows queries instead of executing them',
'SHOP_MODULE_d3datawizard_hideexamples' => 'hide sample exports',
'D3_DATAWIZARD_GROUP_ARTICLES' => 'articles',
'D3_DATAWIZARD_GROUP_CATEGORIES' => 'categories',
'D3_DATAWIZARD_GROUP_ORDERS' => 'orders',
'D3_DATAWIZARD_GROUP_REMARKS' => 'remarks',
'D3_DATAWIZARD_GROUP_SHOP' => 'shop',
'D3_DATAWIZARD_GROUP_CMS' => 'CMS items',
'D3_DATAWIZARD_GROUP_USERS' => 'users',
'D3_DATAWIZARD_EXPORT_SUBMIT' => 'generate export',
@ -50,21 +50,8 @@ $aLang = array(
'D3_DATAWIZARD_ERR_NOSUITABLERENDERER' => 'No renderer registered for format "%1$s"',
'D3_DATAWIZARD_ERR_EXPORTFILEERROR' => 'Export file "%1$s" cannot be created',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES' => 'deactivated categories, with active articles',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TREE' => 'tree',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_TITLE' => 'title',
'D3_DATAWIZARD_EXPORTS_INACTIVECATEGORIES_COUNT' => 'count',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES' => 'Order key figures by month',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_STARTDATE'=> 'start date (optional)',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_FIELD_ENDDATE' => 'end date (optional)',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_ORDERSPERMONTH' => 'orders per month',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_BASKETSIZE' => 'shopping cart value',
'D3_DATAWIZARD_EXPORTS_KEYFIGURES_MONTH' => 'month',
'D3_DATAWIZARD_ERR_ACTIONSELECT' => 'Action cannot be executed. Actions cannot export SELECTs.',
'D3_DATAWIZARD_ERR_NOACTION_INSTALLED' => 'No actions are installed or activated.',
'D3_DATAWIZARD_ERR_ACTIONRESULT' => '%1$s entry changed',
'D3_DATAWIZARD_ERR_ACTIONRESULTS' => '%1$s entries changed',
'D3_DATAWIZARD_ACTIONS_FIXARTEXTENDSITEMS' => 'add missing oxartextends entries',
);

Bestand weergeven

@ -40,6 +40,10 @@
"target-directory": "d3/datawizard"
}
},
"suggest": {
"d3/datawizardtasks": "useful example tasks for Data Wizard",
"d3/datawizardcli": "command line implementation for fully automated Data Wizard tasks"
},
"autoload": {
"psr-4": {
"D3\\DataWizard\\": "../../../source/modules/d3/datawizard"

Bestand weergeven

@ -52,13 +52,7 @@ $aModule = [
'name' => $sModuleId.'_debug',
'type' => 'bool',
'value' => false
],
[
'group' => $sModuleId.'_general',
'name' => $sModuleId.'_hideexamples',
'type' => 'bool',
'value' => false
],
]
],
'blocks' => []
];