DataWizard/Application/Model/Exports/InactiveCategories.php

77 lines
2.8 KiB
PHP
Raw Normal View History

2021-04-27 23:40:54 +02:00
<?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;
2021-04-27 23:40:54 +02:00
use OxidEsales\Eshop\Core\Registry;
class InactiveCategories extends ExportBase
{
/**
2021-07-14 12:23:19 +02:00
* Kategorien -deaktiviert, mit aktiven Artikeln
2021-04-27 23:40:54 +02:00
*/
/**
* @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');
2021-04-27 23:40:54 +02:00
return [
"SELECT
oc.OXID,
oc.OXSHOPID,
oc.oxtitle as :titleTitle,
2021-04-27 23:40:54 +02:00
(
SELECT GROUP_CONCAT(oxtitle ORDER BY oxleft ASC SEPARATOR ' > ')
from ".$categoryTableName."
2021-04-27 23:40:54 +02:00
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
2021-04-27 23:40:54 +02:00
GROUP BY oc.oxid
ORDER BY oc.oxleft ASC",
[
'categoryActive' => 0,
'articleActive' => 1,
'titleTitle' => $titleTitle,
'treeTitle' => $treeTitle,
'countTitle' => $countTitle
]
2021-04-27 23:40:54 +02:00
];
}
}