From e0eb907ba2f1187bec9c32a6a97d0fc04ace9216 Mon Sep 17 00:00:00 2001 From: O K Date: Fri, 5 Sep 2025 09:31:35 +0300 Subject: [PATCH] add missing context --- mauticconnect.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mauticconnect.php b/mauticconnect.php index 13be248..653c4c4 100644 --- a/mauticconnect.php +++ b/mauticconnect.php @@ -985,8 +985,12 @@ class MauticConnect extends Module $customer = new Customer((int)$cart->id_customer); $currency = new Currency((int)$cart->id_currency); - $link = new Link(); // Needed for generating image URLs + Context::getContext()->currency = $currency; + Context::getContext()->customer = $customer; + Context::getContext()->language = new Language($cart->id_lang); + Context::getContext()->country = new \Country(\Configuration::get('PS_COUNTRY_DEFAULT')); + Context::getContext()->link = new Link(); // 3. Gather primary data $customer_email = $customer->email; if (!$this->isContactInSegment($customer_email, $mauticSegmentId)) { @@ -994,7 +998,7 @@ class MauticConnect extends Module } - $action_url = $link->getPageLink('cart', true, null, [ + $action_url = Context::getContext()->link->getPageLink('cart', true, null, [ 'action' => 'show', ]); @@ -1006,10 +1010,10 @@ class MauticConnect extends Module $abandoned_cart_items_for_html = []; foreach ($products as $product) { - $product_obj = new Product($product['id_product'], false, $this->context->language->id); + $product_obj = new Product($product['id_product'], false, Context::getContext()->language->id); $product_url = $product_obj->getLink(); $cover_img = Product::getCover($product_obj->id); - $image_url = $link->getImageLink($product_obj->link_rewrite, $cover_img['id_image'], 'cart_default'); + $image_url = Context::getContext()->link->getImageLink($product_obj->link_rewrite, $cover_img['id_image'], 'cart_default'); $abandoned_cart_items_for_html[] = [ 'image_url' => $image_url, @@ -1056,9 +1060,9 @@ class MauticConnect extends Module "about" => [ // What this email is about: the abandoned cart items "@type" => "OfferCatalog", // A collection of offers/products "name" => "Неоформлене замовлення", - "description" => "Ви, можливо, забули придбати ці товари на ".Tools::getShopDomainSsl(), + "description" => "Ви, можливо, забули придбати ці товари на " . Tools::getShopDomainSsl(), // Optionally, add a general image for the catalog/brand - // // "image": "https://exclusion-ua.shop/logo.png", + // // "image": "https://exclusion-ua.shop/logo.png", "merchant" => [ "@type" => "Organization", "name" => Tools::getShopDomainSsl(), @@ -1274,7 +1278,7 @@ class MauticConnect extends Module 'date_add' => date('Y-m-d H:i:s'), ], false, true, Db::INSERT_IGNORE); // INSERT IGNORE is a safe way to prevent errors on race conditions } - + public function log(array $data) {