Comments (7)
Hi @portchris. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release- For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this
- To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel.
π You can find the schedule on the Magento Community Calendar page.
π The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
from magento2.
@magento-admin I am working on this.
from magento2.
Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: π
- 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- 3. Add
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to. - 4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - 5. Add label
Issue: Confirmed
once verification is complete. - 6. Make sure that automatic system confirms that report has been added to the backlog.
from magento2.
Module: Magento_Company
As this appears to be specifically related to Magento B2B companies I have created a patch within the Magento_Company module in order not to disturb the Magento_Customer module (used in other flavours of Adobe Commerce). Here is my patch
--- a/vendor/magento/module-company/Controller/Adminhtml/Customer/Index/MassAssignGroup.php
+++ b/vendor/magento/module-company/Controller/Adminhtml/Customer/Index/MassAssignGroup.php
@@ -0,0 +1,156 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Magento\Company\Controller\Adminhtml\Customer\Index;
+
+use Magento\Backend\App\Action\Context;
+use Magento\Company\Api\Data\CompanyInterface;
+use Magento\Company\Api\CompanyManagementInterface;
+use Magento\Company\Api\CompanyRepositoryInterface;
+use Magento\Company\Model\SaveHandler\CustomerGroup;
+use Magento\Company\Model\Company;
+use Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup as Original;
+use Magento\Eav\Model\Entity\Collection\AbstractCollection;
+use Magento\Framework\Exception\CouldNotSaveException;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
+use Magento\Ui\Component\MassAction\Filter;
+use Magento\Customer\Api\CustomerRepositoryInterface;
+
+class MassAssignGroup extends Original
+{
+ /**
+ * @var Company|null
+ */
+ private ?CompanyInterface $_company;
+
+ /**
+ * @var CustomerGroup
+ */
+ private CustomerGroup $_customerGroup;
+
+ /**
+ * @var CompanyRepositoryInterface
+ */
+ private CompanyRepositoryInterface $_companyRepository;
+
+ /**
+ * @var CompanyManagementInterface
+ */
+ private CompanyManagementInterface $_companyManagement;
+
+ /**
+ * @param Context $context
+ * @param Filter $filter
+ * @param CustomerGroup $customerGroup
+ * @param CollectionFactory $collectionFactory
+ * @param CompanyRepositoryInterface $companyRepository
+ * @param CompanyManagementInterface $companyManagement
+ * @param CustomerRepositoryInterface $customerRepository
+ */
+ public function __construct(
+ Context $context,
+ Filter $filter,
+ CustomerGroup $customerGroup,
+ CollectionFactory $collectionFactory,
+ CompanyRepositoryInterface $companyRepository,
+ CompanyManagementInterface $companyManagement,
+ CustomerRepositoryInterface $customerRepository
+ ) {
+ parent::__construct(
+ $context,
+ $filter,
+ $collectionFactory,
+ $customerRepository
+ );
+
+ $this->_company = null;
+ $this->_customerGroup = $customerGroup;
+ $this->_companyRepository = $companyRepository;
+ $this->_companyManagement = $companyManagement;
+ }
+
+ /**
+ * Add a warning message to the admin attempting to mass assign a customer to a group.
+ *
+ * @param AbstractCollection $collection
+ * @return \Magento\Backend\Model\View\Result\Redirect
+ */
+ protected function massAction(AbstractCollection $collection)
+ {
+ $resultRedirect = parent::massAction($collection);
+ $groupId = $this
+ ->getRequest()
+ ->getParam('group');
+
+ if ($groupId === null) {
+ return $resultRedirect;
+ }
+
+ foreach ($collection->getAllIds() as $customerId) {
+ try {
+ if (!$this->_isCompanyAdmin((int) $customerId)) {
+ $this->messageManager->addWarningMessage(
+ __(
+ "Cannot assign customer %1 to the group %2 because they are not a company admin.",
+ $customerId,
+ $groupId
+ )
+ );
+
+ continue;
+ }
+
+ $company = $companyInitial = $this->_getCompanyByCustomerId((int) $customerId);
+ $company->setCustomerGroupId($groupId);
+ $this->_customerGroup->execute($company, $companyInitial);
+ $this->_companyRepository->save($company);
+ } catch (LocalizedException | NoSuchEntityException | CouldNotSaveException $e) {
+ $this->messageManager->addErrorMessage(
+ __(
+ "Error attempting to assign customer %1 to group %2. %3.",
+ $customerId,
+ $groupId,
+ $e->getMessage()
+ )
+ );
+ }
+ }
+
+ return $resultRedirect;
+ }
+
+ /**
+ * Check if this customer is a company admin, else this operation is not allowed.
+ *
+ * @param int $customerId
+ * @return boolean
+ */
+ private function _isCompanyAdmin(int $customerId): bool
+ {
+ $company = $this->_getCompanyByCustomerId($customerId);
+ if ($company) {
+ $superUserId = (int) $company->getSuperUserId();
+ return $customerId === $superUserId;
+ }
+
+ return false;
+ }
+
+ /**
+ * Return cached company object if already initialised. Otherwise initialise.
+ *
+ * @param int $customerId
+ * @return Company|null
+ */
+ private function _getCompanyByCustomerId(int $customerId): ?CompanyInterface
+ {
+ if ($this->_company === null) {
+ $this->_company = $this->_companyManagement->getByCustomerId($customerId);
+ }
+
+ return $this->_company;
+ }
+}
--- a/vendor/magento/module-company/etc/adminhtml/di.xml
+++ b/vendor/magento/module-company/etc/adminhtml/di.xml
@@ -38,4 +38,8 @@
<type name="Magento\Catalog\Model\Product\ReservedAttributeList">
<plugin name="reservedAttributeListPlugin" type="Magento\Company\Plugin\Catalog\Model\Product\ReservedAttributeListPlugin"/>
</type>
+ <preference
+ for="Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup"
+ type="Magento\Company\Controller\Adminhtml\Customer\Index\MassAssignGroup"
+ />
</config>
Web API
Additionally, I have a patch here that allows the request data not to be reset:
--- a/vendor/magento/module-customer/Model/Plugin/UpdateCustomer.php
+++ b/vendor/magento/module-customer/Model/Plugin/UpdateCustomer.php
@@ -59,6 +59,11 @@
if (!isset($bodyParams['customer']['Id']) && $customerId) {
if ($customerId === $customerSessionId || $customerSessionId === 0) {
$customer = $this->getUpdatedCustomer($customerRepository->getById($customerId), $customer);
+
+ /** @var \Magento\Customer\Model\Data\Customer $customer */
+ foreach ($bodyParams['customer'] as $param => $value) {
+ $customer->setData($param, $value);
+ }
}
}
from magento2.
Hi @portchris,
Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop instance with EE edition and the issue is not reproducible.Kindly refer the screenshots.
![Screenshot 2023-11-20 at 1 25 55 PM](https://private-user-images.githubusercontent.com/51680745/284183760-e35fd53e-a45a-4774-84b6-e0d5e85f339e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUxNTI0MDcsIm5iZiI6MTcwNTE1MjEwNywicGF0aCI6Ii81MTY4MDc0NS8yODQxODM3NjAtZTM1ZmQ1M2UtYTQ1YS00Nzc0LTg0YjYtZTBkNWU4NWYzMzllLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTEzVDEzMjE0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFkMDI3ZTQ1NzE4ODRlZTg1NDk3YmI5NWU1ZDA1Zjc1ZmQ1ZjlmNjUzODBiNDZkNzg1YzllMjg3MWZkN2Q3YzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.UDpVa2d1Oi9wr0uH_0E3wiDXgsFTn2_XjHqQNADRDro)
Customer Group field is not editable.
As per the Magento devdocs only one customer group can be assigned to company at a time we cannot change afterwards.please refer this document https://experienceleague.adobe.com/docs/commerce-admin/b2b/companies/account-company-customer-group.html?lang=en.
![Screenshot 2023-11-20 at 1 23 46 PM](https://private-user-images.githubusercontent.com/51680745/284183442-e6e9bd91-b578-474b-b5a2-bf3c1f2b4f4b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUxNTI0MDcsIm5iZiI6MTcwNTE1MjEwNywicGF0aCI6Ii81MTY4MDc0NS8yODQxODM0NDItZTZlOWJkOTEtYjU3OC00NzRiLWI1YTItYmYzYzFmMmI0ZjRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTEzVDEzMjE0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRhNTQ2MjM4MjVjMjAzMTJlYTZjNTNhZWIwMzRjYjM3MmRiZGMzMmY4ZjMxZmQ2MGM2YWExZjg5ZGEyZWZkY2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.g_sur9chuYll_cSVJDOxBZM8KTuH7tsroRaZp7sSv7g)
Thanks.
from magento2.
Hi @portchris,
Kindly provide latest update on this comment #38187 (comment) still you are working on this issue if you are able to reproduce the issue please elaborate the steps to reproduce.Please let us know still if you are facing any issue.
Thanks.
from magento2.
Hey @engcom-Bravo
If that's the case then perhaps the Mass Action here should be better validated:
Because at the moment what's happening is a success message but nothing happens. It appears as a bug.
My patch (above) By the way accounts for this and throws a warning if the customer is NOT a company admin.
from magento2.
Related Issues (20)
- Columns functionality for \Magento\Theme\Block\Html\Topmenu seems broken HOT 6
- Export Product does not working with Large number of attribute HOT 12
- We are not getting the product_type and parent_item_id inside refund HOT 15
- magento 2 Braintree error verifyCard options must include a BIN. HOT 4
- We are not getting the base_grand_total value in order response HOT 13
- Customer address form allows random code in the name fields HOT 20
- Magento/OfflineShipping/Model/Carrier/Tablerate.php::collectRates is modifying the request for subsequent carriers HOT 8
- [Magento2]- Some amount (in decimal) is missing from total amount of the downloaded order . HOT 9
- Report viewed products does not seem to work correctly HOT 12
- Mass Action sub dropdown is not visible and not coming to the same align with action dropdown HOT 5
- Warning: Trying to access array offset on value of type int in /vendor/magento/framework/Session/Validator.php on line 132 HOT 7
- [Issue] Updated Db.php and Dbp.php HOT 4
- Logging out when new Mega menu item is added HOT 8
- [Issue] Improve configurable attributes and options loading HOT 1
- Slow configurable product attribute option loading HOT 6
- Bug on the product page loading (Catalog>Product) HOT 8
- Attribute option not showing on configurable product detail page HOT 12
- ESI controller generates an issue HOT 10
- AttributeOptionLabelInterfaceFactory not being generated HOT 12
- [Issue] Put division calculations in less files in parentheses if they were not there alr⦠HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magento2.