mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2025-03-03 13:29:24 +01:00
Merge pull request #179 from exciler/shopexport
Shopexport improvements
This commit is contained in:
commit
8b4f8d49e4
10
classes/Modules/Onlineshop/Data/ArticleExportResult.php
Normal file
10
classes/Modules/Onlineshop/Data/ArticleExportResult.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Xentral\Modules\Onlineshop\Data;
|
||||
|
||||
class ArticleExportResult {
|
||||
public int $articleId = 0;
|
||||
public bool $success = false;
|
||||
public ?string $message = null;
|
||||
public ?string $extArticleId = null;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Xentral\Components\Logger\Logger;
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
|
||||
/** @var Logger $logger */
|
||||
$logger = $app->Container->get('Logger');
|
||||
@ -244,11 +245,12 @@ foreach ($shops_to_transmit as $shop_to_transmit) {
|
||||
);
|
||||
|
||||
// See description of return format in function class.remote.php -> RemoteSendArticleList()
|
||||
foreach ($result['articlelist'] as $article) {
|
||||
/** @var ArticleExportResult $articleResult */
|
||||
foreach ($result as $articleResult) {
|
||||
$app->DB->Delete(
|
||||
sprintf(
|
||||
'DELETE FROM `shopexport_artikeluebertragen` WHERE `artikel`= %d AND `shop` = %d',
|
||||
$article['artikel'],
|
||||
$articleResult->articleId,
|
||||
$shop_to_transmit['shop']
|
||||
)
|
||||
);
|
||||
|
@ -23,6 +23,7 @@
|
||||
<?php
|
||||
use Xentral\Components\MailClient\Client\MimeMessageFormatterInterface;
|
||||
use Xentral\Core\LegacyConfig\ConfigLoader;
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Modules\SystemMailClient\MailClientConfigProvider;
|
||||
use Xentral\Modules\SystemMailClient\MailClientProvider;
|
||||
use Xentral\Modules\SystemMailer\Data\EmailBackupAccount;
|
||||
@ -20721,7 +20722,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
|
||||
|
||||
$this->LogFile('*** UPDATE '.$lagerartikel[$ij]['nummer'].' '.$lagerartikel[$ij]['name_de'].' Shop: '.$shop.' Lagernd: '.$verkaufbare_menge.' Korrektur: '.round((float) ($verkaufbare_menge_korrektur - $verkaufbare_menge),7).' Pseudolager: '.round((float) $pseudolager,8).' Result: '.(is_array($result)?$result['status']:$result), $result);
|
||||
|
||||
if ((is_array($result)?$result['status'] == 1:false) || $result === 1) {
|
||||
if ((is_array($result) && $result instanceof ArticleExportResult ? $result->success : false) || $result === 1) {
|
||||
$cacheQuantity = (int) $verkaufbare_menge_korrektur + (int) $pseudolager;
|
||||
$this->app->DB->Update(
|
||||
"UPDATE `artikel` SET `cache_lagerplatzinhaltmenge` = '{$cacheQuantity}'
|
||||
@ -23015,7 +23016,7 @@ function ChargenMHDAuslagern($artikel, $menge, $lagerplatztyp, $lpid,$typ,$wert,
|
||||
}
|
||||
$ansprechpartner = str_replace('<','<',$ansprechpartner);
|
||||
$ansprechpartner = str_replace('>','>',$ansprechpartner);
|
||||
list($name, $email) = explode('<', trim($ansprechpartner,'>'));
|
||||
[$name, $email] = explode('<', trim($ansprechpartner,'>'));
|
||||
|
||||
$betreff = str_replace('\"','"',$betreff);
|
||||
$betreff = str_replace("\'","'",$betreff);
|
||||
|
@ -23,6 +23,7 @@
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
use Xentral\Modules\Onlineshop\Data\Shipment;
|
||||
@ -1332,6 +1333,7 @@ class Remote {
|
||||
}
|
||||
$this->app->erp->GetKategorienbaum($kategorienbaum, $categoryRootId, 0, $id);
|
||||
if (!empty($kategorienbaum)) {
|
||||
$katid = [];
|
||||
$kategorien = $this->app->DB->SelectArr("SELECT ak.id, ak.bezeichnung FROM `artikelbaum_artikel` aa INNER JOIN `artikelkategorien` ak ON aa.kategorie = ak.id AND ak.geloescht <> 1 AND aa.artikel = '$artikel' ORDER by ak.bezeichnung");
|
||||
if ($kategorien) {
|
||||
foreach ($kategorien as $v) {
|
||||
@ -1941,7 +1943,7 @@ class Remote {
|
||||
if (!empty($artikelexport) && !$nurlager) {
|
||||
$result = $this->sendlist($id, $data, true);
|
||||
}
|
||||
if (!empty($lagerexport)) {
|
||||
else if (!empty($lagerexport)) {
|
||||
$result = $this->sendlistlager($id, $data);
|
||||
}
|
||||
return $result;
|
||||
@ -2067,7 +2069,7 @@ class Remote {
|
||||
if (!empty($artikelexport) && !$nurlager) {
|
||||
$result = $this->sendlist($id, $data, true);
|
||||
}
|
||||
if (!empty($lagerexport)) {
|
||||
else if (!empty($lagerexport)) {
|
||||
$result = $this->sendlistlager($id, $data);
|
||||
}
|
||||
return $result;
|
||||
@ -2100,16 +2102,19 @@ class Remote {
|
||||
$result = $this->RemoteCommand($shop_id, 'sendlist', $data);
|
||||
|
||||
if (!empty($result) && is_array($result)) {
|
||||
foreach ($result['articles'] as $artikelid) {
|
||||
/** @var ArticleExportResult $articleResult */
|
||||
foreach ($result as $articleResult) {
|
||||
if (!$articleResult instanceof ArticleExportResult)
|
||||
continue;
|
||||
/** @var Shopexport $objShopexport */
|
||||
$objShopexport = $this->app->loadModule('shopexport');
|
||||
$changedHash = $objShopexport->hasArticleHashChanged($artikelid, $shop_id);
|
||||
$changedHash = $objShopexport->hasArticleHashChanged($articleResult->articleId, $shop_id);
|
||||
$hash = $changedHash['hash'];
|
||||
|
||||
$checkAo = $this->app->DB->Select(
|
||||
sprintf(
|
||||
'SELECT id FROM artikel_onlineshops WHERE artikel = %d AND shop=%d LIMIT 1',
|
||||
$artikelid, $shop_id
|
||||
$articleResult->articleId, $shop_id
|
||||
)
|
||||
);
|
||||
if (empty($checkAo)) {
|
||||
@ -2117,7 +2122,7 @@ class Remote {
|
||||
sprintf(
|
||||
'INSERT INTO artikel_onlineshops (artikel, shop, aktiv, ausartikel)
|
||||
VALUES (%d, %d, 1, 1) ',
|
||||
$artikelid, $shop_id
|
||||
$articleResult->articleId, $shop_id
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -2126,31 +2131,27 @@ class Remote {
|
||||
"UPDATE artikel_onlineshops
|
||||
SET last_article_transfer = NOW(), last_article_hash = '%s'
|
||||
WHERE artikel = %d AND shop = %d",
|
||||
$this->app->DB->real_escape_string($hash), $artikelid, $shop_id
|
||||
$this->app->DB->real_escape_string($hash), $articleResult->articleId, $shop_id
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($result) && is_array($result)) {
|
||||
foreach ($result['new'] as $artikelid => $fremdnummer) {
|
||||
$artikelid = (int) $artikelid;
|
||||
$artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$artikelid' LIMIT 1");
|
||||
if ($artikelid > 0 && $artikelnummer != trim($fremdnummer) &&
|
||||
($this->app->DB->Select("SELECT id FROM artikel WHERE id = '$artikelid' AND (shop = '$shop_id' OR shop2 = '$shop_id' OR shop3 = '$shop_id') LIMIT 1") ||
|
||||
$this->app->DB->Select("SELECT id FROM artikel_onlineshops WHERE artikel = '$artikelid' AND aktiv = 1")
|
||||
) && trim($fremdnummer) !== '') {
|
||||
//Nur falls Artikel zum Shop passt und keine aktive Fremdnummer exisitert.
|
||||
if (!$this->app->DB->Select("SELECT id FROM `artikelnummer_fremdnummern` WHERE artikel = '$artikelid' AND shopid = '$shop_id' AND nummer <> '' AND (aktiv = 1 OR nummer = '" . trim($this->app->DB->real_escape_string($fremdnummer)) . "') LIMIT 1 ")) {
|
||||
$this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
|
||||
VALUES ('$artikelid','Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($fremdnummer)) . "','$shop_id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
|
||||
");
|
||||
$artikelnummer = $this->app->DB->Select("SELECT nummer FROM artikel WHERE id = '$articleResult->articleId' LIMIT 1");
|
||||
$artikelfremdnummer = $this->app->DB->Select("SELECT nummer
|
||||
FROM `artikelnummer_fremdnummern`
|
||||
WHERE artikel = '$articleResult->articleId'
|
||||
AND shopid = '$shop_id'
|
||||
AND nummer != ''
|
||||
AND (aktiv = 1 OR nummer = '".trim($this->app->DB->real_escape_string($articleResult->extArticleId))."') LIMIT 1 ");
|
||||
if ($articleResult->articleId > 0 && $articleResult->extArticleId != null &&
|
||||
trim($articleResult->extArticleId) != '' &&
|
||||
$artikelnummer != trim($articleResult->extArticleId) &&
|
||||
empty($artikelfremdnummer)) {
|
||||
//Nur falls keine aktive Fremdnummer exisitert.
|
||||
$this->app->DB->Insert("INSERT INTO `artikelnummer_fremdnummern` (artikel, bezeichnung, nummer, shopid, bearbeiter, zeitstempel, aktiv)
|
||||
VALUES ($articleResult->articleId,'Erstellt durch Artikelexport','" . trim($this->app->DB->real_escape_string($articleResult->extArticleId)) . "','$shop_id','" . ((isset($this->app->User) && method_exists($this->app->User, 'GetName')) ? $this->app->DB->real_escape_string($this->app->User->GetName()) : 'Cronjob') . "',now(),0)
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($result['anzahl'])) {
|
||||
$result['count'] = $result['anzahl'];
|
||||
}//Altes Verhalten
|
||||
}
|
||||
|
||||
if (!$isLagerExported) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Widgets\SuperSearch\Result\ResultGroup;
|
||||
use Xentral\Widgets\SuperSearch\Result\ResultItem;
|
||||
|
||||
@ -2873,9 +2874,9 @@ class Artikel extends GenArtikel {
|
||||
|
||||
$remote_result = $this->app->remote->RemoteSendArticleList($shop, $artikel, $extartikelnummer);
|
||||
|
||||
if (is_array($remote_result)) {
|
||||
$remote_status = $remote_result['status'];
|
||||
$remote_message = $remote_result['message'];
|
||||
if (is_array($remote_result) && $remote_result[0] instanceof ArticleExportResult) {
|
||||
$remote_status = $remote_result[0]->success;
|
||||
$remote_message = $remote_result[0]->message;
|
||||
} else if (is_numeric($remote_result)) {
|
||||
if ($remote_result == 1) {
|
||||
$remote_status = true;
|
||||
|
@ -473,6 +473,9 @@ class Shopexport
|
||||
|
||||
// sende artikel liste
|
||||
$tmp_anzahl = $this->app->remote->RemoteSendArticleList($id,$artikel);
|
||||
if (is_array($tmp_anzahl)) {
|
||||
$tmp_anzahl = count(array_filter($tmp_anzahl, fn($var) => $var->success));
|
||||
}
|
||||
|
||||
// dateien update
|
||||
//$dateien = $this->app->DB->SelectArr("SELECT DISTINCT ds.datei FROM datei_stichwoerter ds, datei d WHERE d.id=ds.datei AND (ds.subjekt!='Druckbild') AND (ds.objekt='Artikel' OR ds.objekt='Kampangen') AND d.geloescht=0 AND d.firma='".$this->app->User->GetFirma()."'");
|
||||
|
@ -14,6 +14,7 @@
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
@ -750,10 +751,14 @@ class Shopimporter_Shopify extends ShopimporterBase
|
||||
$bezprodukt = $this->bezprodukt;
|
||||
$bezvariant = $this->bezvariant;
|
||||
$ctmp = !empty($tmp)?count($tmp):0;
|
||||
$return = [];
|
||||
for($i=0;$i<$ctmp;$i++)
|
||||
{
|
||||
$return[$i] = new ArticleExportResult();
|
||||
$return[$i]->articleId = intval($tmp[$i]['artikel']);
|
||||
if($tmp[$i]['variante'] && $tmp[$i]['variantevon'] != ''){
|
||||
return "error: Variantenexport ist nur über den Hauptartikel möglich.";
|
||||
$return[$i]->message = "Variantenexport ist nur über den Hauptartikel möglich.";
|
||||
continue;
|
||||
}
|
||||
$artikel = $tmp[$i]['artikel'];
|
||||
if($artikel == 'ignore'){
|
||||
@ -1432,9 +1437,10 @@ class Shopimporter_Shopify extends ShopimporterBase
|
||||
}
|
||||
$this->translateFreeFields($productid, $freeFieldTranslations);
|
||||
|
||||
$anzahl++;
|
||||
$return[$i]->extArticleId = $productid;
|
||||
$return[$i]->success = true;
|
||||
}
|
||||
return $anzahl;
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
@ -1112,8 +1113,10 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
$crosssellingartikeluebertragen = 0;
|
||||
$preisgruppe = 0;
|
||||
}
|
||||
$return = [];
|
||||
for($i=0;$i<$ctmp;$i++)
|
||||
{
|
||||
$return[$i] = new ArticleExportResult();
|
||||
$filtergruppe = 0;
|
||||
$rootcategory = 1;
|
||||
if(!empty($this->RootCategoryName)) {
|
||||
@ -1207,6 +1210,7 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
|
||||
//Schritt 2: Artikeleigenschaften
|
||||
$artikel = $tmp[$i]['artikel'];
|
||||
$return[$i]->articleId = intval($artikel);
|
||||
$nummer = isset($tmp[$i]['fremdnummer'])?$tmp[$i]['fremdnummer']:$tmp[$i]['nummer'];
|
||||
$inaktiv = $tmp[$i]['inaktiv'];
|
||||
$name_de = $tmp[$i]['name_de'];
|
||||
@ -1231,7 +1235,8 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
|
||||
$preis = $tmp[$i]['bruttopreis'];
|
||||
if(!$preis){
|
||||
return 'error: Im Artikel ist kein Preis hinterlegt.';
|
||||
$return[$i]->message = 'Im Artikel ist kein Preis hinterlegt.';
|
||||
continue;
|
||||
}
|
||||
|
||||
$nettopreis =$tmp[$i]['preis'];
|
||||
@ -2013,7 +2018,8 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
}
|
||||
|
||||
if(!is_array($result)){
|
||||
return $result;
|
||||
$return[$i]->message = $result;
|
||||
continue;
|
||||
}
|
||||
//Schritt 8c: Alle Bilder anlegen und neu verlinken
|
||||
$first = 1;
|
||||
@ -2084,7 +2090,8 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
}
|
||||
|
||||
if(!is_array($result)){
|
||||
return $result;
|
||||
$return[$i]->message = $result;
|
||||
continue;
|
||||
}
|
||||
|
||||
$artikelid = $result['data']['id'];
|
||||
@ -2217,13 +2224,14 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
|
||||
if($result['success'])
|
||||
{
|
||||
$anzahl++;
|
||||
$return[$i]->success = true;
|
||||
$return[$i]->extArticleId = $artikelid;
|
||||
//Erstellt Thumbnailbilder für den Artikel - behauptet die Doku
|
||||
$result = $this->adapter->put('generateArticleImages/'.$artikelexistiert);
|
||||
}
|
||||
}
|
||||
|
||||
return $anzahl;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetImagesIdsbyNummer($nummer){
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\ArticleExportResult;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
use Xentral\Components\Logger\Logger;
|
||||
@ -556,8 +557,11 @@ class Shopimporter_Woocommerce extends ShopimporterBase
|
||||
public function ImportSendList() {
|
||||
$tmp = $this->catchRemoteCommand('data');
|
||||
$anzahl = 0;
|
||||
$return = [];
|
||||
for($i=0;$i<(!empty($tmp)?count($tmp):0);$i++){
|
||||
$return[$i] = new ArticleExportResult();
|
||||
$artikel = $tmp[$i]['artikel'];
|
||||
$return[$i]->articleId = intval($artikel);
|
||||
$nummer = $tmp[$i]['nummer'];
|
||||
if(!empty($tmp[$i]['artikelnummer_fremdnummern'][0]['nummer'])){
|
||||
$nummer = $tmp[$i]['artikelnummer_fremdnummern'][0]['nummer'];
|
||||
@ -766,10 +770,10 @@ class Shopimporter_Woocommerce extends ShopimporterBase
|
||||
}
|
||||
}
|
||||
|
||||
$anzahl++;
|
||||
$return[$i]->success = true;
|
||||
}
|
||||
|
||||
return $anzahl;
|
||||
return $return;
|
||||
// return array($product_id,$anzahl,$nummer,$steuersatz, $preis);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user