Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to move/add in bulk clients from one group client to another #72

Merged
merged 8 commits into from
Apr 5, 2021

Conversation

PululuK
Copy link
Contributor

@PululuK PululuK commented Dec 8, 2020

Feature request

Be able to move/add in bulk clients from one group client to another

Specs

To be able to transfer customers from a Group_A group to a Group_B

⚠️ have at least two groups and at least one customer associated with one of the groups

Select groups

1 - be able to select Group_A (group from) : only groups with at least one customer
2 - be able to select Group_B (group to) : The previously selected group must not be in this list.

Select action before

Select an action once the clients of group Group_A have been transferred to group Group_B

1 - Delete Group_A group :  if we choose this option group Group_A will be deleted after transfer

This option is not displayed if Group_A is a Pretashop default group (customer, guest, unidentified)

2 - Remove customers in Group_A group : if we choose this option customers will be removed from the Group_A

⚠️ In both cases (1) and (2), if Group_A was the customer's default group, Group_B became its default group.

3 - Just add to new group : if we choose this option users of group Group_A will be added to group Group_B
4 - Cancel current action : Command exit :)

POC

🎥 Click to see screen record

image

@PululuK
Copy link
Contributor Author

PululuK commented Dec 8, 2020

ping @SebSept @akiletour @jf-viguier

Ready for review :)

@SebSept
Copy link
Contributor

SebSept commented Dec 8, 2020

Thanks for this PR.
Please be patient, before it could be merged, I have lot of work at the moment and I think I'm not the only one in that situation.

@SebSept SebSept added the feature a new feature to implement label Dec 8, 2020
@SebSept
Copy link
Contributor

SebSept commented Dec 8, 2020

Good job 👍🏼
I added a few remarks.
I'll test the code later.

@PululuK PululuK requested a review from SebSept December 9, 2020 21:02
@SebSept
Copy link
Contributor

SebSept commented Dec 9, 2020

Almost done !
Sorry to bother you, it will be nice if you could fix this problems reported by phpstan (level 2 only) :

 ------ ----------------------------------------------------------------------- 
  Line   CustomersGroups.php                                                    
 ------ ----------------------------------------------------------------------- 
  120    Method FOP\Console\Commands\Customers\CustomersGroups::execute()       
         should return int|null but return statement is missing.                
  146    PHPDoc tag @return with type null is incompatible with native type     
         void.                                                                  
  146    PHPDoc tag @throws with type FOP\Console\Commands\Customers\Exception  
         is not subtype of Throwable                                            
  259    PHPDoc tag @param references unknown parameter: $type                  
  357    PHPDoc tag @return with type FOP\Console\Commands\Customers\in is      
         incompatible with native type int.                                     
  357    Return typehint of method                                              
         FOP\Console\Commands\Customers\CustomersGroups::getDefautlLang() has   
         invalid type FOP\Console\Commands\Customers\in.                        
  380    PHPDoc tag @throws with type                                           
         FOP\Console\Commands\Customers\UnexpectedValueException is not         
         subtype of Throwable                                                   
 ------ ----------------------------------------------------------------------- 

 [ERROR] Found 7 errors   

Phpstan will be integrated as a github action and available as a local tool.
So to avoid fixing this warnings, it could be good to fix it before merging.
(for the moment, you can try with https://github.com/PrestaShop/php-dev-tools which is already a dependency of this module, but that's no required, you can use my report above.)

Copy link
Contributor

@SebSept SebSept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for info, do you plan to fix this phpstan warnings ?

@PululuK
Copy link
Contributor Author

PululuK commented Dec 21, 2020

Just for info, do you plan to fix this phpstan warnings ?

Hi @SebSept
I'm sorry. Yes I will fix it.
Thanks

@PululuK
Copy link
Contributor Author

PululuK commented Dec 21, 2020

Hi @SebSept
Can you run phpstan tests again please ?
Thanks

@@ -35,6 +35,11 @@
*/
final class CustomersGroups extends Command
{
public const SUCCESS = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though this constants were available with this symfony version. But they are not.
It's only for later versions.

It's nice that you added it !
(We'll move them to the base command later.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes !
I noticed that in our version they don't exist, that's why I added them in my class. But I think for the sake of reusability we should put them in the Command class.

@SebSept
Copy link
Contributor

SebSept commented Dec 21, 2020

phpstan & php-cs-fixer are happy, Nice :)
I'll run a few tests tomorrow before merging.

Thanks !

@SebSept SebSept self-requested a review December 21, 2020 22:37
@SebSept SebSept changed the title [WIP] Be able to move/add in bulk clients from one group client to another Be able to move/add in bulk clients from one group client to another Dec 21, 2020
@SebSept
Copy link
Contributor

SebSept commented Dec 22, 2020

The error message needs to be more explicit. Why did the command aborted ?
So does the help message.

Feeling lost at this point

@SebSept
Copy link
Contributor

SebSept commented Dec 22, 2020

Also I think that the word "move" is not appropriate.
Because in fact this allows us to add customers from a group to another group.
And, as an option, remove the customer from the source group (so that's a move) but if I choose, "Just add to new group", that's not really a move.

@SebSept
Copy link
Contributor

SebSept commented Jan 5, 2021

@PululuK Can you just add a more explicit message ?
then I'll merge the command if other reviewers are ok.

(I wish I could add the message but I'm not really sure of the error)

Copy link
Contributor

@SebSept SebSept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, the non explicit error message is confusing.
The user deserve to know what was wrong.
I suppose it is related to the fact that there is a need to have users in different groups as mentioned in the PR explanation. But I'm not sure.
Can someone confirm this and write a correct error message ?

I also mention the fact that the command result can be something different than a 'move', user can be added to a group without being removed from the source one.
Because of the current lack of time of reviewer I suggest to merge with this wrong definition.
Unless someone fix it.

@SebSept SebSept added the help wanted Extra attention is needed label Jan 8, 2021
@SebSept
Copy link
Contributor

SebSept commented Jan 11, 2021

Just a last effort to seal your work @PululuK ? 🙏🏼

taken from PR description : "have at least two groups and at least one customer associated with one of the groups.

Signed-off-by: SebSept <sebastienmonterisi@yahoo.fr>
@jf-viguier
Copy link
Member

If we follow naming convention, the command should e named fop:customer:transfert ? or splitted in fop:customer:move and fop:customer:copy ?

@SebSept
Copy link
Contributor

SebSept commented Jan 16, 2021

the "group" concept is important ...
fop:customer:group-change ?

@SebSept SebSept removed the help wanted Extra attention is needed label Jan 17, 2021
@PululuK
Copy link
Contributor Author

PululuK commented Feb 11, 2021

the "group" concept is important ...
fop:customer:group-change ?

Hello I'm back !
Seems good to me ! Or fop:customer:group-manager wdyf @SebSept @jf-viguier ?

@SebSept
Copy link
Contributor

SebSept commented Mar 10, 2021

Personne pour finaliser ça ?

@Mch0
Copy link
Collaborator

Mch0 commented Mar 23, 2021

fop:customer:group-change it's ok for me

Copy link
Collaborator

@Mch0 Mch0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just update name of Command and it's ok

@SebSept
Copy link
Contributor

SebSept commented Mar 24, 2021

Finally I think my proposal (fop:customer:group-change was not good, because the command can leave customer into a group, so they did not changed their group.)

fop:customer:group-manage looks like the best choice.

If anyone has something against that choice, it's time to speak, now or never 😆
I'll make the change and merge on Friday..

@SebSept SebSept merged commit 73436be into friends-of-presta:dev Apr 5, 2021
@SebSept
Copy link
Contributor

SebSept commented Apr 5, 2021

thanks @PululuK (and sorry for the delay).

@PululuK PululuK deleted the add-customer-groups-command branch April 5, 2021 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a new feature to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants