diff --git a/README.md b/README.md index 49010e4..b9c271d 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Ein Einsatz in älteren Shopversionen ist vor dem Livebetrieb zwingend auf Verwe Kopieren Sie den Inhalt des `copy_this`-Ordners in Ihren Shopordner. Achten Sie darauf, auch die verborgene .htaccess mitzukopieren, dass die Scripte nicht über den Browser von außen erreichbar sind. -Vergeben Sie den beiden Scripten im Ordner `_taxRates/bin` Ausführungsrechte. +Vergeben Sie den Scripten im Ordner `_taxRates/bin` Ausführungsrechte. ## Ausführung @@ -86,13 +86,13 @@ Nutzen Sie für die Preisanpassungen die folgenden Scripte als Cronjob zum passe um die Artikelpreise zu senken:: ``` -[ Shoppfad ]/vendor/bin/reduceArticlePrices +[ Shoppfad ]/_taxRates/bin/reduceArticlePrices ``` um die Artikelpreise zurückzusetzen: ``` -[ Shoppfad ]/vendor/bin/raiseArtikelPrices +[ Shoppfad ]/_taxRates/bin/raiseArtikelPrices ``` Führen Sie die Preisanpassungsscripte nur ein einziges Mal aus, da die Preise sonst mehrfach gesenkt / erhöht werden. diff --git a/copy_this/_taxRates/Models/articlePricesAbstract.php b/copy_this/_taxRates/Models/articlePricesAbstract.php index a542d9a..e1dac98 100644 --- a/copy_this/_taxRates/Models/articlePricesAbstract.php +++ b/copy_this/_taxRates/Models/articlePricesAbstract.php @@ -15,10 +15,7 @@ namespace D3\TaxRatesAdjustment\Models; -use D3\ModCfg\Application\Model\d3database; -use OxidEsales\Eshop\Application\Model\Shop; -use OxidEsales\Eshop\Core\Config; -use OxidEsales\Eshop\Core\DatabaseProvider; +require_once('genericAbstract.php'); abstract class articlePricesAbstract extends genericAbstract { @@ -48,10 +45,6 @@ abstract class articlePricesAbstract extends genericAbstract 'UPDATE oxarticles SET oxvarmaxprice = (oxvarmaxprice / :oldTaxPercent * :newTaxPercent) WHERE oxshopid = :shopid AND (oxvat IN(:oldTaxRate, :newTaxRate))' ]; - /** - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException - */ public function run() { if (false === $this->isInExecutableTimeRange()) { @@ -62,27 +55,23 @@ abstract class articlePricesAbstract extends genericAbstract $this->changeArticlePrices(); } - /** - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException - */ public function changeArticlePrices() { - $shop = new Shop(); + $shop = new \oxShop(); // use shop list, when parameter -d is set $opts = getopt("s:"); $where = isset($opts['s']) ? "oxid IN (".implode(', ', array_map( - function ($a) {return DatabaseProvider::getDb()->quote(trim($a));}, + function ($a) {return \oxDb::getDb()->quote(trim($a));}, explode(',', $opts['s'])) ).")" : "1"; $q = "SELECT oxid FROM " . $shop->getCoreTableName() . " WHERE ".$where ; - foreach ( DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC )->getAll( $q ) as $record ) { + foreach ( \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC)->getAll( $q ) as $record ) { $shopId = (int) $record["oxid"]; $count = 0; @@ -99,7 +88,7 @@ abstract class articlePricesAbstract extends genericAbstract { $count = 0; - $oCurrConfig = new Config(); + $oCurrConfig = new \oxConfig(); $oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT'); $newTaxRate = $this->rateChanges[$oldTaxRate]; @@ -111,7 +100,7 @@ abstract class articlePricesAbstract extends genericAbstract } foreach ($this->baseQueriesDefaultTax as $query) { - $db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); + $db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC); $queryParameters = [ 'shopid' => $shopId, @@ -132,7 +121,7 @@ abstract class articlePricesAbstract extends genericAbstract $count = 0; foreach ($this->baseQueriesCustomTax as $query) { foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) { - $db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); + $db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC); $queryParameters = [ 'shopid' => $shopId, diff --git a/copy_this/_taxRates/Models/genericAbstract.php b/copy_this/_taxRates/Models/genericAbstract.php index 68fa284..df98c69 100644 --- a/copy_this/_taxRates/Models/genericAbstract.php +++ b/copy_this/_taxRates/Models/genericAbstract.php @@ -15,9 +15,6 @@ namespace D3\TaxRatesAdjustment\Models; -use OxidEsales\Eshop\Core\Config; -use OxidEsales\Eshop\Core\Registry; - abstract class genericAbstract { public $rateChanges = [ @@ -48,18 +45,18 @@ abstract class genericAbstract */ public function switchToShop($id) { - if (Registry::getConfig()->isMall() - && $id != Registry::getConfig()->getActiveShop()->getId() + if (oxRegistry::getConfig()->isMall() + && $id != oxRegistry::getConfig()->getActiveShop()->getId() ) { - /** @var Config $oNewConf */ - $oNewConf = new Config(); + /** @var oxConfig $oNewConf */ + $oNewConf = new oxConfig(); $oNewConf->setShopId($id); $oNewConf->init(); - Registry::getConfig()->onShopChange(); - Registry::getSession()->setVariable('actshop', $id); - Registry::getSession()->setVariable('currentadminshop', $id); - Registry::getConfig()->setShopId($id); + oxRegistry::getConfig()->onShopChange(); + oxRegistry::getSession()->setVariable('actshop', $id); + oxRegistry::getSession()->setVariable('currentadminshop', $id); + oxRegistry::getConfig()->setShopId($id); } } } \ No newline at end of file diff --git a/copy_this/_taxRates/Models/raiseArticlePrices.php b/copy_this/_taxRates/Models/raiseArticlePrices.php index d73f4a5..dd7c095 100644 --- a/copy_this/_taxRates/Models/raiseArticlePrices.php +++ b/copy_this/_taxRates/Models/raiseArticlePrices.php @@ -15,6 +15,9 @@ namespace D3\TaxRatesAdjustment\Models; +require_once('articlePricesAbstract.php'); +require_once('raiseTrait.php'); + class raiseArticlePrices extends articlePricesAbstract { use raiseTrait; diff --git a/copy_this/_taxRates/Models/raiseTaxRate.php b/copy_this/_taxRates/Models/raiseTaxRate.php index b4456d2..dbd031a 100644 --- a/copy_this/_taxRates/Models/raiseTaxRate.php +++ b/copy_this/_taxRates/Models/raiseTaxRate.php @@ -15,7 +15,8 @@ namespace D3\TaxRatesAdjustment\Models; -require 'taxRateAbstract.php'; +require_once 'taxRateAbstract.php'; +require_once 'raiseTrait.php'; class raiseTaxRate extends taxRateAbstract { diff --git a/copy_this/_taxRates/Models/reduceArticlePrices.php b/copy_this/_taxRates/Models/reduceArticlePrices.php index 019b256..89bc3bb 100644 --- a/copy_this/_taxRates/Models/reduceArticlePrices.php +++ b/copy_this/_taxRates/Models/reduceArticlePrices.php @@ -15,6 +15,9 @@ namespace D3\TaxRatesAdjustment\Models; +require_once('articlePricesAbstract.php'); +require_once('reduceTrait.php'); + class reduceArticlePrices extends articlePricesAbstract { use reduceTrait; diff --git a/copy_this/_taxRates/Models/reduceTaxRate.php b/copy_this/_taxRates/Models/reduceTaxRate.php index 63b90a9..c81a0e2 100644 --- a/copy_this/_taxRates/Models/reduceTaxRate.php +++ b/copy_this/_taxRates/Models/reduceTaxRate.php @@ -15,7 +15,8 @@ namespace D3\TaxRatesAdjustment\Models; -require 'taxRateAbstract.php'; +require_once 'taxRateAbstract.php'; +require_once 'reduceTrait.php'; class reduceTaxRate extends taxRateAbstract { diff --git a/copy_this/_taxRates/Models/taxRateAbstract.php b/copy_this/_taxRates/Models/taxRateAbstract.php index b6fe59f..04acbdb 100644 --- a/copy_this/_taxRates/Models/taxRateAbstract.php +++ b/copy_this/_taxRates/Models/taxRateAbstract.php @@ -21,12 +21,10 @@ use oxDb; use oxRegistry; use oxShop; +require_once('genericAbstract.php'); + abstract class taxRateAbstract extends genericAbstract { - /** - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException - * @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException - */ public function run() { if (false === $this->isInExecutableTimeRange()) { diff --git a/copy_this/_taxRates/bin/raiseArticlePrices b/copy_this/_taxRates/bin/raiseArticlePrices index d7fc2d8..8f260db 100644 --- a/copy_this/_taxRates/bin/raiseArticlePrices +++ b/copy_this/_taxRates/bin/raiseArticlePrices @@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/'; $filePath = $currentDirectory . $filePath; require($filePath); +require(__DIR__.'/../Models/raiseArticlePrices.php'); $change = new \D3\TaxRatesAdjustment\Models\raiseArticlePrices(); try { diff --git a/copy_this/_taxRates/bin/reduceArticlePrices b/copy_this/_taxRates/bin/reduceArticlePrices index ae4ad5d..7517a51 100644 --- a/copy_this/_taxRates/bin/reduceArticlePrices +++ b/copy_this/_taxRates/bin/reduceArticlePrices @@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/'; $filePath = $currentDirectory . $filePath; require($filePath); +require(__DIR__.'/../Models/reduceArticlePrices.php'); $change = new \D3\TaxRatesAdjustment\Models\reduceArticlePrices(); try {