add missing context

This commit is contained in:
O K
2025-09-05 09:31:35 +03:00
parent 0949f1025b
commit e0eb907ba2

View File

@@ -985,8 +985,12 @@ class MauticConnect extends Module
$customer = new Customer((int)$cart->id_customer); $customer = new Customer((int)$cart->id_customer);
$currency = new Currency((int)$cart->id_currency); $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 // 3. Gather primary data
$customer_email = $customer->email; $customer_email = $customer->email;
if (!$this->isContactInSegment($customer_email, $mauticSegmentId)) { 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', 'action' => 'show',
]); ]);
@@ -1006,10 +1010,10 @@ class MauticConnect extends Module
$abandoned_cart_items_for_html = []; $abandoned_cart_items_for_html = [];
foreach ($products as $product) { 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(); $product_url = $product_obj->getLink();
$cover_img = Product::getCover($product_obj->id); $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[] = [ $abandoned_cart_items_for_html[] = [
'image_url' => $image_url, 'image_url' => $image_url,