mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +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(
|
return $this->request(
|
||||||
'POST',
|
'POST',
|
||||||
|
@ -8,6 +8,8 @@ class PriceData
|
|||||||
{
|
{
|
||||||
/** @var int */
|
/** @var int */
|
||||||
protected $startingQuantity;
|
protected $startingQuantity;
|
||||||
|
/** @var int|null */
|
||||||
|
protected $endingQuantity;
|
||||||
/** @var float */
|
/** @var float */
|
||||||
protected $net;
|
protected $net;
|
||||||
/** @var float */
|
/** @var float */
|
||||||
@ -26,13 +28,14 @@ class PriceData
|
|||||||
* @param $currency
|
* @param $currency
|
||||||
* @param $groupName
|
* @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->startingQuantity = $startingQuantity;
|
||||||
$this->net = $net;
|
$this->net = $net;
|
||||||
$this->gross = $gross;
|
$this->gross = $gross;
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->groupName = $groupName;
|
$this->groupName = $groupName;
|
||||||
|
$this->endingQuantity = $endingQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,6 +98,25 @@ class PriceData
|
|||||||
return $this;
|
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
|
* @return float
|
||||||
*/
|
*/
|
||||||
|
@ -1892,7 +1892,7 @@ class Remote
|
|||||||
'altersfreigabe' => $eigenschaft['altersfreigabe'], 'ean' => $eigenschaft['ean'],
|
'altersfreigabe' => $eigenschaft['altersfreigabe'], 'ean' => $eigenschaft['ean'],
|
||||||
'lag' => $matrixStock,
|
'lag' => $matrixStock,
|
||||||
'pseudolager' => $matrixPseudoStorage, 'pseudopreis' => $eigenschaft['pseudopreis'],
|
'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'],
|
'bruttopreis' => $eigenschaft['preis'] * $steuer, 'inaktiv' => $eigenschaft['inaktiv'],
|
||||||
'name_de' => $eigenschaft['name_de'], 'name_en' => $eigenschaft['name_en'],
|
'name_de' => $eigenschaft['name_de'], 'name_en' => $eigenschaft['name_en'],
|
||||||
'uebersicht_de' => $eigenschaft['uebersicht_de'], 'uebersicht_en' => $eigenschaft['uebersicht_en']);
|
'uebersicht_de' => $eigenschaft['uebersicht_de'], 'uebersicht_en' => $eigenschaft['uebersicht_en']);
|
||||||
|
@ -38,6 +38,9 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
public $propertyOption;
|
public $propertyOption;
|
||||||
public $shopwareDefaultSalesChannel;
|
public $shopwareDefaultSalesChannel;
|
||||||
public $shopwareMediaFolder;
|
public $shopwareMediaFolder;
|
||||||
|
|
||||||
|
private $normalTaxId;
|
||||||
|
private $reducedTaxId;
|
||||||
public $protocol;
|
public $protocol;
|
||||||
|
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
@ -586,6 +589,8 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
$this->propertyOption = $einstellungen['felder']['shopwarePropertyOption'];
|
$this->propertyOption = $einstellungen['felder']['shopwarePropertyOption'];
|
||||||
$this->shopwareDefaultSalesChannel = $einstellungen['felder']['shopwareDefaultSalesChannel'];
|
$this->shopwareDefaultSalesChannel = $einstellungen['felder']['shopwareDefaultSalesChannel'];
|
||||||
$this->shopwareMediaFolder = $einstellungen['felder']['shopwareMediaFolder'];
|
$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);
|
$query = sprintf('SELECT `steuerfreilieferlandexport` FROM `shopexport` WHERE `id` = %d', $this->shopid);
|
||||||
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
|
$this->taxationByDestinationCountry = !empty($this->app->DB->Select($query));
|
||||||
|
|
||||||
@ -669,6 +674,16 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
'size' => 40,
|
'size' => 40,
|
||||||
'default' => 'Product Media'
|
'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' => [
|
'statesToFetch' => [
|
||||||
'typ' => 'text',
|
'typ' => 'text',
|
||||||
'bezeichnung' => '{|Abzuholender Bestellstatus|}:',
|
'bezeichnung' => '{|Abzuholender Bestellstatus|}:',
|
||||||
@ -927,7 +942,12 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
$quantity = $this->getCorrectedStockFromAvailable($active, (int)$quantity, $articleInfo);
|
$quantity = $this->getCorrectedStockFromAvailable($active, (int)$quantity, $articleInfo);
|
||||||
$taxRate = (float)$article['steuersatz'];
|
$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);
|
$mediaToAdd = $this->mediaToExport($article, $articleIdShopware);
|
||||||
|
|
||||||
@ -1352,8 +1372,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
*/
|
*/
|
||||||
protected function mediaToExport($internalArticleData, $articleIdShopware)
|
protected function mediaToExport($internalArticleData, $articleIdShopware)
|
||||||
{
|
{
|
||||||
$mediaToAdd = [
|
$mediaToAdd = [];
|
||||||
];
|
|
||||||
|
|
||||||
if (empty($internalArticleData['Dateien'])) {
|
if (empty($internalArticleData['Dateien'])) {
|
||||||
return $mediaToAdd;
|
return $mediaToAdd;
|
||||||
@ -1826,7 +1845,6 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
protected function createPropertyOption($propertyGroupId, $propertyOptionName): ?string
|
protected function createPropertyOption($propertyGroupId, $propertyOptionName): ?string
|
||||||
{
|
{
|
||||||
$propertyOptionData = [
|
$propertyOptionData = [
|
||||||
'id' => '',
|
|
||||||
'name' => $propertyOptionName
|
'name' => $propertyOptionName
|
||||||
];
|
];
|
||||||
$createdPropertyOption = $this->shopwareRequest(
|
$createdPropertyOption = $this->shopwareRequest(
|
||||||
@ -1881,13 +1899,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
if (empty($countryIsoToPropertyTranslation['DE'])) {
|
if (empty($countryIsoToPropertyTranslation['DE'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$propertyGroupId = '';
|
$propertyGroupId = $this->getPropertyGroupId($propertyDefaultName);
|
||||||
if (array_key_exists($propertyDefaultName, $this->knownPropertyGroupIds)) {
|
|
||||||
$propertyGroupId = $this->knownPropertyGroupIds[$propertyDefaultName];
|
|
||||||
}
|
|
||||||
if (empty($propertyGroupId)) {
|
|
||||||
$propertyGroupId = $this->getPropertyGroupId($propertyDefaultName);
|
|
||||||
}
|
|
||||||
if (empty($propertyGroupId)) {
|
if (empty($propertyGroupId)) {
|
||||||
$propertyGroupId = $this->createPropertyGroup($propertyDefaultName);
|
$propertyGroupId = $this->createPropertyGroup($propertyDefaultName);
|
||||||
}
|
}
|
||||||
@ -2664,15 +2676,10 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
if (empty($article['matrix_varianten']) || empty($articleIdShopware)) {
|
if (empty($article['matrix_varianten']) || empty($articleIdShopware)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$headerInformation = ['sw-language-id: ' . $languageId];
|
||||||
$internalGroupPropertiesToShopwareId = [];
|
$internalGroupPropertiesToShopwareId = [];
|
||||||
foreach ($article['matrix_varianten']['gruppen'] as $propertyGroupName => $internalPropertyGroupValues) {
|
foreach ($article['matrix_varianten']['gruppen'] as $propertyGroupName => $internalPropertyGroupValues) {
|
||||||
$propertyGroupId = '';
|
$propertyGroupId = $this->getPropertyGroupId($propertyGroupName);
|
||||||
if (array_key_exists($propertyGroupName, $this->knownPropertyGroupIds)) {
|
|
||||||
$propertyGroupId = $this->knownPropertyGroupIds[$propertyGroupName];
|
|
||||||
}
|
|
||||||
if (empty($propertyGroupId)) {
|
|
||||||
$propertyGroupId = $this->getPropertyGroupId($propertyGroupName);
|
|
||||||
}
|
|
||||||
if (empty($propertyGroupId)) {
|
if (empty($propertyGroupId)) {
|
||||||
$propertyGroupId = $this->createPropertyGroup($propertyGroupName);
|
$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(
|
$shopwarePropertyGroupOptions = $this->shopwareRequest(
|
||||||
'GET',
|
'GET',
|
||||||
'property-group/' . $propertyGroupId . '/options?limit=100',
|
'property-group/' . $propertyGroupId . '/options?limit=100',
|
||||||
@ -2705,7 +2710,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($internalPropertyGroupValues as $internalPropertyGroupValue => $valueNotNeeded) {
|
foreach ($internalPropertyGroupValues as $internalPropertyGroupValue => $valueNotNeeded) {
|
||||||
if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName])) {
|
if (!array_key_exists($internalPropertyGroupValue, $internalGroupPropertiesToShopwareId[$propertyGroupName] ?? [])) {
|
||||||
$newOptionData = [
|
$newOptionData = [
|
||||||
'name' => (string)$internalPropertyGroupValue
|
'name' => (string)$internalPropertyGroupValue
|
||||||
];
|
];
|
||||||
@ -2778,6 +2783,13 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
$isCloseOut = true;
|
$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 = [
|
$variantProductData = [
|
||||||
'active' => $active,
|
'active' => $active,
|
||||||
'isCloseout' => $isCloseOut,
|
'isCloseout' => $isCloseOut,
|
||||||
@ -2800,7 +2812,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
],
|
],
|
||||||
'stock' => (int)$stock,
|
'stock' => (int)$stock,
|
||||||
'ean' => null,
|
'ean' => null,
|
||||||
'taxId' => $this->getTaxIdByRate($variant['steuersatz']),
|
'taxId' => $taxId,
|
||||||
];
|
];
|
||||||
if(!empty($weight)){
|
if(!empty($weight)){
|
||||||
$variantProductData['weight'] = $weight;
|
$variantProductData['weight'] = $weight;
|
||||||
@ -2817,7 +2829,7 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
foreach ($internalVariantMatrixData as $expression) {
|
foreach ($internalVariantMatrixData as $expression) {
|
||||||
if (!in_array(
|
if (!in_array(
|
||||||
$internalGroupPropertiesToShopwareId[$expression['name']][$expression['values']],
|
$internalGroupPropertiesToShopwareId[$expression['name']][$expression['values']],
|
||||||
$existingCombinationsByNumber[$productNumber]['options'],
|
$existingCombinationsByNumber[$productNumber]['options'] ?? [],
|
||||||
false)) {
|
false)) {
|
||||||
$renewVariant = true;
|
$renewVariant = true;
|
||||||
} else {
|
} else {
|
||||||
@ -2960,14 +2972,21 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
* @return PriceData[]
|
* @return PriceData[]
|
||||||
*/
|
*/
|
||||||
protected function getPricesFromArray($priceArray): array{
|
protected function getPricesFromArray($priceArray): array{
|
||||||
return array_map(static function($price){
|
$c = count($priceArray);
|
||||||
return new PriceData(
|
$result = [];
|
||||||
(int)$price['ab_menge'],
|
for ($i = 0; $i < $c; $i++) {
|
||||||
(float)$price['preis'],
|
$end = null;
|
||||||
(float)$price['bruttopreis'],
|
if ($i+1 < $c && ($priceArray[$i+1]['gruppeextern'] ?? '') == ($priceArray[$i]['gruppeextern'] ?? ''))
|
||||||
$price['waehrung'],
|
$end = (int)$priceArray[$i+1]['ab_menge'] - 1;
|
||||||
$price['gruppeextern'] ?? '') ;
|
$result[] = new PriceData(
|
||||||
},$priceArray);
|
(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