make article price adjustment scripts compatible to OXID 4.10 / 5.3
This commit is contained in:
parent
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.
|
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
|
## Ausführung
|
||||||
|
|
||||||
@ -86,13 +86,13 @@ Nutzen Sie für die Preisanpassungen die folgenden Scripte als Cronjob zum passe
|
|||||||
um die Artikelpreise zu senken::
|
um die Artikelpreise zu senken::
|
||||||
|
|
||||||
```
|
```
|
||||||
[ Shoppfad ]/vendor/bin/reduceArticlePrices
|
[ Shoppfad ]/_taxRates/bin/reduceArticlePrices
|
||||||
```
|
```
|
||||||
|
|
||||||
um die Artikelpreise zurückzusetzen:
|
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.
|
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;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
use D3\ModCfg\Application\Model\d3database;
|
require_once('genericAbstract.php');
|
||||||
use OxidEsales\Eshop\Application\Model\Shop;
|
|
||||||
use OxidEsales\Eshop\Core\Config;
|
|
||||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
|
||||||
|
|
||||||
abstract class articlePricesAbstract extends genericAbstract
|
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))'
|
'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()
|
public function run()
|
||||||
{
|
{
|
||||||
if (false === $this->isInExecutableTimeRange()) {
|
if (false === $this->isInExecutableTimeRange()) {
|
||||||
@ -62,27 +55,23 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
$this->changeArticlePrices();
|
$this->changeArticlePrices();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
|
||||||
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
|
|
||||||
*/
|
|
||||||
public function changeArticlePrices()
|
public function changeArticlePrices()
|
||||||
{
|
{
|
||||||
$shop = new Shop();
|
$shop = new \oxShop();
|
||||||
|
|
||||||
// use shop list, when parameter -d is set
|
// use shop list, when parameter -d is set
|
||||||
$opts = getopt("s:");
|
$opts = getopt("s:");
|
||||||
|
|
||||||
$where = isset($opts['s']) ?
|
$where = isset($opts['s']) ?
|
||||||
"oxid IN (".implode(', ', array_map(
|
"oxid IN (".implode(', ', array_map(
|
||||||
function ($a) {return DatabaseProvider::getDb()->quote(trim($a));},
|
function ($a) {return \oxDb::getDb()->quote(trim($a));},
|
||||||
explode(',', $opts['s']))
|
explode(',', $opts['s']))
|
||||||
).")" :
|
).")" :
|
||||||
"1";
|
"1";
|
||||||
|
|
||||||
$q = "SELECT oxid FROM " . $shop->getCoreTableName() . " WHERE ".$where ;
|
$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"];
|
$shopId = (int) $record["oxid"];
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
@ -99,7 +88,7 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
$oCurrConfig = new Config();
|
$oCurrConfig = new \oxConfig();
|
||||||
|
|
||||||
$oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT');
|
$oldTaxRate = (int) $oCurrConfig->getConfigParam('dDefaultVAT');
|
||||||
$newTaxRate = $this->rateChanges[$oldTaxRate];
|
$newTaxRate = $this->rateChanges[$oldTaxRate];
|
||||||
@ -111,7 +100,7 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->baseQueriesDefaultTax as $query) {
|
foreach ($this->baseQueriesDefaultTax as $query) {
|
||||||
$db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
|
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
||||||
|
|
||||||
$queryParameters = [
|
$queryParameters = [
|
||||||
'shopid' => $shopId,
|
'shopid' => $shopId,
|
||||||
@ -132,7 +121,7 @@ abstract class articlePricesAbstract extends genericAbstract
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
foreach ($this->baseQueriesCustomTax as $query) {
|
foreach ($this->baseQueriesCustomTax as $query) {
|
||||||
foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) {
|
foreach ($this->rateChanges as $oldTaxRate => $newTaxRate) {
|
||||||
$db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
|
$db = \oxDb::getDb(\oxDb::FETCH_MODE_ASSOC);
|
||||||
|
|
||||||
$queryParameters = [
|
$queryParameters = [
|
||||||
'shopid' => $shopId,
|
'shopid' => $shopId,
|
||||||
|
@ -15,9 +15,6 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
use OxidEsales\Eshop\Core\Config;
|
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
|
||||||
|
|
||||||
abstract class genericAbstract
|
abstract class genericAbstract
|
||||||
{
|
{
|
||||||
public $rateChanges = [
|
public $rateChanges = [
|
||||||
@ -48,18 +45,18 @@ abstract class genericAbstract
|
|||||||
*/
|
*/
|
||||||
public function switchToShop($id)
|
public function switchToShop($id)
|
||||||
{
|
{
|
||||||
if (Registry::getConfig()->isMall()
|
if (oxRegistry::getConfig()->isMall()
|
||||||
&& $id != Registry::getConfig()->getActiveShop()->getId()
|
&& $id != oxRegistry::getConfig()->getActiveShop()->getId()
|
||||||
) {
|
) {
|
||||||
/** @var Config $oNewConf */
|
/** @var oxConfig $oNewConf */
|
||||||
$oNewConf = new Config();
|
$oNewConf = new oxConfig();
|
||||||
$oNewConf->setShopId($id);
|
$oNewConf->setShopId($id);
|
||||||
$oNewConf->init();
|
$oNewConf->init();
|
||||||
|
|
||||||
Registry::getConfig()->onShopChange();
|
oxRegistry::getConfig()->onShopChange();
|
||||||
Registry::getSession()->setVariable('actshop', $id);
|
oxRegistry::getSession()->setVariable('actshop', $id);
|
||||||
Registry::getSession()->setVariable('currentadminshop', $id);
|
oxRegistry::getSession()->setVariable('currentadminshop', $id);
|
||||||
Registry::getConfig()->setShopId($id);
|
oxRegistry::getConfig()->setShopId($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
|
require_once('articlePricesAbstract.php');
|
||||||
|
require_once('raiseTrait.php');
|
||||||
|
|
||||||
class raiseArticlePrices extends articlePricesAbstract
|
class raiseArticlePrices extends articlePricesAbstract
|
||||||
{
|
{
|
||||||
use raiseTrait;
|
use raiseTrait;
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
require 'taxRateAbstract.php';
|
require_once 'taxRateAbstract.php';
|
||||||
|
require_once 'raiseTrait.php';
|
||||||
|
|
||||||
class raiseTaxRate extends taxRateAbstract
|
class raiseTaxRate extends taxRateAbstract
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
|
require_once('articlePricesAbstract.php');
|
||||||
|
require_once('reduceTrait.php');
|
||||||
|
|
||||||
class reduceArticlePrices extends articlePricesAbstract
|
class reduceArticlePrices extends articlePricesAbstract
|
||||||
{
|
{
|
||||||
use reduceTrait;
|
use reduceTrait;
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
|
|
||||||
namespace D3\TaxRatesAdjustment\Models;
|
namespace D3\TaxRatesAdjustment\Models;
|
||||||
|
|
||||||
require 'taxRateAbstract.php';
|
require_once 'taxRateAbstract.php';
|
||||||
|
require_once 'reduceTrait.php';
|
||||||
|
|
||||||
class reduceTaxRate extends taxRateAbstract
|
class reduceTaxRate extends taxRateAbstract
|
||||||
{
|
{
|
||||||
|
@ -21,12 +21,10 @@ use oxDb;
|
|||||||
use oxRegistry;
|
use oxRegistry;
|
||||||
use oxShop;
|
use oxShop;
|
||||||
|
|
||||||
|
require_once('genericAbstract.php');
|
||||||
|
|
||||||
abstract class taxRateAbstract extends genericAbstract
|
abstract class taxRateAbstract extends genericAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
|
||||||
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseErrorException
|
|
||||||
*/
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
if (false === $this->isInExecutableTimeRange()) {
|
if (false === $this->isInExecutableTimeRange()) {
|
||||||
|
@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/';
|
|||||||
$filePath = $currentDirectory . $filePath;
|
$filePath = $currentDirectory . $filePath;
|
||||||
|
|
||||||
require($filePath);
|
require($filePath);
|
||||||
|
require(__DIR__.'/../Models/raiseArticlePrices.php');
|
||||||
|
|
||||||
$change = new \D3\TaxRatesAdjustment\Models\raiseArticlePrices();
|
$change = new \D3\TaxRatesAdjustment\Models\raiseArticlePrices();
|
||||||
try {
|
try {
|
||||||
|
@ -6,6 +6,7 @@ $currentDirectory = __DIR__ . '/';
|
|||||||
$filePath = $currentDirectory . $filePath;
|
$filePath = $currentDirectory . $filePath;
|
||||||
|
|
||||||
require($filePath);
|
require($filePath);
|
||||||
|
require(__DIR__.'/../Models/reduceArticlePrices.php');
|
||||||
|
|
||||||
$change = new \D3\TaxRatesAdjustment\Models\reduceArticlePrices();
|
$change = new \D3\TaxRatesAdjustment\Models\reduceArticlePrices();
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user