You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guides/v2.3/ext-best-practices/tutorials/dynamic-row-system-config.md
+66-2Lines changed: 66 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,71 @@ class TaxColumn extends Select
171
171
172
172
This block sets values for the drop-down option.
173
173
174
-
## Step 4: Clean cache
174
+
## Step 4: Set default values - OPTIONAL
175
+
176
+
It is possible to set defaults for a dynamic row configuration, this is done by adding additional XML to the defaults block in the `config.xml` file for the module.
177
+
178
+
Add a block to the `<default>` section of the `config.xml` file and do not include any values:
179
+
180
+
```xml
181
+
<system>
182
+
<general>
183
+
<ranges></ranges>
184
+
</general>
185
+
</system>
186
+
```
187
+
188
+
For each complete line of configuration, create an XML block with a repeating node that has a different value to all the others and contains XML tags for each sub-option and value.
189
+
For example, you can use `<item1>, <item2>`.
190
+
191
+
The sub-options are the columns defined in the `_prepareToRender()` method as described in [Step 2](#step-2-create-the-block-class-to-describe-custom-field-columns).
192
+
193
+
In the following excerpt, a single row for `item1` contains 4 sub-options:
194
+
195
+
```xml
196
+
<item1>
197
+
<from_qty>5</from_qty>
198
+
<to_qty>6</to_qty>
199
+
<price>10.00</price>
200
+
<tax>1</tax>
201
+
</item1>
202
+
```
203
+
204
+
Continue building the default block by adding 3 items to the `ranges` configuration option in the `config.xml` file:
205
+
206
+
```xml
207
+
<system>
208
+
<general>
209
+
<ranges>
210
+
<item1>
211
+
<from_qty>1</from_qty>
212
+
<to_qty>5</to_qty>
213
+
<price>10.00</price>
214
+
<tax>1</tax>
215
+
</item1>
216
+
<item2>
217
+
<from_qty>6</from_qty>
218
+
<to_qty>10</to_qty>
219
+
<price>20.00</price>
220
+
<tax>1</tax>
221
+
</item2>
222
+
<item3>
223
+
<from_qty>11</from_qty>
224
+
<to_qty>15</to_qty>
225
+
<price>30.00</price>
226
+
<tax>0</tax>
227
+
</item3>
228
+
</ranges>
229
+
</general>
230
+
</system>
231
+
```
232
+
233
+
To verify the default values for the configuration are correct, do the following :
234
+
235
+
- Ensure that this configuration option has no entry in the database.
236
+
- Continue with Step 5
237
+
238
+
## Step 5: Clean cache
175
239
176
240
Clean the Magento cache with the following command:
0 commit comments