Loki_CompanyAccountAutomaticAssignment
Installation
Install this package via composer:
composer require loki/magento2-company-account-automatic-assignment
Next, enable this module:
bin/magento module:enable Loki_CompanyAccountAutomaticAssignment
Features
This module automatically assigns customers to a company of Loki_CompanyAccounts. When a customer registers, is
saved (frontend, Admin Panel, API) or logs in, all assignment rules are checked. The first rule that returns a company
wins and the customer is added to that company with the configured role. Customers that already belong to a company
are never moved to another company.
Configuration is found under Stores > Configuration > Customers > Company Accounts > Automatic Assignment:
- Enabled: Enable or disable the automatic assignment
- Role: The company role given to automatically assigned customers (default: Buyer)
Email domain rule
Each company has a field Email domains (database column loki_company.email_domain), which contains a
comma-separated list of domains (for instance example.com, example.org). When the domain of a customer email matches
one of these domains (case-insensitive), the customer is added to that company. Only active companies are matched.
Adding your own rules
Create a class implementing Loki\CompanyAccountAutomaticAssignment\Rule\RuleInterface and add it to the rule
listing via etc/di.xml:
<type name="Loki\CompanyAccountAutomaticAssignment\Rule\RuleListing"> <arguments> <argument name="rules" xsi:type="array"> <item name="my_rule" xsi:type="object">Vendor\Module\Rule\MyRule</item> </argument> </arguments> </type>
Current status
@dev
to the composer command.
Support
For getting support, create an Issue under the following project URL:
https://gitlab.yireo.com/loki-extensions/Loki_CompanyAccountAutomaticAssignment.git
Configuration Options
The following options of this module can be configured via the Store Configuration:
loki_company_accounts/automatic_assignment/enabled
loki_company_accounts/automatic_assignment/role
Module Dependencies
The following dependencies are declared in the module its `etc/module.xml` file:
Magento_Customer
Magento_Store
Loki_CompanyAccounts
Composer details
Loki_CompanyAccountAutomaticAssignmentloki/magento2-company-account-automatic-assignment
loki/magento2-company-accounts: *
magento/framework: ^103.0
magento/module-customer: ^103.0
magento/module-store: ^101.0
php: >=8.2 <8.6
psr/log: *
Releases
Changelog
Added
- Dependency on
Loki_CompanyAccounts - DI-based assignment rules (
RuleListingwithRuleInterfaceimplementations) - Email domain rule: assign customers whose email domain matches the company email domains
- Automatic assignment on customer registration, customer save and customer login
- Configuration for enabling the automatic assignment and choosing the assigned role
- Unit and integration tests