mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Merge pull request #89 from exciler/prestashop-improve-import
Prestashop improve import
This commit is contained in:
commit
5557c54fd6
@ -559,7 +559,7 @@ class Remote
|
|||||||
$steuersatz_normal = 19;
|
$steuersatz_normal = 19;
|
||||||
}
|
}
|
||||||
$crossellingInstalled = $this->app->erp->ModulVorhanden('crossselling');
|
$crossellingInstalled = $this->app->erp->ModulVorhanden('crossselling');
|
||||||
foreach($reta as $k => $ret)
|
foreach($reta as $k => $ret)
|
||||||
{
|
{
|
||||||
if(isset($ret['stueckliste'])){
|
if(isset($ret['stueckliste'])){
|
||||||
$stuecklistenmechanik = $ret['stueckliste'];
|
$stuecklistenmechanik = $ret['stueckliste'];
|
||||||
@ -631,8 +631,17 @@ class Remote
|
|||||||
}
|
}
|
||||||
$arr['projekt'] = $shopexportArr['projekt'];
|
$arr['projekt'] = $shopexportArr['projekt'];
|
||||||
$arr['name_de'] = $ret['name'];
|
$arr['name_de'] = $ret['name'];
|
||||||
$arr['uebersicht_de'] = isset($ret['uebersicht_de'])?$ret['uebersicht_de']:'';
|
$arr['uebersicht_de'] = $ret['uebersicht_de'] ?? '';
|
||||||
$arr['kurztext_de'] = isset($ret['kurztext_de'])?$ret['kurztext_de']:'';
|
$arr['kurztext_de'] = $ret['kurztext_de'] ?? '';
|
||||||
|
$arr['name_en'] = $ret['name_en'];
|
||||||
|
$arr['uebersicht_en'] = $ret['uebersicht_en'] ?? '';
|
||||||
|
$arr['kurztext_en'] = $ret['kurztext_en'] ?? '';
|
||||||
|
$arr['metakeywords_de'] = $ret['metakeywords_de'] ?? '';
|
||||||
|
$arr['metakeywords_en'] = $ret['metakeywords_en'] ?? '';
|
||||||
|
$arr['metatitle_de'] = $ret['metatitle_de'] ?? '';
|
||||||
|
$arr['metatitle_en'] = $ret['metatitle_en'] ?? '';
|
||||||
|
$arr['metadescription_de'] = $ret['metadescription_de'] ?? '';
|
||||||
|
$arr['metadescription_en'] = $ret['metadescription_en'] ?? '';
|
||||||
//$arr['anabregs_text'] = isset($ret['uebersicht_de'])?$ret['uebersicht_de']:'';
|
//$arr['anabregs_text'] = isset($ret['uebersicht_de'])?$ret['uebersicht_de']:'';
|
||||||
if(isset($ret['ean']) && $ret['ean'] != '')
|
if(isset($ret['ean']) && $ret['ean'] != '')
|
||||||
{
|
{
|
||||||
|
@ -333,34 +333,64 @@ class Shopimporter_Presta extends ShopimporterBase
|
|||||||
if (empty($nummer))
|
if (empty($nummer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$searchresult = $this->prestaRequest('GET', 'products?filter[reference]='.$nummer);
|
$productsresult = $this->prestaRequest('GET', 'products?filter[reference]='.$nummer);
|
||||||
if (empty($searchresult)) {
|
$combinationsresult = $this->prestaRequest('GET', 'combinations?filter[reference]='.$nummer);
|
||||||
|
$numberOfCombinations = count($combinationsresult->combinations->combination);
|
||||||
|
$numberOfProducts = count($productsresult->products->product);
|
||||||
|
$numberOfResults = $numberOfProducts + $numberOfCombinations;
|
||||||
|
if ($numberOfResults > 1) {
|
||||||
|
$this->Log('Got multiple results from Shop', $this->data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elseif ($numberOfResults < 1) {
|
||||||
$this->Log('No product found in Shop', $this->data);
|
$this->Log('No product found in Shop', $this->data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (count($searchresult->products->product) > 1) {
|
|
||||||
$this->Log('Got multiple results from Shop', $this->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
$productid = $searchresult->products->product->attributes()->id;
|
$isCombination = $numberOfCombinations > 0;
|
||||||
$product = $this->prestaRequest('GET', "products/$productid");
|
if ($isCombination) {
|
||||||
|
$combinationId = intval($combinationsresult->combinations->combination->attributes()->id);
|
||||||
|
$combination = $this->prestaRequest('GET', "combinations/$combinationId");
|
||||||
|
$productId = intval($combination->combination->id_product);
|
||||||
|
} else {
|
||||||
|
$productId = intval($productsresult->products->product->attributes()->id);
|
||||||
|
}
|
||||||
|
$product = $this->prestaRequest('GET', "products/$productId");
|
||||||
$res = [];
|
$res = [];
|
||||||
$res['nummer'] = strval($product->product->reference);
|
if ($isCombination) {
|
||||||
$res['artikelnummerausshop'] = strval($product->product->reference);
|
$res['nummer'] = strval($combination->combination->reference);
|
||||||
|
$res['artikelnummerausshop'] = strval($combination->combination->reference);
|
||||||
|
$res['ean'] = strval($combination->combination->ean13);
|
||||||
|
$res['preis_netto'] = floatval($product->product->price) + floatval($combination->combination->price);
|
||||||
|
} else {
|
||||||
|
$res['nummer'] = strval($product->product->reference);
|
||||||
|
$res['artikelnummerausshop'] = strval($product->product->reference);
|
||||||
|
$res['ean'] = strval($product->product->ean13);
|
||||||
|
$res['preis_netto'] = floatval($product->product->price);
|
||||||
|
}
|
||||||
$names = $this->toMultilangArray($product->product->name->language);
|
$names = $this->toMultilangArray($product->product->name->language);
|
||||||
$descriptions = $this->toMultilangArray($product->product->description->language);
|
$descriptions = $this->toMultilangArray($product->product->description->language);
|
||||||
$shortdescriptions = $this->toMultilangArray($product->product->description_short->language);
|
$shortdescriptions = $this->toMultilangArray($product->product->description_short->language);
|
||||||
|
$metadescriptions = $this->toMultilangArray($product->product->meta_description->language);
|
||||||
|
$metakeywords = $this->toMultilangArray($product->product->meta_keywords->language);
|
||||||
|
$metatitles = $this->toMultilangArray($product->product->meta_title->language);
|
||||||
$res['name'] = $names['de'];
|
$res['name'] = $names['de'];
|
||||||
$res['name_en'] = $names['en'];
|
$res['name_en'] = $names['en'];
|
||||||
$res['uebersicht_de'] = $descriptions['de'];
|
$res['uebersicht_de'] = $descriptions['de'];
|
||||||
$res['uebersicht_en'] = $descriptions['en'];
|
$res['uebersicht_en'] = $descriptions['en'];
|
||||||
$res['preis_netto'] = strval($product->product->price);
|
$res['kurztext_de'] = strip_tags($shortdescriptions['de']);
|
||||||
|
$res['kurztext_en'] = strip_tags($shortdescriptions['en']);
|
||||||
$res['hersteller'] = strval($product->product->manufacturer_name);
|
$res['hersteller'] = strval($product->product->manufacturer_name);
|
||||||
$res['ean'] = strval($product->product->ean13);
|
$res['metakeywords_de'] = $metakeywords['de'];
|
||||||
|
$res['metakeywords_en'] = $metakeywords['en'];
|
||||||
|
$res['metatitle_de'] = $metatitles['de'];
|
||||||
|
$res['metatitle_en'] = $metatitles['en'];
|
||||||
|
$res['metadescription_de'] = $metadescriptions['de'];
|
||||||
|
$res['metadescription_en'] = $metadescriptions['en'];
|
||||||
|
|
||||||
$images = [];
|
$images = [];
|
||||||
foreach ($product->product->associations->images->image as $img) {
|
foreach ($product->product->associations->images->image as $img) {
|
||||||
$endpoint = "images/products/$productid/$img->id";
|
$endpoint = "images/products/$productId/$img->id";
|
||||||
$imgdata = $this->prestaRequest('GET', $endpoint, '', true);
|
$imgdata = $this->prestaRequest('GET', $endpoint, '', true);
|
||||||
$images[] = [
|
$images[] = [
|
||||||
'content' => base64_encode($imgdata),
|
'content' => base64_encode($imgdata),
|
||||||
|
Loading…
Reference in New Issue
Block a user