diff --git a/vendor/magento/module-company/Model/CompanyFieldPool.php b/vendor/magento/module-company/Model/CompanyFieldPool.php
new file mode 100644
index 000000000000..114b1f48de30
--- /dev/null
+++ b/vendor/magento/module-company/Model/CompanyFieldPool.php
@@ -0,0 +1,43 @@
+fields);
+ }
+}
diff --git a/vendor/magento/module-company/Model/CompanyProfile.php b/vendor/magento/module-company/Model/CompanyProfile.php
index 8b02318a6f61..77cc55506c35 100644
--- a/vendor/magento/module-company/Model/CompanyProfile.php
+++ b/vendor/magento/module-company/Model/CompanyProfile.php
@@ -42,12 +42,22 @@ class CompanyProfile
* @param CompanyContext $companyContext
* @param DataObjectHelper $objectHelper
* @param UserContextInterface $userContext
+ * @param CompanyFieldPool|null $companyProfileFieldPool
+ * @param CompanyFieldPool|null $companyAddressFieldPool
*/
public function __construct(
private readonly CompanyContext $companyContext,
private readonly DataObjectHelper $objectHelper,
private readonly UserContextInterface $userContext,
+ ?CompanyFieldPool $companyProfileFieldPool = null,
+ ?CompanyFieldPool $companyAddressFieldPool = null,
) {
+ if ($companyProfileFieldPool !== null) {
+ $this->companyProfileFields = $companyProfileFieldPool->getFields();
+ }
+ if ($companyAddressFieldPool !== null) {
+ $this->companyAddressFields = $companyAddressFieldPool->getFields();
+ }
}
/**
@@ -79,16 +89,13 @@ public function filterDataBasedOnCompanyAclPermissions(array $data): array
// company ACL permissions only apply in the storefront customer context
return $data;
}
- if (!$this->companyContext->isResourceAllowed('Magento_Company::edit_account')) {
- foreach ($this->companyProfileFields as $field) {
- unset($data[$field]);
- }
+ $allowedFields = [];
+ if ($this->companyContext->isResourceAllowed('Magento_Company::edit_account')) {
+ $allowedFields = array_merge($allowedFields, $this->companyProfileFields);
}
- if (!$this->companyContext->isResourceAllowed('Magento_Company::edit_address')) {
- foreach ($this->companyAddressFields as $field) {
- unset($data[$field]);
- }
+ if ($this->companyContext->isResourceAllowed('Magento_Company::edit_address')) {
+ $allowedFields = array_merge($allowedFields, $this->companyAddressFields);
}
- return $data;
+ return array_intersect_key($data, array_flip($allowedFields));
}
}
diff --git a/vendor/magento/module-company/etc/di.xml b/vendor/magento/module-company/etc/di.xml
index 85704cec9e1b..cf9fe0d45f54 100755
--- a/vendor/magento/module-company/etc/di.xml
+++ b/vendor/magento/module-company/etc/di.xml
@@ -307,4 +307,34 @@
+
+
+
+ - company_name
+ - legal_name
+ - company_email
+ - vat_tax_id
+ - reseller_id
+
+
+
+
+
+
+ - street
+ - city
+ - country_id
+ - region_id
+ - region
+ - postcode
+ - telephone
+
+
+
+
+
+ companyProfileFieldPool
+ companyAddressFieldPool
+
+