Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 941cacb

Browse files
atwixfirsterAlex Taranovskyikeharper
authored
magento/devdocs#: Update "Copying fieldsets" documentation (#8122)
* magento/devdocs#: Update "Copying fieldsets" documentation https://devdocs.magento.com/guides/v2.4/ext-best-practices/tutorials/copy-fieldsets.html * Update copy-fieldsets.md Co-authored-by: Alex Taranovskyi <a.taranovskyi@atwix.com> Co-authored-by: Kevin Harper <keharper@users.noreply.github.com>
1 parent 486c85f commit 941cacb

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/guides/v2.3/ext-best-practices/tutorials/copy-fieldsets.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ The code snippet in the next step uses the name of the fieldset and aspect to sp
3636

3737
**etc/fieldset.xml:**
3838

39+
The following example shows how to copy `sales_convert_quote`.`demo` to `sales_order`.`demo`.
40+
3941
```xml
4042
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4143
xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
@@ -49,6 +51,42 @@ The code snippet in the next step uses the name of the fieldset and aspect to sp
4951
</config>
5052
```
5153

54+
Use the `targetField` attribute to specify the destination field. The following example shows how to copy `sales_convert_quote`.`demo` to `sales_order`.`order_demo`.
55+
56+
```xml
57+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
58+
xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
59+
<scope id="global">
60+
<fieldset id="sales_convert_quote">
61+
<field name="demo">
62+
<aspect name="to_order" targetField="order_demo"/>
63+
</field>
64+
</fieldset>
65+
</scope>
66+
</config>
67+
```
68+
69+
Define a new `aspect` if you need to copy a field of a source table into multiple fields in a destination table.
70+
71+
The following example shows how to copy `sales_convert_quote`.`demo` into
72+
73+
- `sales_order`.`demo`
74+
- `sales_order`.`order_demo`
75+
76+
```xml
77+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
78+
xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
79+
<scope id="global">
80+
<fieldset id="sales_convert_quote">
81+
<field name="demo">
82+
<aspect name="to_order"/>
83+
<aspect name="to_demo_order" targetField="order_demo"/>
84+
</field>
85+
</fieldset>
86+
</scope>
87+
</config>
88+
```
89+
5290
## Step 3: Copy the fieldset {#step-3}
5391

5492
For copying the fieldset, we'll observe the `sales_model_service_quote_submit_before` event by using the following code in our `etc/events.xml`:
@@ -108,7 +146,6 @@ class SaveOrderBeforeSalesModelQuoteObserver implements ObserverInterface
108146
return $this;
109147
}
110148
}
111-
112149
```
113150

114151
In the code, an instance of the `Copy` class is obtained from the constructor using [dependency injection][2].

0 commit comments

Comments
 (0)