Skip to content

Commit d13ed5a

Browse files
committed
feat: generator command for sample view.xml file
1 parent 412ff7c commit d13ed5a

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
@@ -12,6 +12,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1212
- Added: Generator command for sample email_templates.xml file
1313
- Added: Generator command for sample sections.xml file
1414
- Added: Generator command for sample fieldset.xml file
15+
- Added: Generator command for sample view.xml file
1516

1617
## [1.1.3] - 3/12/2025
1718

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@
134134
{
135135
"command": "magento-toolbox.generateFieldsetXmlFile",
136136
"title": "Magento Toolbox: Generate Fieldset XML"
137+
},
138+
{
139+
"command": "magento-toolbox.generateViewXmlFile",
140+
"title": "Magento Toolbox: Generate View XML"
137141
}
138142
],
139143
"menus": {
@@ -231,6 +235,10 @@
231235
{
232236
"command": "magento-toolbox.generateFieldsetXmlFile",
233237
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
238+
},
239+
{
240+
"command": "magento-toolbox.generateViewXmlFile",
241+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
234242
}
235243
]
236244
}

src/command/GenerateViewXmlFile.ts

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 GenerateViewXmlFile extends SimpleTemplateGeneratorCommand {
6+
constructor() {
7+
super('magento-toolbox.generateViewXmlFile');
8+
}
9+
10+
getWizardTitle(): string {
11+
return 'View 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/view.xml`;
22+
}
23+
24+
getTemplateName(data: TemplateWizardData): string {
25+
return 'xml/blank-view';
26+
}
27+
}

src/command/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ export { default as GenerateCrontabXmlCommand } from './GenerateCrontabXmlComman
1818
export { default as GenerateEmailTemplatesXmlCommand } from './GenerateEmailTemplatesXmlCommand';
1919
export { default as GenerateSectionsXmlCommand } from './GenerateSectionsXmlCommand';
2020
export { default as GenerateFieldsetXmlCommand } from './GenerateFieldsetXmlCommand';
21+
export { default as GenerateViewXmlFile } from './GenerateViewXmlFile';

templates/xml/blank-view.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:framework:Indexer/etc/view.xsd">
7+
</config>

0 commit comments

Comments
 (0)