mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Compare commits
7 Commits
5a2d144ad7
...
c3d60a48fd
Author | SHA1 | Date | |
---|---|---|---|
|
c3d60a48fd | ||
|
37ed5ba246 | ||
|
10c077006d | ||
|
d39f9bb2fe | ||
|
85c699f5ee | ||
|
9eb958a1a6 | ||
|
6feaa03b8e |
@ -129,6 +129,8 @@ final class Shopware6Client
|
||||
],
|
||||
],
|
||||
];
|
||||
if ($priceData->getEndingQuantity() > 0)
|
||||
$data['quantityEnd'] = $priceData->getEndingQuantity();
|
||||
|
||||
return $this->request(
|
||||
'POST',
|
||||
|
@ -8,6 +8,8 @@ class PriceData
|
||||
{
|
||||
/** @var int */
|
||||
protected $startingQuantity;
|
||||
/** @var int|null */
|
||||
protected $endingQuantity;
|
||||
/** @var float */
|
||||
protected $net;
|
||||
/** @var float */
|
||||
@ -26,13 +28,14 @@ class PriceData
|
||||
* @param $currency
|
||||
* @param $groupName
|
||||
*/
|
||||
public function __construct(int $startingQuantity, float $net, float $gross, string $currency, string $groupName)
|
||||
public function __construct(int $startingQuantity, float $net, float $gross, string $currency, string $groupName, int $endingQuantity = null)
|
||||
{
|
||||
$this->startingQuantity = $startingQuantity;
|
||||
$this->net = $net;
|
||||
$this->gross = $gross;
|
||||
$this->currency = $currency;
|
||||
$this->groupName = $groupName;
|
||||
$this->endingQuantity = $endingQuantity;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,6 +98,25 @@ class PriceData
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getEndingQuantity(): int|null
|
||||
{
|
||||
return $this->endingQuantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $endingQuantity
|
||||
* @return PriceData
|
||||
*/
|
||||
public function setEndingQuantity(int $endingQuantity): PriceData
|
||||
{
|
||||
$this->endingQuantity = $endingQuantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
|
@ -119,6 +119,12 @@ if (php_sapi_name() == "cli") {
|
||||
$strict_db = false;
|
||||
}
|
||||
|
||||
if (in_array('-drop_keys', $argv)) {
|
||||
$drop_keys = true;
|
||||
} else {
|
||||
$drop_keys = false;
|
||||
}
|
||||
|
||||
if (in_array('-do', $argv)) {
|
||||
if (!$check_git && !$check_db) {
|
||||
$do_git = true;
|
||||
@ -143,7 +149,8 @@ if (php_sapi_name() == "cli") {
|
||||
do_db: $do_db,
|
||||
force: $force,
|
||||
connection: $connection,
|
||||
origin: $origin);
|
||||
origin: $origin,
|
||||
drop_keys: $drop_keys);
|
||||
} else {
|
||||
info();
|
||||
}
|
||||
@ -155,7 +162,7 @@ if (php_sapi_name() == "cli") {
|
||||
}
|
||||
// -------------------------------- END
|
||||
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $strict_db, bool $do_db, bool $force, bool $connection, bool $origin) {
|
||||
function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do_git, bool $export_db, bool $check_db, bool $strict_db, bool $do_db, bool $force, bool $connection, bool $origin, bool $drop_keys) {
|
||||
|
||||
$mainfolder = dirname($directory);
|
||||
$datafolder = $directory."/data";
|
||||
@ -395,7 +402,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
|
||||
echo_out("--------------- Calculating database upgrade for '$schema@$host'... ---------------\n");
|
||||
|
||||
$upgrade_sql = array();
|
||||
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers, $strict_db);
|
||||
$result = mustal_calculate_db_upgrade($compare_def, $db_def, $upgrade_sql, $mustal_replacers, $strict_db, $drop_keys);
|
||||
|
||||
if (!empty($result)) {
|
||||
abort(count($result)." errors.\n");
|
||||
@ -411,7 +418,7 @@ function upgrade_main(string $directory,bool $verbose, bool $check_git, bool $do
|
||||
foreach($upgrade_sql as $statement) {
|
||||
echo_out($statement."\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo_out(count($upgrade_sql)." upgrade statements\n");
|
||||
|
||||
|
17
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
17
vendor/mustal/mustal_mysql_upgrade_tool.php
vendored
@ -21,7 +21,7 @@ function mustal_compare_table_array(array $nominal, string $nominal_name, array
|
||||
Compare two database structures
|
||||
Returns a structured array containing information on all the differences.
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, bool $strict) : int
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers, bool $strict, bool $drop_keys) : array
|
||||
Generate the SQL needed to upgrade the database to match the definition, based on a comparison.
|
||||
|
||||
Data structure in Array and JSON
|
||||
@ -542,11 +542,22 @@ function mustal_implode_with_quote(string $quote, string $delimiter, array $arra
|
||||
// 11 Table type upgrade not supported
|
||||
// 12 Upgrade type not supported
|
||||
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers, bool $strict) : array {
|
||||
function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$upgrade_sql, array $replacers, bool $strict, bool $drop_keys) : array {
|
||||
|
||||
$result = array();
|
||||
$upgrade_sql = array();
|
||||
|
||||
if ($drop_keys) {
|
||||
foreach ($db_def['tables'] as $table_id => $table) {
|
||||
foreach ($table['keys'] as $key_id => $key) {
|
||||
if ($key['Key_name'] != 'PRIMARY') {
|
||||
$upgrade_sql[] = "ALTER TABLE `".$table['name']. "` DROP KEY `".$key['Key_name']."`;";
|
||||
unset($db_def['tables'][$table_id]['keys'][$key_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$compare_differences = mustal_compare_table_array($compare_def,"in JSON",$db_def,"in DB",true,true);
|
||||
|
||||
foreach ($compare_differences as $compare_difference) {
|
||||
@ -749,7 +760,7 @@ function mustal_calculate_db_upgrade(array $compare_def, array $db_def, array &$
|
||||
}
|
||||
}
|
||||
|
||||
$upgrade_sql = array_unique($upgrade_sql);
|
||||
$upgrade_sql = array_unique($upgrade_sql);
|
||||
|
||||
if (count($upgrade_sql) > 0) {
|
||||
array_unshift($upgrade_sql,"SET SQL_MODE='ALLOW_INVALID_DATES';");
|
||||
|
@ -1892,7 +1892,7 @@ class Remote
|
||||
'altersfreigabe' => $eigenschaft['altersfreigabe'], 'ean' => $eigenschaft['ean'],
|
||||
'lag' => $matrixStock,
|
||||
'pseudolager' => $matrixPseudoStorage, 'pseudopreis' => $eigenschaft['pseudopreis'],
|
||||
'restmenge' => $eigenschaft['restmenge'], 'steuersatz' => ($steuer - 1) * 100,
|
||||
'restmenge' => $eigenschaft['restmenge'], 'steuersatz' => ($steuer - 1) * 100, 'umsatzsteuer' => $eigenschaft['umsatzsteuer'],
|
||||
'bruttopreis' => $eigenschaft['preis'] * $steuer, 'inaktiv' => $eigenschaft['inaktiv'],
|
||||
'name_de' => $eigenschaft['name_de'], 'name_en' => $eigenschaft['name_en'],
|
||||
'uebersicht_de' => $eigenschaft['uebersicht_de'], 'uebersicht_en' => $eigenschaft['uebersicht_en']);
|
||||
|
@ -38,6 +38,9 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
public $propertyOption;
|
||||
public $shopwareDefaultSalesChannel;
|
||||
public $shopwareMediaFolder;
|
||||
|
||||
private $normalTaxId;
|
||||
private $reducedTaxId;
|
||||
public $protocol;
|
||||
|
||||
/** @var bool */
|
||||
@ -586,6 +589,8 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
$this->propertyOption = $einstellungen['felder']['shopwarePropertyOption'];
|
||||
$this->shopwareDefaultSalesChannel = $einstellungen['felder']['shopwareDefaultSalesChannel'];
|
||||
$this->shopwareMediaFolder = $einstellungen['felder']['shopwareMediaFolder'];
|
||||
$this->normalTaxId = $einstellungen['felder']['normalTaxId'];
|
||||
$this->reducedTaxId = $einstellungen['felder']['reducedTaxId'];
|
||||
$query = sprintf('SELECT `steuerfreilieferlandexport` FROM `shopexport` WHERE `id` = %d', $this->shopid);
|
||||
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
|
||||
|
||||
@ -669,6 +674,16 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
'size' => 40,
|
||||
'default' => 'Product Media'
|
||||
],
|
||||
'normalTaxId' => [
|
||||
'typ' => 'text',
|
||||
'bezeichnung' => '{|TaxId für Steuersatz "normal"|}',
|
||||
'size' => 40,
|
||||
],
|
||||
'reducedTaxId' => [
|
||||
'typ' => 'text',
|
||||
'bezeichnung' => '{|TaxId für Steuersatz "ermäßigt"|}',
|
||||
'size' => 40,
|
||||
],
|
||||
'statesToFetch' => [
|
||||
'typ' => 'text',
|
||||
'bezeichnung' => '{|Abzuholender Bestellstatus|}:',
|
||||
@ -927,7 +942,12 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
$quantity = $this->getCorrectedStockFromAvailable($active, (int)$quantity, $articleInfo);
|
||||
$taxRate = (float)$article['steuersatz'];
|
||||
|
||||
$taxId = $this->getTaxIdByRate($taxRate);
|
||||
if (!empty($this->normalTaxId) && $article['umsatzsteuer'] == 'normal')
|
||||
$taxId = $this->normalTaxId;
|
||||
else if (!empty($this->reducedTaxId) && $article['umsatzsteuer'] == 'ermaessigt')
|
||||
$taxId = $this->reducedTaxId;
|
||||
else
|
||||
$taxId = $this->getTaxIdByRate($taxRate);
|
||||
|
||||
$mediaToAdd = $this->mediaToExport($article, $articleIdShopware);
|
||||
|
||||
@ -1352,8 +1372,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
*/
|
||||
protected function mediaToExport($internalArticleData, $articleIdShopware)
|
||||
{
|
||||
$mediaToAdd = [
|
||||
];
|
||||
$mediaToAdd = [];
|
||||
|
||||
if (empty($internalArticleData['Dateien'])) {
|
||||
return $mediaToAdd;
|
||||
@ -1826,7 +1845,6 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
protected function createPropertyOption($propertyGroupId, $propertyOptionName): ?string
|
||||
{
|
||||
$propertyOptionData = [
|
||||
'id' => '',
|
||||
'name' => $propertyOptionName
|
||||
];
|
||||
$createdPropertyOption = $this->shopwareRequest(
|
||||
@ -1881,13 +1899,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
if (empty($countryIsoToPropertyTranslation['DE'])) {
|
||||
continue;
|
||||
}
|
||||
$propertyGroupId = '';
|
||||
if (array_key_exists($propertyDefaultName, $this->knownPropertyGroupIds)) {
|
||||
$propertyGroupId = $this->knownPropertyGroupIds[$propertyDefaultName];
|
||||
}
|
||||
if (empty($propertyGroupId)) {
|
||||
$propertyGroupId = $this->getPropertyGroupId($propertyDefaultName);
|
||||
}
|
||||
$propertyGroupId = $this->getPropertyGroupId($propertyDefaultName);
|
||||
if (empty($propertyGroupId)) {
|
||||
$propertyGroupId = $this->createPropertyGroup($propertyDefaultName);
|
||||
}
|
||||
@ -2664,15 +2676,10 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
if (empty($article['matrix_varianten']) || empty($articleIdShopware)) {
|
||||
return false;
|
||||
}
|
||||
$headerInformation = ['sw-language-id: ' . $languageId];
|
||||
$internalGroupPropertiesToShopwareId = [];
|
||||
foreach ($article['matrix_varianten']['gruppen'] as $propertyGroupName => $internalPropertyGroupValues) {
|
||||
$propertyGroupId = '';
|
||||
if (array_key_exists($propertyGroupName, $this->knownPropertyGroupIds)) {
|
||||
$propertyGroupId = $this->knownPropertyGroupIds[$propertyGroupName];
|
||||
}
|
||||
if (empty($propertyGroupId)) {
|
||||
$propertyGroupId = $this->getPropertyGroupId($propertyGroupName);
|
||||
}
|
||||
$propertyGroupId = $this->getPropertyGroupId($propertyGroupName);
|
||||
if (empty($propertyGroupId)) {
|
||||
$propertyGroupId = $this->createPropertyGroup($propertyGroupName);
|
||||
}
|
||||
@ -2693,8 +2700,6 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
}
|
||||
}
|
||||
|
||||
$languageId = $this->getLanguageIdByCountryIso('DE');
|
||||
$headerInformation = ['sw-language-id: ' . $languageId];
|
||||
$shopwarePropertyGroupOptions = $this->shopwareRequest(
|
||||
'GET',
|
||||
'property-group/' . $propertyGroupId . '/options?limit=100',
|
||||
@ -2705,7 +2710,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
}
|
||||
|
||||
foreach ($internalPropertyGroupValues as $internalPropertyGroupValue => $valueNotNeeded) {
|
||||
if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName])) {
|
||||
if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName] ?? [])) {
|
||||
$newOptionData = [
|
||||
'name' => (string)$internalPropertyGroupValue
|
||||
];
|
||||
@ -2778,6 +2783,13 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
$isCloseOut = true;
|
||||
}
|
||||
|
||||
if ($variant['umsatzsteuer'] == 'normal' && !empty($this->normalTaxId))
|
||||
$taxId = $this->normalTaxId;
|
||||
else if ($variant['umsatzsteuer'] == 'ermaessigt' && !empty($this->reducedTaxId))
|
||||
$taxId = $this->reducedTaxId;
|
||||
else
|
||||
$taxId = $this->getTaxIdByRate($variant['steuersatz']);
|
||||
|
||||
$variantProductData = [
|
||||
'active' => $active,
|
||||
'isCloseout' => $isCloseOut,
|
||||
@ -2800,7 +2812,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
],
|
||||
'stock' => (int)$stock,
|
||||
'ean' => null,
|
||||
'taxId' => $this->getTaxIdByRate($variant['steuersatz']),
|
||||
'taxId' => $taxId,
|
||||
];
|
||||
if(!empty($weight)){
|
||||
$variantProductData['weight'] = $weight;
|
||||
@ -2817,7 +2829,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
foreach ($internalVariantMatrixData as $expression) {
|
||||
if (!in_array(
|
||||
$internalGroupPropertiesToShopwareId[$expression['name']][$expression['values']],
|
||||
$existingCombinationsByNumber[$productNumber]['options'],
|
||||
$existingCombinationsByNumber[$productNumber]['options'] ?? [],
|
||||
false)) {
|
||||
$renewVariant = true;
|
||||
} else {
|
||||
@ -2960,14 +2972,21 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
* @return PriceData[]
|
||||
*/
|
||||
protected function getPricesFromArray($priceArray): array{
|
||||
return array_map(static function($price){
|
||||
return new PriceData(
|
||||
(int)$price['ab_menge'],
|
||||
(float)$price['preis'],
|
||||
(float)$price['bruttopreis'],
|
||||
$price['waehrung'],
|
||||
$price['gruppeextern'] ?? '') ;
|
||||
},$priceArray);
|
||||
$c = count($priceArray);
|
||||
$result = [];
|
||||
for ($i = 0; $i < $c; $i++) {
|
||||
$end = null;
|
||||
if ($i+1 < $c && ($priceArray[$i+1]['gruppeextern'] ?? '') == ($priceArray[$i]['gruppeextern'] ?? ''))
|
||||
$end = (int)$priceArray[$i+1]['ab_menge'] - 1;
|
||||
$result[] = new PriceData(
|
||||
(int)$priceArray[$i]['ab_menge'],
|
||||
(float)$priceArray[$i]['preis'],
|
||||
(float)$priceArray[$i]['bruttopreis'],
|
||||
$priceArray[$i]['waehrung'],
|
||||
$priceArray[$i]['gruppeextern'] ?? '',
|
||||
$end);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,8 @@ class upgrade {
|
||||
do_db: false,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
origin: false,
|
||||
drop_keys: false
|
||||
);
|
||||
break;
|
||||
case 'do_upgrade':
|
||||
@ -72,7 +73,8 @@ class upgrade {
|
||||
do_db: true,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
origin: false,
|
||||
drop_keys: false
|
||||
);
|
||||
break;
|
||||
case 'check_db':
|
||||
@ -88,7 +90,8 @@ class upgrade {
|
||||
do_db: false,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
origin: false,
|
||||
drop_keys: false
|
||||
);
|
||||
break;
|
||||
case 'do_db_upgrade':
|
||||
@ -104,7 +107,8 @@ class upgrade {
|
||||
do_db: true,
|
||||
force: $force,
|
||||
connection: false,
|
||||
origin: false
|
||||
origin: false,
|
||||
drop_keys: false
|
||||
);
|
||||
break;
|
||||
case 'refresh':
|
||||
|
Loading…
Reference in New Issue
Block a user