Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 8b184b4

Browse files
committed
MAGETWO-91701: Newsletter subscription is not correctly updated when user is registered on 2 stores
- Adding additional checking for guest customers
1 parent dff7580 commit 8b184b4

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class Subscriber extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
4848
*/
4949
protected $mathRandom;
5050

51+
/**
52+
* Guest customer id
53+
*
54+
* @var int
55+
*/
56+
private $guestCustomerId = 0;
57+
5158
/**
5259
* Construct
5360
*
@@ -136,22 +143,24 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface
136143
return $result;
137144
}
138145

139-
$select = $this->connection
140-
->select()
141-
->from($this->getMainTable())
142-
->where('subscriber_email=:subscriber_email and store_id=:store_id');
143-
144-
$result = $this->connection
145-
->fetchRow(
146-
$select,
147-
[
148-
'subscriber_email' => $customer->getEmail(),
149-
'store_id' => $customer->getStoreId()
150-
]
151-
);
152-
153-
if ($result) {
154-
return $result;
146+
if ($customer->getId() === $this->guestCustomerId) {
147+
$select = $this->connection
148+
->select()
149+
->from($this->getMainTable())
150+
->where('subscriber_email=:subscriber_email and store_id=:store_id');
151+
152+
$result = $this->connection
153+
->fetchRow(
154+
$select,
155+
[
156+
'subscriber_email' => $customer->getEmail(),
157+
'store_id' => $customer->getStoreId()
158+
]
159+
);
160+
161+
if ($result) {
162+
return $result;
163+
}
155164
}
156165

157166
return [];

0 commit comments

Comments
 (0)