|
1 |
| -The Magento_Customer module serves to handle the customer data (Customer, Customer Address and Customer Group entities) both in the admin panel and the storefront. |
| 1 | +# Magento_Customer module |
| 2 | + |
| 3 | +This module serves to handle the customer data (Customer, Customer Address and Customer Group entities) both in the admin panel and the storefront. |
2 | 4 | For customer passwords, the module implements upgrading hashes.
|
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +The Magento_Customer module is one of the base Magento 2 modules. You cannot disable or uninstall this module. |
| 9 | +This module is dependent on the following modules: |
| 10 | + |
| 11 | +- `Magento_Eav` |
| 12 | +- `Magento_Directory` |
| 13 | + |
| 14 | +The following modules depend on this module: |
| 15 | +- `Magento_Captcha` |
| 16 | +- `Magento_Catalog` |
| 17 | +- `Magento_CatalogCustomerGraphQl` |
| 18 | +- `Magento_CatalogRule` |
| 19 | +- `Magento_CompareListGraphQl` |
| 20 | +- `Magento_CustomerAnalytics` |
| 21 | +- `Magento_CustomerGraphQl` |
| 22 | +- `Magento_EncryptionKey` |
| 23 | +- `Magento_LoginAsCustomerGraphQl` |
| 24 | +- `Magento_NewRelicReporting` |
| 25 | +- `Magento_ProductAlert` |
| 26 | +- `Magento_Reports` |
| 27 | +- `Magento_Sales` |
| 28 | +- `Magento_Swatches` |
| 29 | +- `Magento_Tax` |
| 30 | +- `Magento_Wishlist` |
| 31 | +- `Magento_WishlistGraphQl` |
| 32 | + |
| 33 | +The Magento_Customer module creates the following tables in the database: |
| 34 | +- `customer_entity` |
| 35 | +- `customer_entity_datetime` |
| 36 | +- `customer_entity_decimal` |
| 37 | +- `customer_entity_int` |
| 38 | +- `customer_entity_text` |
| 39 | +- `customer_entity_varchar` |
| 40 | +- `customer_address_entity` |
| 41 | +- `customer_address_entity_datetime` |
| 42 | +- `customer_address_entity_decimal` |
| 43 | +- `customer_address_entity_int` |
| 44 | +- `customer_address_entity_text` |
| 45 | +- `customer_address_entity_varchar` |
| 46 | +- `customer_group` |
| 47 | +- `customer_eav_attribute` |
| 48 | +- `customer_form_attribute` |
| 49 | +- `customer_eav_attribute_website` |
| 50 | +- `customer_visitor` |
| 51 | +- `customer_log` |
| 52 | + |
| 53 | +For information about a module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-subcommands-enable.html). |
| 54 | + |
| 55 | +## Extensibility |
| 56 | + |
| 57 | +Extension developers can interact with the Magento_Customer module. For more information about the Magento extension mechanism, see [Magento plugins](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/plugins.html). |
| 58 | + |
| 59 | +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_Customer module. |
| 60 | + |
| 61 | +A lot of functionality in the module is on JavaScript, use [mixins](https://devdocs.magento.com/guides/v2.4/javascript-dev-guide/javascript/js_mixins.html) to extend it. |
| 62 | + |
| 63 | +### Events |
| 64 | + |
| 65 | +The module dispatches the following events: |
| 66 | + |
| 67 | +#### Block |
| 68 | +- `adminhtml_block_html_before` event in the `\Magento\Customer\Block\Adminhtml\Edit\Tab\Carts::_toHtml` method. Parameters: |
| 69 | + - `block` is a `$this` object (`Magento\Customer\Block\Adminhtml\Edit\Tab\Carts` class) |
| 70 | + |
| 71 | +#### Controller |
| 72 | +- `customer_register_success` event in the `\Magento\Customer\Controller\Account\CreatePost::execute` method. Parameters: |
| 73 | + - `account_controller` is a `$this` object (`\Magento\Customer\Controller\Account\CreatePost` class) |
| 74 | + - `customer` is a customer object (`\Magento\Customer\Model\Data\Customer` class) |
| 75 | + |
| 76 | +- `customer_account_edited` event in the `\Magento\Customer\Controller\Account\EditPost::dispatchSuccessEvent` method. Parameters: |
| 77 | + - `email` is a customer email (`string` type) |
| 78 | + |
| 79 | +- `adminhtml_customer_prepare_save` event in the `\Magento\Customer\Controller\Adminhtml\Index\Save::execute` method. Parameters: |
| 80 | + - `customer` is a customer object to be saved (`\Magento\Customer\Model\Data\Customer` class) |
| 81 | + - `request` is a request object with the `\Magento\Framework\App\RequestInterface` interface. |
| 82 | + |
| 83 | +- `adminhtml_customer_save_after` event in the `\Magento\Customer\Controller\Adminhtml\Index\Save::execute` method. Parameters: |
| 84 | + - `customer` is a customer object (`\Magento\Customer\Model\Data\Customer` class) |
| 85 | + - `request` is a request object with the `\Magento\Framework\App\RequestInterface` interface. |
| 86 | + |
| 87 | +#### Model |
| 88 | +- `customer_customer_authenticated` event in the `\Magento\Customer\Model\AccountManagement::authenticate` method. Parameters: |
| 89 | + - `model` is a customer object (`\Magento\Customer\Model\Customer` class) |
| 90 | + - `password` is a customer password (`string` type) |
| 91 | + |
| 92 | +- `customer_data_object_login` event in the `\Magento\Customer\Model\AccountManagement::authenticate` method. Parameters: |
| 93 | + - `customer` is a customer object (`\Magento\Customer\Model\Data\Customer` class) |
| 94 | + |
| 95 | +- `customer_address_format` event in the `\Magento\Customer\Model\Address\AbstractAddress::format` method. Parameters: |
| 96 | + - `type` is a address format type (`string` type) |
| 97 | + - `address` is a `$this` object (`\Magento\Customer\Model\Address\AbstractAddress` class) |
| 98 | + |
| 99 | +- `customer_customer_authenticated` event in the `\Magento\Customer\Model\Customer::authenticate` method. Parameters: |
| 100 | + - `model` is a customer object (`\Magento\Customer\Model\Customer` class) |
| 101 | + - `password` is a customer password (`string` type) |
| 102 | + |
| 103 | +- `customer_save_after_data_object` event in the `\Magento\Customer\Model\ResourceModel\CustomerRepository::save` method. Parameters: |
| 104 | + - `customer_data_object` is a saved customer object (`\Magento\Customer\Model\Data\Customer` class) |
| 105 | + - `orig_customer_data_object` is a previous customer object (`\Magento\Customer\Model\Data\Customer` class) |
| 106 | + - `delegate_data` is a customer additional data (`array` type) |
| 107 | + |
| 108 | +- `customer_session_init` event in the `\Magento\Customer\Model\Session::__construct` method. Parameters: |
| 109 | + - `customer_session` is a `$this` object (`\Magento\Customer\Model\Session` class) |
| 110 | + |
| 111 | +- `customer_login` event in the `\Magento\Customer\Model\Session::setCustomerAsLoggedIn` method. Parameters: |
| 112 | + - `customer` is a `$this` object (`\Magento\Customer\Model\Customer` class) |
| 113 | + |
| 114 | +- `customer_data_object_login` event in the `\Magento\Customer\Model\Session::setCustomerAsLoggedIn` method. Parameters: |
| 115 | + - `customer` is a `$this` object (`\Magento\Customer\Model\Data\Customer` class) |
| 116 | + |
| 117 | +- `customer_login` event in the `\Magento\Customer\Model\Session::setCustomerDataAsLoggedIn` method. Parameters: |
| 118 | + - `customer` is a `$this` object (`\Magento\Customer\Model\Customer` class) |
| 119 | + |
| 120 | +- `customer_data_object_login` event in the `\Magento\Customer\Model\Session::setCustomerDataAsLoggedIn` method. Parameters: |
| 121 | + - `customer` is a `$this` object (`\Magento\Customer\Model\Data\Customer` class) |
| 122 | + |
| 123 | +- `customer_logout` event in the `\Magento\Customer\Model\Session::logout` method. Parameters: |
| 124 | + - `customer` is a `$this` object (`\Magento\Customer\Model\Customer` class) |
| 125 | + |
| 126 | +- `visitor_init` event in the `\Magento\Customer\Model\Visitor::logout` method. Parameters: |
| 127 | + - `visitor` is a `$this` object (`\Magento\Customer\Model\Visitor` class) |
| 128 | + |
| 129 | +- `visitor_activity_save` event in the `\Magento\Customer\Model\Visitor::saveByRequest` method. Parameters: |
| 130 | + - `visitor` is a `$this` object (`\Magento\Customer\Model\Visitor` class) |
| 131 | + |
| 132 | +For information about an event in Magento 2, see [Events and observers](http://devdocs.magento.com/guides/v2.4/extension-dev-guide/events-and-observers.html#events). |
| 133 | + |
| 134 | +### Layouts |
| 135 | + |
| 136 | +This module introduces the following layouts in the `view/frontend/layout` and `view/adminhtml/layout` directories: |
| 137 | +- `view/adminhtml/layout`: |
| 138 | + - `customer_address_edit` |
| 139 | + - `customer_group_index` |
| 140 | + - `customer_index_cart` |
| 141 | + - `customer_index_carts` |
| 142 | + - `customer_index_edit` |
| 143 | + - `customer_index_index` |
| 144 | + - `customer_index_newsletter` |
| 145 | + - `customer_index_orders` |
| 146 | + - `customer_index_viewcart` |
| 147 | + - `customer_index_viewwishlist` |
| 148 | + - `customer_online_index` |
| 149 | + |
| 150 | +- `view/frontend/layout`: |
| 151 | + - `customer_account` |
| 152 | + - `customer_account_confirmation` |
| 153 | + - `customer_account_create` |
| 154 | + - `customer_account_createpassword` |
| 155 | + - `customer_account_edit` |
| 156 | + - `customer_account_forgotpassword` |
| 157 | + - `customer_account_index` |
| 158 | + - `customer_account_login` |
| 159 | + - `customer_account_logoutsuccess` |
| 160 | + - `customer_address_index` |
| 161 | + - `default` |
| 162 | + |
| 163 | +For more information about a layout in Magento 2, see the [Layout documentation](https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/layouts/layout-overview.html). |
| 164 | + |
| 165 | +### Public APIs |
| 166 | + |
| 167 | +#### Data |
| 168 | + |
| 169 | +- `\Magento\Customer\Api\Data\AddressInterface`: |
| 170 | + - customer address data |
| 171 | + |
| 172 | +- `\Magento\Customer\Api\Data\AddressSearchResultsInterface`: |
| 173 | + - customer address search result data |
| 174 | + |
| 175 | +- `\Magento\Customer\Api\Data\AttributeMetadataInterface`: |
| 176 | + - customer attribute metadata |
| 177 | + |
| 178 | +- `\Magento\Customer\Api\Data\CustomerInterface`: |
| 179 | + - customer data |
| 180 | + |
| 181 | +- `\Magento\Customer\Api\Data\CustomerSearchResultsInterface`: |
| 182 | + - customer search result data |
| 183 | + |
| 184 | +- `\Magento\Customer\Api\Data\GroupInterface`: |
| 185 | + - customer group data |
| 186 | + |
| 187 | +- `\Magento\Customer\Api\Data\GroupSearchResultsInterface`: |
| 188 | + - customer group search result data |
| 189 | + |
| 190 | +- `\Magento\Customer\Api\Data\OptionInterface`: |
| 191 | + - option data |
| 192 | + |
| 193 | +- `\Magento\Customer\Api\Data\RegionInterface`: |
| 194 | + - customer address region data |
| 195 | + |
| 196 | +- `\Magento\Customer\Api\Data\ValidationResultsInterface`: |
| 197 | + - validation results data |
| 198 | + |
| 199 | +- `\Magento\Customer\Api\Data\ValidationRuleInterface`: |
| 200 | + - validation rule data |
| 201 | + |
| 202 | +#### Metadata |
| 203 | + |
| 204 | +- `\Magento\Customer\Api\MetadataInterface`: |
| 205 | + - retrieve all attributes filtered by form code |
| 206 | + - retrieve attribute metadata by attribute code |
| 207 | + - get all attribute metadata |
| 208 | + - get custom attributes metadata for the given data interface |
| 209 | + |
| 210 | +- `\Magento\Customer\Api\MetadataManagementInterface`: |
| 211 | + - check whether attribute is searchable in admin grid and it is allowed |
| 212 | + - check whether attribute is filterable in admin grid and it is allowed |
| 213 | + |
| 214 | +#### Customer address |
| 215 | + |
| 216 | +- `\Magento\Customer\Api\AddressMetadataInterface`: |
| 217 | + - retrieve information about customer address attributes metadata |
| 218 | + - extends `Magento\Customer\MetadataInterface` |
| 219 | + |
| 220 | +- `\Magento\Customer\Api\AddressMetadataManagementInterface`: |
| 221 | + - manage customer address attributes metadata |
| 222 | + - extends `Magento\Customer\Api\MetadataManagementInterface` |
| 223 | + |
| 224 | +- `\Magento\Customer\Api\AddressRepositoryInterface`: |
| 225 | + - save customer address |
| 226 | + - get customer address by address ID |
| 227 | + - retrieve customers addresses matching the specified criteria |
| 228 | + - delete customer address |
| 229 | + - delete customer address by address ID |
| 230 | + |
| 231 | +- `\Magento\Customer\Model\Address\AddressModelInterface` |
| 232 | + - get street line by number |
| 233 | + - create fields street1, street2, etc |
| 234 | + |
| 235 | +- `\Magento\Customer\Model\Address\ValidatorInterface` |
| 236 | + - validate address instance |
| 237 | + |
| 238 | +- `\Magento\Customer\Model\Address\CustomAttributeListInterface` |
| 239 | + - retrieve list of customer addresses custom attributes |
| 240 | + |
| 241 | +#### Customer |
| 242 | + |
| 243 | +- `\Magento\Customer\Api\AccountManagementInterface`: |
| 244 | + - create customer account |
| 245 | + - create customer account using provided hashed password |
| 246 | + - validate customer data |
| 247 | + - check if customer can be deleted |
| 248 | + - activate a customer account using customer EMAIL and key that was sent in a confirmation email |
| 249 | + - activate a customer account using customer ID and key that was sent in a confirmation email |
| 250 | + - authenticate a customer by username and password |
| 251 | + - change customer password by customer EMAIL |
| 252 | + - change customer password by customer ID |
| 253 | + - send an email to the customer with a password reset link |
| 254 | + - reset customer password |
| 255 | + - check if password reset token is valid |
| 256 | + - gets the account confirmation status |
| 257 | + - resend confirmation email |
| 258 | + - check if given email is associated with a customer account in given website |
| 259 | + - check store availability for customer given the customer ID |
| 260 | + - retrieve default billing address for the given customer ID |
| 261 | + - retrieve default shipping address for the given customer ID |
| 262 | + - get hashed password |
| 263 | + |
| 264 | +- `\Magento\Customer\Api\CustomerManagementInterface`: |
| 265 | + - provide the number of customer count |
| 266 | + |
| 267 | +- `\Magento\Customer\Api\CustomerMetadataInterface`: |
| 268 | + - retrieve information about customer attributes metadata |
| 269 | + - extends `Magento\Customer\MetadataInterface` |
| 270 | + |
| 271 | +- `\Magento\Customer\Api\CustomerMetadataManagementInterface`: |
| 272 | + - manage customer attributes metadata |
| 273 | + - extends `Magento\Customer\Api\MetadataManagementInterface` |
| 274 | + |
| 275 | +- `\Magento\Customer\Api\CustomerNameGenerationInterface`: |
| 276 | + - concatenate all customer name parts into full customer name |
| 277 | + |
| 278 | +- `\Magento\Customer\Api\CustomerRepositoryInterface`: |
| 279 | + - create or update a customer |
| 280 | + - get customer by customer EMAIL |
| 281 | + - get customer by customer ID |
| 282 | + - retrieve customers which match a specified criteria |
| 283 | + - delete customer |
| 284 | + - delete customer by customer ID |
| 285 | + |
| 286 | +- `\Magento\Customer\Model\AuthenticationInterface`: |
| 287 | + - process customer authentication failure by customer ID |
| 288 | + - unlock customer by customer ID |
| 289 | + - check if a customer is locked by customer ID |
| 290 | + - authenticate customer by customer ID and password |
| 291 | + |
| 292 | +- `\Magento\Customer\Model\EmailNotificationInterface`: |
| 293 | + - send notification to customer when email and/or password changed |
| 294 | + - send email with new customer password |
| 295 | + - send email with reset password confirmation link |
| 296 | + - send email with new account related information |
| 297 | + |
| 298 | +#### Customer group |
| 299 | + |
| 300 | +- `\Magento\Customer\Api\CustomerGroupConfigInterface`: |
| 301 | + - set system default customer group |
| 302 | + |
| 303 | +- `\Magento\Customer\Api\GroupManagementInterface`: |
| 304 | + - check if customer group can be deleted |
| 305 | + - get default customer group |
| 306 | + - get customer group representing customers not logged in |
| 307 | + - get all customer groups except group representing customers not logged in |
| 308 | + - get customer group representing all customers |
| 309 | + |
| 310 | +- `\Magento\Customer\Api\GroupRepositoryInterface`: |
| 311 | + - save customer group |
| 312 | + - get customer group by group ID |
| 313 | + - retrieve customer groups which match a specified criteria |
| 314 | + - delete customer group |
| 315 | + - delete customer group by ID |
| 316 | + |
| 317 | +- `\Magento\Customer\Model\Group\RetrieverInterface` |
| 318 | + - get current customer group id from session |
| 319 | + |
| 320 | +- `\Magento\Customer\Model\Customer\Source\GroupSourceLoggedInOnlyInterface` |
| 321 | + - get customer group attribute source |
| 322 | + |
| 323 | +For information about a public API in Magento 2, see [Public interfaces & APIs](http://devdocs.magento.com/guides/v2.4/extension-dev-guide/api-concepts.html). |
| 324 | + |
| 325 | +### UI components |
| 326 | + |
| 327 | +You can extend customer and customer address updates using the configuration files located in the `view/adminhtml/ui_component` and `view/base/ui_component` directories: |
| 328 | +- `view/adminhtml/ui_component`: |
| 329 | + - `customer_address_form` |
| 330 | + - `customer_address_listing` |
| 331 | + - `customer_group_listing` |
| 332 | + - `customer_listing` |
| 333 | + - `customer_online_grid` |
| 334 | + |
| 335 | +- `view/base/ui_component`: |
| 336 | + - `customer_form` |
| 337 | + |
| 338 | +For information about a UI component in Magento 2, see [Overview of UI components](http://devdocs.magento.com/guides/v2.4/ui_comp_guide/bk-ui_comps.html). |
| 339 | + |
| 340 | +## Additional information |
| 341 | + |
| 342 | +More information can get at articles: |
| 343 | +- [Customer Configurations](https://docs.magento.com/user-guide/configuration/customers/customer-configuration.html) |
| 344 | +- [Customer Attributes](https://docs.magento.com/user-guide/stores/attributes-customer.html) |
| 345 | +- [Customer Address Attributes](https://docs.magento.com/user-guide/stores/attributes-customer-address.html) |
| 346 | +- [EAV And Extension Attributes](https://devdocs.magento.com/guides/v2.4/extension-dev-guide/attributes.html) |
| 347 | +- [2.4.x Release information](https://devdocs.magento.com/guides/v2.4/release-notes/bk-release-notes.html) |
| 348 | + |
| 349 | +### Console commands |
| 350 | + |
| 351 | +Magento_Customer provides console commands: |
| 352 | +- `bin/magento customer:hash:upgrade` - upgrades a customer password hash to the latest hash algorithm |
| 353 | + |
| 354 | +### Cron options |
| 355 | + |
| 356 | +Cron group configuration can be set at `etc/crontab.xml`: |
| 357 | +- `visitor_clean` - clean visitor's outdated records |
| 358 | + |
| 359 | +[Learn how to configure and run cron in Magento.](http://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html). |
| 360 | + |
| 361 | +### Indexers |
| 362 | + |
| 363 | +This module introduces the following indexers: |
| 364 | +- `customer_grid` - customer grid indexer |
| 365 | + |
| 366 | +[Learn how to manage the indexers](https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-index.html). |
0 commit comments