14
14
use Magento \Customer \Model \CustomerRegistry ;
15
15
use Magento \Framework \Api \SearchCriteriaBuilder ;
16
16
use Magento \Framework \App \Config \ScopeConfigInterface ;
17
+ use Magento \Framework \DataObject ;
17
18
use Magento \Framework \Exception \InputException ;
18
19
use Magento \Framework \Exception \LocalizedException ;
19
20
use Magento \Framework \Exception \NoSuchEntityException ;
@@ -37,53 +38,16 @@ class CustomerDataProcessor implements ProcessorInterface
37
38
{
38
39
private const CONFIG_PATH_ERASURE_REMOVE_CUSTOMER = 'gdpr/erasure/remove_customer ' ;
39
40
40
- private AnonymizerInterface $ anonymizer ;
41
-
42
- /**
43
- * @var CustomerRepositoryInterface
44
- */
45
- private CustomerRepositoryInterface $ customerRepository ;
46
-
47
- private OrderRepositoryInterface $ orderRepository ;
48
-
49
- private SearchCriteriaBuilder $ criteriaBuilder ;
50
-
51
- /**
52
- * @var CustomerRegistry
53
- */
54
- private CustomerRegistry $ customerRegistry ;
55
-
56
- /**
57
- * @var OrigDataRegistry
58
- */
59
- private OrigDataRegistry $ origDataRegistry ;
60
-
61
- /**
62
- * @var SessionCleanerInterface
63
- */
64
- private SessionCleanerInterface $ sessionCleaner ;
65
-
66
- private ScopeConfigInterface $ scopeConfig ;
67
-
68
41
public function __construct (
69
- AnonymizerInterface $ anonymizer ,
70
- CustomerRepositoryInterface $ customerRepository ,
71
- OrderRepositoryInterface $ orderRepository ,
72
- SearchCriteriaBuilder $ criteriaBuilder ,
73
- CustomerRegistry $ customerRegistry ,
74
- OrigDataRegistry $ origDataRegistry ,
75
- SessionCleanerInterface $ sessionCleaner ,
76
- ScopeConfigInterface $ scopeConfig
77
- ) {
78
- $ this ->anonymizer = $ anonymizer ;
79
- $ this ->customerRepository = $ customerRepository ;
80
- $ this ->orderRepository = $ orderRepository ;
81
- $ this ->criteriaBuilder = $ criteriaBuilder ;
82
- $ this ->customerRegistry = $ customerRegistry ;
83
- $ this ->origDataRegistry = $ origDataRegistry ;
84
- $ this ->sessionCleaner = $ sessionCleaner ;
85
- $ this ->scopeConfig = $ scopeConfig ;
86
- }
42
+ private AnonymizerInterface $ anonymizer ,
43
+ private CustomerRepositoryInterface $ customerRepository ,
44
+ private OrderRepositoryInterface $ orderRepository ,
45
+ private SearchCriteriaBuilder $ criteriaBuilder ,
46
+ private CustomerRegistry $ customerRegistry ,
47
+ private OrigDataRegistry $ origDataRegistry ,
48
+ private SessionCleanerInterface $ sessionCleaner ,
49
+ private ScopeConfigInterface $ scopeConfig
50
+ ) {}
87
51
88
52
/**
89
53
* @inheritdoc
@@ -144,7 +108,12 @@ private function anonymizeCustomer(CustomerInterface $customer): void
144
108
$ secureData ->setData ('lock_expires ' , $ dateTime ->format (DateTimeFormat::DATETIME_PHP_FORMAT ));
145
109
$ secureData ->setPasswordHash (sha1 (uniqid ((string ) mt_rand (), true )));
146
110
147
- $ this ->customerRepository ->save ($ this ->anonymizer ->anonymize ($ customer ));
111
+ $ customer = $ this ->anonymizer ->anonymize ($ customer );
112
+ if ($ customer instanceof DataObject) {
113
+ $ customer ->setData ('ignore_validation_flag ' , true );
114
+ }
115
+
116
+ $ this ->customerRepository ->save ($ customer );
148
117
}
149
118
150
119
private function shouldRemoveCustomerWithoutOrders (): bool
0 commit comments