From 5d1201637facad46d2463b37e0848d47c1a0a4a6 Mon Sep 17 00:00:00 2001 From: Andreas Palm Date: Sun, 30 Jul 2023 22:08:32 +0200 Subject: [PATCH] Prestashop: Import metakeywords --- www/pages/shopimporter_presta.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/www/pages/shopimporter_presta.php b/www/pages/shopimporter_presta.php index 1ff7f207..793deab0 100644 --- a/www/pages/shopimporter_presta.php +++ b/www/pages/shopimporter_presta.php @@ -384,13 +384,26 @@ class Shopimporter_Presta extends ShopimporterBase $res['kurztext_de'] = strip_tags($shortdescriptions['de']); $res['kurztext_en'] = strip_tags($shortdescriptions['en']); $res['hersteller'] = strval($product->product->manufacturer_name); - $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']; + $tags = $product->product->associations->tags->tag; + $keywords = []; + foreach ($tags as $tag) { + $tagid = intval($tag->id); + $endpoint = "tags/{$tagid}"; + $tagdata = $this->prestaRequest('GET', $endpoint); + $tagiso = $this->langidToIso[intval($tagdata->tag->id_lang)]; + $tagvalue = strval($tagdata->tag->name); + if (!array_key_exists($tagiso, $keywords)) + $keywords[$tagiso] = []; + $keywords[$tagiso][] = $tagvalue; + } + $res['metakeywords_de'] = join(',', $keywords['de'] ?? []); + $res['metakeywords_en'] = join(',', $keywords['en'] ?? []); + $images = []; foreach ($product->product->associations->images->image as $img) { $endpoint = "images/products/$productId/$img->id";