Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielborzov/b11560cfd9c872ad727fc53cb979f48d to your computer and use it in GitHub Desktop.
Save danielborzov/b11560cfd9c872ad727fc53cb979f48d to your computer and use it in GitHub Desktop.
diff --git a/app/addons/call_requests/func.php b/app/addons/call_requests/func.php
index 355cb5d82d..a068daf62b 100644
--- a/app/addons/call_requests/func.php
+++ b/app/addons/call_requests/func.php
@@ -322,6 +322,11 @@ function fn_do_call_request($params, $product_data, &$cart, &$auth)
$params['company_id'] = $company_id;
+ if (fn_allowed_for('MULTIVENDOR') && empty($params['storefront_id'])) {
+ /** @var \Tygh\Storefront\Storefront $storefront */
+ $params['storefront_id'] = Tygh::$app['storefront']->storefront_id ?? null;
+ }
+
/**
* Allows to perform some actions before call request is processed
*
diff --git a/app/addons/call_requests/schemas/notifications/events.post.php b/app/addons/call_requests/schemas/notifications/events.post.php
index 363bdb3f9d..0f55b9e256 100644
--- a/app/addons/call_requests/schemas/notifications/events.post.php
+++ b/app/addons/call_requests/schemas/notifications/events.post.php
@@ -32,14 +32,15 @@ $schema['call_requests.request_created'] = [
'receivers' => [
UserTypes::ADMIN => [
MailTransport::getId() => MailMessageSchema::create([
- 'area' => SiteArea::ADMIN_PANEL,
- 'from' => 'default_company_orders_department',
- 'to' => 'company_orders_department',
- 'template_code' => 'call_requests_call_request',
- 'legacy_template' => 'addons/call_requests/call_request.tpl',
- 'company_id' => DataValue::create('call_request_data.company_id'),
- 'to_company_id' => DataValue::create('call_request_data.company_id'),
- 'language_code' => Registry::get('settings.Appearance.backend_default_language'),
+ 'area' => SiteArea::ADMIN_PANEL,
+ 'from' => 'default_company_orders_department',
+ 'to' => 'company_orders_department',
+ 'template_code' => 'call_requests_call_request',
+ 'legacy_template' => 'addons/call_requests/call_request.tpl',
+ 'company_id' => DataValue::create('call_request_data.company_id'),
+ 'to_company_id' => DataValue::create('call_request_data.company_id'),
+ 'to_storefront_id' => DataValue::create('call_request_data.storefront_id'),
+ 'language_code' => Registry::get('settings.Appearance.backend_default_language'),
]),
],
],
diff --git a/app/addons/product_reviews/func.php b/app/addons/product_reviews/func.php
index 1a7a6bdd77..9d2fd3e9ed 100644
--- a/app/addons/product_reviews/func.php
+++ b/app/addons/product_reviews/func.php
@@ -262,6 +262,13 @@ function fn_product_reviews_get_data_for_notification($product_review_id, array
$product_reviews_repository = ProductReviewsProvider::getProductReviewRepository();
$product_review_data = $product_reviews_repository->findById($product_review_id);
+ if (
+ fn_allowed_for('MULTIVENDOR')
+ && YesNo::toBool(Registry::ifGet('addons.product_reviews.split_reviews_by_storefronts', YesNo::NO))
+ ) {
+ $product_review_data['to_storefront_id'] = !empty($product_review_data['storefront_id']) ? $product_review_data['storefront_id'] : null;
+ }
+
if (!$product_review_data || empty($product_review_data['product_review_id'])) {
return [];
}
diff --git a/app/addons/product_reviews/schemas/notifications/events.post.php b/app/addons/product_reviews/schemas/notifications/events.post.php
index 2c56763956..6acef2b09a 100644
--- a/app/addons/product_reviews/schemas/notifications/events.post.php
+++ b/app/addons/product_reviews/schemas/notifications/events.post.php
@@ -40,6 +40,7 @@ $schema['product_reviews.new_post'] = [
'from' => 'company_site_administrator',
'to' => 'company_orders_department',
'to_company_id' => DataValue::create('product_data.company_id'),
+ 'to_storefront_id' => DataValue::create('product_review_data.to_storefront_id'),
'template_code' => 'product_reviews_notification',
'legacy_template' => 'addons/product_reviews/product_review_notification.tpl',
'language_code' => DataValue::create('company.lang_code', CART_LANGUAGE),
diff --git a/app/schemas/notifications/events.php b/app/schemas/notifications/events.php
index c66aa035b1..43e22a0263 100644
--- a/app/schemas/notifications/events.php
+++ b/app/schemas/notifications/events.php
@@ -606,16 +606,17 @@ $order_event = [
],
UserTypes::ADMIN => [
MailTransport::getId() => MailMessageSchema::create([
- 'area' => SiteArea::ADMIN_PANEL,
- 'from' => 'default_company_orders_department',
- 'to' => 'default_company_orders_department',
- 'reply_to' => DataValue::create('order_info.email'),
- 'template_code' => DataValue::create('template_code'),
- 'legacy_template' => 'orders/order_notification.tpl',
- 'company_id' => DataValue::create('order_info.company_id'),
- 'to_company_id' => DataValue::create('order_info.company_id'),
- 'storefront_id' => DataValue::create('order_info.storefront_id'),
- 'language_code' => DataValue::create('lang_code', CART_LANGUAGE)
+ 'area' => SiteArea::ADMIN_PANEL,
+ 'from' => 'default_company_orders_department',
+ 'to' => 'default_company_orders_department',
+ 'reply_to' => DataValue::create('order_info.email'),
+ 'template_code' => DataValue::create('template_code'),
+ 'legacy_template' => 'orders/order_notification.tpl',
+ 'company_id' => DataValue::create('order_info.company_id'),
+ 'to_company_id' => DataValue::create('order_info.company_id'),
+ 'storefront_id' => DataValue::create('order_info.storefront_id'),
+ 'to_storefront_id' => DataValue::create('order_info.storefront_id'),
+ 'language_code' => DataValue::create('lang_code', CART_LANGUAGE)
])
],
],
diff --git a/app/Tygh/Notifications/Transports/Mail/MailMessageSchema.php b/app/Tygh/Notifications/Transports/Mail/MailMessageSchema.php
index e6c73803ce..614592dced 100644
--- a/app/Tygh/Notifications/Transports/Mail/MailMessageSchema.php
+++ b/app/Tygh/Notifications/Transports/Mail/MailMessageSchema.php
@@ -77,6 +77,11 @@ class MailMessageSchema extends BaseMessageSchema
*/
public $storefront_id;
+ /**
+ * @var int
+ */
+ public $to_storefront_id;
+
/**
* @var array
*/
@@ -98,6 +103,7 @@ class MailMessageSchema extends BaseMessageSchema
$self->area = self::get($schema, 'area');
$self->attachments = self::get($schema, 'attachments', []);
$self->storefront_id = self::get($schema, 'storefront_id');
+ $self->to_storefront_id = self::get($schema, 'to_storefront_id');
//TODO validate schema
diff --git a/app/Tygh/Notifications/Transports/Mail/ReceiverFinders/UserIdFinder.php b/app/Tygh/Notifications/Transports/Mail/ReceiverFinders/UserIdFinder.php
index fc670b9d9a..7d1b19442f 100644
--- a/app/Tygh/Notifications/Transports/Mail/ReceiverFinders/UserIdFinder.php
+++ b/app/Tygh/Notifications/Transports/Mail/ReceiverFinders/UserIdFinder.php
@@ -44,6 +44,10 @@ class UserIdFinder implements ReceiverFinderInterface
$conditions['users.company_id'] = [0, $message_schema->to_company_id];
}
+ if (fn_allowed_for('MULTIVENDOR') && !empty($message_schema->to_storefront_id)) {
+ $conditions['users.storefront_id'] = [0, $message_schema->to_storefront_id];
+ }
+
return $this->db->getColumn(
'SELECT users.email'
. ' FROM ?:users AS users'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment