Petite amélioration sur le module PurgeFakeCustomer -> on loggue les suppressions de faux clients à présent.
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
*/
|
||||
namespace PurgeFakeCustomer\EventListener;
|
||||
|
||||
use PurgeFakeCustomer\Controller\Admin\AdminController;
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Propel\Runtime\Propel;
|
||||
use PurgeFakeCustomer\Event\FakeCustomerEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Model\Map\FeatureTableMap;
|
||||
|
||||
@@ -50,6 +52,31 @@ class EventManager implements EventSubscriberInterface
|
||||
$listeId = substr($listeId, 0, -1) . ')';
|
||||
$event->setDeletedList(substr($listeId, 1, -1));
|
||||
|
||||
/* On va logguer quelques infos de ces faux clients */
|
||||
$stmt->closeCursor();
|
||||
$sql = 'SELECT `customer_id`, `firstname`, `lastname`, `address1`, `zipcode`, `city`, `country_id` FROM `address` WHERE `customer_id` IN ' . $listeId;
|
||||
try {
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
if ($rows = $stmt->fetchAll(\PDO::FETCH_OBJ)) {
|
||||
foreach ($rows as $fakeCustomer) {
|
||||
$customerAsString = sprintf("Deleted fake customer -> Id: %d - Firstname: %s - Lastname: %s - Address: %s - ZipCode: %s - City: %s - Country_id: %d",
|
||||
$fakeCustomer->customer_id,
|
||||
$fakeCustomer->firstname,
|
||||
$fakeCustomer->lastname,
|
||||
$fakeCustomer->address1,
|
||||
$fakeCustomer->zipcode,
|
||||
$fakeCustomer->city,
|
||||
$fakeCustomer->country_id);
|
||||
|
||||
Tlog::getInstance()->addWarning($customerAsString);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
Propel::log($e->getMessage(), Propel::LOG_ERR);
|
||||
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
|
||||
}
|
||||
|
||||
$nbAvant = CustomerQuery::create()->count();
|
||||
/* Le OnCascade permet de supprimer toutes les infos du client juste en le supprimant dans la table CUSTOMER */
|
||||
$sql = 'DELETE FROM `customer` WHERE `id` IN ' . $listeId;
|
||||
@@ -79,4 +106,5 @@ class EventManager implements EventSubscriberInterface
|
||||
FakeCustomerEvent::PURGE => ["purge", 128]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user