make article price adjustment scripts compatible to OXID 4.10 / 5.3
Dieser Commit ist enthalten in:
Ursprung
f4d7c8ef5f
Commit
db2d8cb09a
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,9 @@
|
||||
|
||||
namespace D3\TaxRatesAdjustment\Models;
|
||||
|
||||
require_once('articlePricesAbstract.php');
|
||||
require_once('raiseTrait.php');
|
||||
|
||||
class raiseArticlePrices extends articlePricesAbstract
|
||||
{
|
||||
use raiseTrait;
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
namespace D3\TaxRatesAdjustment\Models;
|
||||
|
||||
require 'taxRateAbstract.php';
|
||||
require_once 'taxRateAbstract.php';
|
||||
require_once 'raiseTrait.php';
|
||||
|
||||
class raiseTaxRate extends taxRateAbstract
|
||||
{
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
namespace D3\TaxRatesAdjustment\Models;
|
||||
|
||||
require_once('articlePricesAbstract.php');
|
||||
require_once('reduceTrait.php');
|
||||
|
||||
class reduceArticlePrices extends articlePricesAbstract
|
||||
{
|
||||
use reduceTrait;
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
namespace D3\TaxRatesAdjustment\Models;
|
||||
|
||||
require 'taxRateAbstract.php';
|
||||
require_once 'taxRateAbstract.php';
|
||||
require_once 'reduceTrait.php';
|
||||
|
||||
class reduceTaxRate extends taxRateAbstract
|
||||
{
|
||||
|
@ -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()) {
|
||||
|
@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/';
|
||||
$filePath = $currentDirectory . $filePath;
|
||||
|
||||
require($filePath);
|
||||
require(__DIR__.'/../Models/raiseArticlePrices.php');
|
||||
|
||||
$change = new \D3\TaxRatesAdjustment\Models\raiseArticlePrices();
|
||||
try {
|
||||
|
@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/';
|
||||
$filePath = $currentDirectory . $filePath;
|
||||
|
||||
require($filePath);
|
||||
require(__DIR__.'/../Models/reduceArticlePrices.php');
|
||||
|
||||
$change = new \D3\TaxRatesAdjustment\Models\reduceArticlePrices();
|
||||
try {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren