Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hello fellow Sprykers, I have an issue that might as well be a bug. If a company user is deleted fro

Options
U03EDGXUTPH
U03EDGXUTPH Posts: 36 🧑🏻‍🚀 - Cadet
edited March 2023 in Help

Hello fellow Sprykers, I have an issue that might as well be a bug. If a company user is deleted from Yves (by a company user admin), the customer account is then anonymized and then we can create a new account with the same address.
In Zed/Backoffice, through business On Behalf, you delete a company user, and then it’s not removed nor anonymized, so we can’t create an account with the same address.
Do you think this is expected behaviour? I assume it’s a bug, or I’m missing certain functionality.
(This is with the default b2b shop v 202212.0-p1)

Comments

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    In \Spryker\Zed\CompanyUser\Business\Model\CompanyUser::delete the company user is deleted and after that the customer is anonymized...

        /**
         * @param \Generated\Shared\Transfer\CompanyUserTransfer $companyUserTransfer
         *
         * @return \Generated\Shared\Transfer\CompanyUserResponseTransfer
         */
        public function delete(CompanyUserTransfer $companyUserTransfer): CompanyUserResponseTransfer
        {
            return $this->getTransactionHandler()->handleTransaction(function () use ($companyUserTransfer) {
                $this->companyUserPluginExecutor->executePreDeletePlugins($companyUserTransfer);
    
                $companyUserTransfer = $this->companyUserRepository->getCompanyUserById(
                    $companyUserTransfer->getIdCompanyUser(),
                );
    
                $this->companyUserEntityManager->deleteCompanyUserById($companyUserTransfer->getIdCompanyUser());
                $this->customerFacade->anonymizeCustomer($companyUserTransfer->getCustomer());
    
                return (new CompanyUserResponseTransfer())->setIsSuccessful(true);
            });
        }
    

    from what I see, it's not possible for what you described to happen....

    On Behalf it means of course that the customer can be related to more than one company and in this case have more company-user relation... in this case can be possible that the customer cannot be anonymized.. but i am not sure where spryker check this case.. u have to start to investigate from here
    \Spryker\Zed\CompanyUser\Business\Model\CompanyUser::delete and \Spryker\Zed\BusinessOnBehalfGui\Communication\Controller\DeleteCompanyUserController::deleteAction if u use BusinessOnBehalfGui otherwise \Spryker\Zed\CompanyUserGui\Communication\Controller\DeleteCompanyUserController::deleteAction