From 0d012cccf59176a1cb4e6efb9a6e526909be8f09 Mon Sep 17 00:00:00 2001 From: Margaret Eker Date: Wed, 6 May 2026 14:07:00 -0500 Subject: [PATCH] Editorial updates to comply with style and grammar guidelines --- src/pages/config.md | 1 - .../admin/custom-boolean-field-attribute.md | 22 +++++++++------- .../admin/custom-dropdown-field-attribute.md | 26 +++++++++++-------- .../custom-multiselect-field-attribute.md | 20 ++++++++------ 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/pages/config.md b/src/pages/config.md index 8e413f8b8..6874b799a 100644 --- a/src/pages/config.md +++ b/src/pages/config.md @@ -785,7 +785,6 @@ - [Create a boolean field attribute](/tutorials/admin/custom-boolean-field-attribute.md) - [Create a dropdown field attribute](/tutorials/admin/custom-dropdown-field-attribute.md) - [Create a multiselect field attribute](/tutorials/admin/custom-multiselect-field-attribute.md) - - [Frontend development](/tutorials/frontend/index.md) - [Customize checkout](/tutorials/frontend/custom-checkout/index.md) - [Add a new checkout step](/tutorials/frontend/custom-checkout/add-new-step.md) diff --git a/src/pages/tutorials/admin/custom-boolean-field-attribute.md b/src/pages/tutorials/admin/custom-boolean-field-attribute.md index 12b47f91f..241648139 100644 --- a/src/pages/tutorials/admin/custom-boolean-field-attribute.md +++ b/src/pages/tutorials/admin/custom-boolean-field-attribute.md @@ -9,15 +9,17 @@ keywords: # Add a custom boolean attribute -This tutorial describes how a developer can create a custom boolean (Yes/No) attribute for the Customer entity using code. This will reflect in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. +This tutorial describes how you create a custom boolean (Yes/No) attribute for the Customer entity using code. The attribute appears in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. -This Customer attribute will be used to store a simple Yes/No flag on a customer record, as an example. It will be created as an EAV attribute in a data patch. The EAV model allows a developer to add custom functionality to the entities without modifying the core databases and schemas. Data patches are run just once, so this code will create the custom attribute and will never run again, which could cause issues. This tutorial also implements `PatchRevertableInterface`, which allows the attribute to be cleanly removed by running `bin/magento setup:rollback`. +Use this customer attribute as an example to store a simple Yes/No flag on a customer record. You create it as an EAV attribute in a data patch. The EAV model lets you extend entities without changing core database schemas. Data patches run once, so this code creates the attribute on the first run only. This tutorial also implements `PatchRevertableInterface`, so you can remove the attribute by running `bin/magento setup:rollback`. -## Code +## Data patch implementation + +The following sections show the PHP you add to your module. ### Create the data patch class -Create a data patch class called `AddCustomerAttributeBoolean` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. This makes the application execute the data patch automatically when `bin/magento setup:upgrade` is run. This class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. Adding the revertable interface requires implementing a `revert()` method that removes the attribute when the patch is rolled back. +Create a data patch class called `AddCustomerAttributeBoolean` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. Magento runs this data patch automatically when you run `bin/magento setup:upgrade`. This class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. Adding the revertable interface requires implementing a `revert()` method that removes the attribute when the patch is rolled back. ```php moduleDataSetup->getConnection()->startSetup(); @@ -149,7 +153,7 @@ There are five steps in developing a data patch. All the steps below are written | `is_filterable_in_grid` | `true` - Filterable in the customer grid | | `is_searchable_in_grid` | `false` - Not searchable in the customer grid (boolean fields are filtered, not searched) | -1. Add attribute to an attribute set and group. +1. Add the attribute to an attribute set and group. There is only one attribute set and group for the customer entity. The default attribute set ID is a constant defined in the `CustomerMetadataInterface` interface and setting the attribute group ID to null makes the application use the default attribute group ID for the customer entity. @@ -182,7 +186,7 @@ There are five steps in developing a data patch. All the steps below are written Unlike the text field attribute, which is visible only in the Admin, the boolean attribute is also registered for the storefront registration and account edit forms. Adjust the `used_in_forms` values to match the visibility requirements of your project. -1. Gracefully handle exceptions. +1. Handle exceptions in a try/catch block. ```php try { @@ -217,7 +221,7 @@ public function revert(): void } ``` -### Implement rest of the interface +### Implement the rest of the interface This data patch does not have any other patch as a dependency, and this data patch was not renamed earlier, so both `getDependencies` and `getAliases` can return an empty array. @@ -241,7 +245,7 @@ Run `bin/magento setup:upgrade` from the project root to execute the newly added ![Custom attribute in the customer form](../../images/tutorials/custom-attribute-customer-form.png) -- The attribute is displayed in the customer grid and can be filtered using a Yes/No dropdown. +- The attribute is displayed in the customer grid and can be filtered using a Yes/No dropdown menu. ![Custom attribute in the customer grid](../../images/tutorials/custom-attribute-customer-grid.png) diff --git a/src/pages/tutorials/admin/custom-dropdown-field-attribute.md b/src/pages/tutorials/admin/custom-dropdown-field-attribute.md index 00bed5f33..7ecf1aa0d 100644 --- a/src/pages/tutorials/admin/custom-dropdown-field-attribute.md +++ b/src/pages/tutorials/admin/custom-dropdown-field-attribute.md @@ -9,15 +9,17 @@ keywords: # Add a custom dropdown attribute -This tutorial describes how a developer can create a custom dropdown (select) attribute for the Customer entity using code. This will reflect in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. +This tutorial describes how you create a custom dropdown (select) attribute for the Customer entity using code. The attribute appears in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. -Use a select attribute when you want administrators (and optionally customers) to choose a value from a controlled set of options — for example, a customer tier (Silver/Gold/Platinum) or an internal segmentation flag. The attribute will be created as an EAV attribute in a data patch. This tutorial also implements `PatchRevertableInterface`, which allows the attribute to be cleanly removed by running `bin/magento setup:rollback`. +Use a select attribute when you want administrators (and optionally customers) to choose a value from a controlled set of options. Examples include a customer tier (Silver, Gold, Platinum) or an internal segmentation flag. You create the attribute as an EAV attribute in a data patch. This tutorial also implements `PatchRevertableInterface`, so you can remove the attribute by running `bin/magento setup:rollback`. -## Code +## Data patch implementation + +The following sections show the PHP you add to your module. ### Create the data patch class -Create a data patch class called `AddCustomerAttributeOptions` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. This makes the application execute the data patch automatically when `bin/magento setup:upgrade` is run. Unlike the text field and boolean attribute tutorials, this class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. Adding the revertable interface requires implementing a `revert()` method that removes the attribute when the patch is rolled back. +Create a data patch class called `AddCustomerAttributeOptions` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. Magento runs this data patch automatically when you run `bin/magento setup:upgrade`. Unlike the text field and boolean attribute tutorials, this class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. Adding the revertable interface requires implementing a `revert()` method that removes the attribute when the patch is rolled back. ```php moduleDataSetup->getConnection()->startSetup(); @@ -134,7 +138,7 @@ There are five steps in developing a data patch. All the steps below are written | --- | --- | | `label` | `Customer Custom Attribute Options` - Label for displaying the attribute value | | `type` | `int` - Stores the selected option ID as an integer | - | `input` | `select` - Renders as a dropdown in the customer form | + | `input` | `select` - Renders as a dropdown menu in the customer form | | `source` | Provides the list of selectable options | | `required` | `false` - Attribute will be an optional field in the customer form | | `position` | `444` - Sort order in the customer form | @@ -145,7 +149,7 @@ There are five steps in developing a data patch. All the steps below are written | `is_filterable_in_grid` | `true` - Filterable in the customer grid | | `is_searchable_in_grid` | `false` - Not searchable in the customer grid (dropdown fields are filtered by option, not free-text searched) | -1. Add attribute to an attribute set and group. +1. Add the attribute to an attribute set and group. There is only one attribute set and group for the customer entity. The default attribute set ID is a constant defined in the `CustomerMetadataInterface` interface and setting the attribute group ID to null makes the application use the default attribute group ID for the customer entity. @@ -176,7 +180,7 @@ There are five steps in developing a data patch. All the steps below are written $this->attributeResource->save($attribute); ``` -1. Gracefully handle exceptions. +1. Handle exceptions in a try/catch block. ```php try { @@ -211,7 +215,7 @@ public function revert(): void } ``` -### Implement rest of the interface +### Implement the rest of the interface This data patch does not have any other patch as a dependency, and this data patch was not renamed earlier, so both `getDependencies` and `getAliases` can return an empty array. @@ -235,7 +239,7 @@ Run `bin/magento setup:upgrade` from the project root to execute the newly added ![Custom attribute in the customer form](../../images/tutorials/custom-attribute-customer-form.png) -- The attribute is displayed in the customer grid and can be filtered using a dropdown of available options. +- The attribute is displayed in the customer grid and can be filtered using a dropdown menu of available options. ![Custom attribute in the customer grid](../../images/tutorials/custom-attribute-customer-grid.png) diff --git a/src/pages/tutorials/admin/custom-multiselect-field-attribute.md b/src/pages/tutorials/admin/custom-multiselect-field-attribute.md index bb743ea7c..335989201 100644 --- a/src/pages/tutorials/admin/custom-multiselect-field-attribute.md +++ b/src/pages/tutorials/admin/custom-multiselect-field-attribute.md @@ -9,15 +9,17 @@ keywords: # Add a custom multiselect attribute -This tutorial describes how a developer can create a custom multiselect attribute for the Customer entity using code. This will reflect in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. +This tutorial describes how you create a custom multiselect attribute for the Customer entity using code. The attribute appears in both the [Customer Grid](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/manage-account) and the [Customer Form](https://experienceleague.adobe.com/en/docs/commerce-admin/customers/customer-accounts/manage/update-account) in the Admin. -Use a multiselect attribute when you need to store multiple simultaneous values for a single customer field — for example, eligible shipping methods, allowed sales channels, or subscription preferences. Unlike the [dropdown attribute](custom-dropdown-field-attribute.md), which stores a single selected option ID as an integer, a multiselect attribute stores a comma-separated list of option IDs as a `varchar` value, handled by the `ArrayBackend` backend model. This tutorial also implements `PatchRevertableInterface`, which allows the attribute to be cleanly removed by running `bin/magento setup:rollback`. +Use a multiselect attribute when you need to store multiple simultaneous values for a single customer field. Examples include eligible shipping methods, allowed sales channels, or subscription preferences. Unlike the [dropdown attribute](custom-dropdown-field-attribute.md), a dropdown stores one selected option ID as an integer. A multiselect stores a comma-separated list of option IDs in a `varchar` value. Magento uses the `ArrayBackend` backend model to manage that storage. This tutorial also implements `PatchRevertableInterface`, so you can remove the attribute by running `bin/magento setup:rollback`. -## Code +## Data patch implementation + +The following sections show the PHP code you add to your module. ### Create the data patch class -Create a data patch class called `AddCustomerAttributeMultipleOptions` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. This makes the application execute the data patch automatically when `bin/magento setup:upgrade` is run. This class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. +Create a data patch class called `AddCustomerAttributeMultipleOptions` under the `\ExampleCorp\Customer\Setup\Patch\Data` namespace. Magento runs this data patch automatically when you run `bin/magento setup:upgrade`. This class implements both `\Magento\Framework\Setup\Patch\DataPatchInterface` and `\Magento\Framework\Setup\Patch\PatchRevertableInterface`. ```php moduleDataSetup->getConnection()->startSetup(); @@ -147,7 +151,7 @@ There are five steps in developing a data patch. All the steps below are written | `is_filterable_in_grid` | `true` - Filterable in the customer grid | | `is_searchable_in_grid` | `false` - Not searchable in the customer grid (multiselect fields are filtered by option, not free-text searched) | -1. Add attribute to an attribute set and group. +1. Add the attribute to an attribute set and group. There is only one attribute set and group for the customer entity. The default attribute set ID is a constant defined in the `CustomerMetadataInterface` interface and setting the attribute group ID to null makes the application use the default attribute group ID for the customer entity. @@ -178,7 +182,7 @@ There are five steps in developing a data patch. All the steps below are written $this->attributeResource->save($attribute); ``` -1. Gracefully handle exceptions. +1. Handle exceptions in a try/catch block. ```php try { @@ -213,7 +217,7 @@ public function revert(): void } ``` -### Implement rest of the interface +### Implement the rest of the interface This data patch does not have any other patch as a dependency, and this data patch was not renamed earlier, so both `getDependencies` and `getAliases` can return an empty array.