init
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\AiMascotCampaign\Model;
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
|
||||
class RegistrationRecorder
|
||||
{
|
||||
private const TABLE_NAME = 'esun_campaign_registration';
|
||||
|
||||
public function __construct(private readonly ResourceConnection $resourceConnection)
|
||||
{
|
||||
}
|
||||
|
||||
public function record(
|
||||
string $campaignCode,
|
||||
int $customerId,
|
||||
string $email,
|
||||
int $websiteId,
|
||||
int $storeId
|
||||
): void {
|
||||
$normalizedEmail = strtolower(trim($email));
|
||||
if ($customerId <= 0 || $normalizedEmail === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$connection = $this->resourceConnection->getConnection();
|
||||
$connection->insertOnDuplicate(
|
||||
$this->resourceConnection->getTableName(self::TABLE_NAME),
|
||||
[
|
||||
'campaign_code' => $campaignCode,
|
||||
'customer_id' => $customerId,
|
||||
'email' => $normalizedEmail,
|
||||
'website_id' => $websiteId,
|
||||
'store_id' => $storeId,
|
||||
],
|
||||
[]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user