Skip to content

Commit 1de38e1

Browse files
committed
feat: generator command for sample sections.xml
1 parent 57b6bfd commit 1de38e1

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1010
- Added: Generator command for sample page_types.xml file
1111
- Added: Generator command for sample crontab.xml file
1212
- Added: Generator command for sample email_templates.xml file
13+
- Added: Generator command for sample sections.xml file
1314

1415
## [1.1.3] - 3/12/2025
1516

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@
126126
{
127127
"command": "magento-toolbox.generateEmailTemplatesXmlFile",
128128
"title": "Magento Toolbox: Generate Email Templates XML"
129+
},
130+
{
131+
"command": "magento-toolbox.generateSectionsXmlFile",
132+
"title": "Magento Toolbox: Generate Sections XML"
129133
}
130134
],
131135
"menus": {
@@ -215,6 +219,10 @@
215219
{
216220
"command": "magento-toolbox.generateEmailTemplatesXmlFile",
217221
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
222+
},
223+
{
224+
"command": "magento-toolbox.generateSectionsXmlFile",
225+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
218226
}
219227
]
220228
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
2+
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
3+
import FileHeader from 'common/xml/FileHeader';
4+
5+
export default class GenerateSectionsXmlCommand extends SimpleTemplateGeneratorCommand {
6+
constructor() {
7+
super('magento-toolbox.generateSectionsXmlFile');
8+
}
9+
10+
getWizardTitle(): string {
11+
return 'Sections XML File';
12+
}
13+
14+
getFileHeader(data: TemplateWizardData): string | undefined {
15+
return FileHeader.getHeader(data.module);
16+
}
17+
18+
getFilePath(data: TemplateWizardData): string {
19+
const [vendor, module] = data.module.split('_');
20+
21+
return `app/code/${vendor}/${module}/etc/frontend/sections.xml`;
22+
}
23+
24+
getTemplateName(data: TemplateWizardData): string {
25+
return 'xml/blank-sections';
26+
}
27+
}

src/command/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ export { default as GenerateWebapiXmlFileCommand } from './GenerateWebapiXmlFile
1616
export { default as GeneratePageTypesXmlCommand } from './GeneratePageTypesXmlCommand';
1717
export { default as GenerateCrontabXmlCommand } from './GenerateCrontabXmlCommand';
1818
export { default as GenerateEmailTemplatesXmlCommand } from './GenerateEmailTemplatesXmlCommand';
19+
export { default as GenerateSectionsXmlCommand } from './GenerateSectionsXmlCommand';

templates/xml/blank-sections.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<% if (fileHeader) { -%>
3+
<%- fileHeader %>
4+
<% } -%>
5+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
7+
</config>

0 commit comments

Comments
 (0)