mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 12:07:15 +01:00
Merge pull request #130 from exciler/shopware6_improvements
Shopware6 improvements
This commit is contained in:
commit
37ed5ba246
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user