@@ -234,11 +234,14 @@ public function execute()
234234 $ customer = $ this ->getCustomerDataObject ($ this ->session ->getCustomerId ());
235235 $ customerCandidate = $ this ->populateNewCustomerDataObject ($ this ->_request , $ customer );
236236
237- $ attributeToDelete = $ this ->_request ->getParam ('delete_attribute_value ' );
238- if ((string )$ attributeToDelete !== "" ) {
239- $ uploadedValue = $ this ->_request ->getParam ($ attributeToDelete . File::UPLOADED_FILE_SUFFIX );
240- if ((string )$ uploadedValue === "" ) {
241- $ this ->deleteCustomerFileAttribute ($ customerCandidate , $ attributeToDelete );
237+ $ attributeToDelete = (string )$ this ->_request ->getParam ('delete_attribute_value ' );
238+ if ($ attributeToDelete !== "" ) {
239+ $ attributesToDelete = $ this ->prepareAttributesToDelete ($ attributeToDelete );
240+ foreach ($ attributesToDelete as $ attribute ) {
241+ $ uploadedValue = $ this ->_request ->getParam ($ attribute . File::UPLOADED_FILE_SUFFIX );
242+ if ((string )$ uploadedValue === "" ) {
243+ $ this ->deleteCustomerFileAttribute ($ customerCandidate , $ attribute );
244+ }
242245 }
243246 }
244247
@@ -304,6 +307,26 @@ public function execute()
304307 return $ resultRedirect ;
305308 }
306309
310+ /**
311+ * Convert comma-separated list of attributes to delete into array
312+ *
313+ * @param string $attribute
314+ * @return array
315+ */
316+ private function prepareAttributesToDelete (string $ attribute ) : array
317+ {
318+ $ result = [];
319+ if ($ attribute !== "" ) {
320+ if (str_contains ($ attribute , ', ' )) {
321+ $ result = explode (', ' , $ attribute );
322+ } else {
323+ $ result [] = $ attribute ;
324+ }
325+ $ result = array_unique ($ result );
326+ }
327+ return $ result ;
328+ }
329+
307330 /**
308331 * Adds a complex success message if email confirmation is required
309332 *
@@ -472,11 +495,7 @@ private function deleteCustomerFileAttribute(
472495 string $ attributeToDelete
473496 ) : void {
474497 if ($ attributeToDelete !== '' ) {
475- if (strpos ($ attributeToDelete , ', ' ) !== false ) {
476- $ attributes = explode (', ' , $ attributeToDelete );
477- } else {
478- $ attributes [] = $ attributeToDelete ;
479- }
498+ $ attributes = $ this ->prepareAttributesToDelete ($ attributeToDelete );
480499 foreach ($ attributes as $ attr ) {
481500 $ attributeValue = $ customerCandidateDataObject ->getCustomAttribute ($ attr );
482501 if ($ attributeValue !== null ) {
0 commit comments