Skip to content

Commit cfb175e

Browse files
committed
DA DEFINIRE
1 parent cacf793 commit cfb175e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ps_emailsubscription.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,22 @@ public function newsletterRegistration($hookName = null)
505505

506506
public function getSubscribers()
507507
{
508+
/**
509+
* //TODO <cnc-notice> ISSUE: https://github.com/PrestaShop/PrestaShop/issues/36152
510+
*/
511+
$shopIds = [];
512+
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE')) {
513+
$context = Context::getContext();
514+
$shopContext = Shop::getContext();
515+
516+
if ($shopContext === Shop::CONTEXT_SHOP) {
517+
$shopIds = [(int) $context->shop->id];
518+
} elseif ($shopContext === Shop::CONTEXT_GROUP) {
519+
$shops = ShopGroup::getShopsFromGroup((int) $context->shop->id_shop_group);
520+
$shopIds = array_column($shops, 'id_shop');
521+
}
522+
}
523+
508524
$dbquery = new DbQuery();
509525
$dbquery->select('c.`id_customer` AS `id`, s.`name` AS `shop_name`, gl.`name` AS `gender`, c.`lastname`, c.`firstname`, c.`email`, c.`newsletter` AS `subscribed`, c.`newsletter_date_add`, l.`iso_code`');
510526
$dbquery->from('customer', 'c');
@@ -517,6 +533,10 @@ public function getSubscribers()
517533
$dbquery->where('c.`email` LIKE \'%' . pSQL($this->_searched_email) . '%\' ');
518534
}
519535

536+
if (!empty($shopIds)) {
537+
$dbquery->where('c.`id_shop` IN (' . implode(',', $shopIds) . ')');
538+
}
539+
520540
$customers = Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($dbquery->build());
521541

522542
$dbquery = new DbQuery();
@@ -529,6 +549,10 @@ public function getSubscribers()
529549
$dbquery->where('e.`email` LIKE \'%' . pSQL($this->_searched_email) . '%\' ');
530550
}
531551

552+
if (!empty($shopIds)) {
553+
$dbquery->where('e.`id_shop` IN (' . implode(',', $shopIds) . ')');
554+
}
555+
532556
$non_customers = Db::getInstance()->executeS($dbquery->build());
533557

534558
$subscribers = array_merge($customers, $non_customers);

0 commit comments

Comments
 (0)