ExamGecko
Home Home / Adobe / AD0-E720

Adobe AD0-E720 Practice Test - Questions Answers, Page 2

Question list
Search
Search

List of questions

Search

Related questions











An Adobe Commerce developer wants to override the template assigned to a block named existing, product, block. This relationship is defined in the catalog_product_view. xml layout in the Magento_Catalog module. They cannot simply override the file in their theme, as this change is part of a feature that is being released to the marketplace as a module called 'Orange_CustomProduct'.

The developer has already created the desired template at app/code/Orange/CustomProduct/view/f rontend/templates/custom-product-block.phtml.

What can they add to app/code/Orange/CustomProduct/view/f rontend/layout/catalog_product_view. xml in their module to accomplish this?

A)

B)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: B

Explanation:

To override the template assigned to a block in a module, the developer needs to use the <referenceBlock> layout instruction with the name attribute specifying the name of the block and the template attribute specifying the path to the new template file. In this case, the code would be:

<referenceBlock name=''existing.product.block'' template=''Orange_CustomProduct::custom-product-block.phtml''/>

Option A is not valid because it uses <block> instead of <referenceBlock>, which would create a new block instead of referencing an existing one. Option C is not valid because it uses instead of <template>, which would not change the template of the block. Option D is not valid because it uses an incorrect syntax for the template attribute, which should use two colons instead of a slash.

Reference: [Layout instructions], [Override templates and layout files]

An Adobe Commerce developer is using a view model within an existing block:

What are two ways to access the view model class in the template? (Choose two.)

A.
$block->getData('view_model')
A.
$block->getData('view_model')
Answers
B.
$block->viewModel()
B.
$block->viewModel()
Answers
C.
$block->getViewHodel()
C.
$block->getViewHodel()
Answers
D.
$block->getData('viewModel)
D.
$block->getData('viewModel)
Answers
Suggested answer: A, D

Explanation:

To access a view model within an existing block, the developer can use either of the following ways:

$block->getData('view_model'): This method will return the view model object that is assigned to the argument name ''view_model'' in the layout XML file. For example:

<referenceBlock name=''blog_posts_list''> ExampleObjectModel/ExampleObjectModel </referenceBlock>

In the template file, the developer can access the view model object by using:

$block->getData('view_model')

$block->getData('viewModel'): This method will return the view model object that is assigned to the argument name ''viewModel'' in the layout XML file. For example:

<referenceBlock name=''blog_posts_list''> ExampleObjectModel/ExampleObjectModel </referenceBlock>

In the template file, the developer can access the view model object by using:

$block->getData('viewModel')

The following methods are not valid and will not work:

$block->viewModel(): This method does not exist and will cause an error.

$block->getViewHodel(): This method is misspelled and will cause an error.

An Adobe Commerce developer needs to pass JSON data to a JavaScript component while keeping XSS prevention strategies in mind.

Which two options would the developer use? (Choose two.)

A)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: A, C

Explanation:

To pass JSON data to a JavaScript component while keeping XSS prevention strategies in mind, the developer should use the following options:

Option A: Use the x-magento-init script tag with the data-mage-init attribute and the JSON.parse function to initialize the component with the JSON data. This option is secure because it does not use any HTML tags or attributes that can be exploited by XSS attacks.

Option C: Use the text/x-magento-init script tag with the type attribute and the JSON.parse function to initialize the component with the JSON data. This option is secure because it does not use any HTML tags or attributes that can be exploited by XSS attacks.

The following options are not secure and should not be used:

Option B: Use the script tag with the type attribute and the escapeHtmlAttr function to initialize the component with the JSON data. This option is not secure because it uses the escapeHtmlAttr function, which is meant for escaping HTML attributes, not JSON data. This function can introduce double quotes in the JSON data, which can break the JSON syntax and cause errors.

Option D: Use the script tag with the type attribute and the escapeJsQuote function to initialize the component with the JSON data. This option is not secure because it uses the escapeJsQuote function, which is meant for escaping JavaScript strings, not JSON data. This function can introduce backslashes in the JSON data, which can break the JSON syntax and cause errors.

An Adobe Commerce developer created a module called Orange_Customer. In customer information.

Where would the developer place this file?

A.
app/code/OrangG/customer/viev^/frontend/web/templates/customer-info.phtml
A.
app/code/OrangG/customer/viev^/frontend/web/templates/customer-info.phtml
Answers
B.
app/code/Orange/Customer/frontend/templates/customer-info.phtml
B.
app/code/Orange/Customer/frontend/templates/customer-info.phtml
Answers
C.
app/code/OrangG/Custon>Gr/viGw/frontGnd/templates/customGr-info.phtml
C.
app/code/OrangG/Custon>Gr/viGw/frontGnd/templates/customGr-info.phtml
Answers
Suggested answer: C

Explanation:

To place a template file for a custom module, the developer should follow this path pattern:

app/code/<Vendor>/<Module>/view/<Area>/templates/<Template>

In this case, the vendor name is Orange, the module name is Customer, the area is frontend, and the template name is customer-info.phtml. Therefore, the correct path is:

app/code/Orange/Customer/view/frontend/templates/customer-info.phtml

The following paths are not correct and will not work:

app/code/Orange/customer/view/frontend/web/templates/customer-info.phtml: This path is incorrect because it uses web instead of templates, which is used for storing web assets like CSS, JS, and images, not template files.

app/code/Orange/Customer/frontend/templates/customer-info.phtml: This path is incorrect because it misses the view directory, which is required for separating frontend and backend templates.

An Adobe Commerce developer needs to display a URL in the template. How would the variable $ur1 be securely output in the template?

A.
<?php echo $escaper->escapeUrl($url) ?>
A.
<?php echo $escaper->escapeUrl($url) ?>
Answers
B.
<?php echo $escaper->escapeLink($url) ?>
B.
<?php echo $escaper->escapeLink($url) ?>
Answers
C.
<?php echo $escaper->escapeHtml($url) ?>
C.
<?php echo $escaper->escapeHtml($url) ?>
Answers
Suggested answer: A

Explanation:

To display a URL in a template securely, the developer should use the escapeUrl method of the escaper object. This method will encode any special characters in the URL that can be used for XSS attacks, such as &, <, >, ', ', etc. For example:

<?php echo $escaper->escapeUrl($url) ?>

The following methods are not suitable for displaying URLs and should not be used:

<?php echo $escaper->escapeLink($url) ?>: This method is used for escaping link attributes, not URLs. It will encode any characters that are valid in URLs but invalid in HTML attributes, such as spaces, quotes, etc. For example:

<?php echo $escaper->escapeLink('https://example.com/?q=hello world') ?> // Output: https://example.com/?q=hello%20world

<?php echo $escaper->escapeHtml($url) ?>: This method is used for escaping HTML content, not URLs. It will encode any characters that are valid in URLs but invalid in HTML content, such as &, <, >, etc. For example:

<?php echo $escaper->escapeHtml('https://example.com/?q=<script>alert(''XSS'')</script>') ?> // Output: https://example.com/?q=<script>alert('XSS')</script>

An Adobe Commerce developer is trying to remove a block using the <remove name='test.block'/> tag in a layout XML file but it shows an error and doesn't work.

Which tag would be applied to fix the error?

A.
US6 <referenceBlock name='test.block' remove='true'/>
A.
US6 <referenceBlock name='test.block' remove='true'/>
Answers
B.
Use <remove name='Custom_Module:test.block'/>
B.
Use <remove name='Custom_Module:test.block'/>
Answers
C.
Use<referenceBlock name='test.block' delete='true'7>
C.
Use<referenceBlock name='test.block' delete='true'7>
Answers
Suggested answer: A

Explanation:

To remove a block using layout XML, the developer should use the <referenceBlock> tag with the name attribute specifying the name of the block and the remove attribute set to true. For example:

<referenceBlock name=''test.block'' remove=''true''/>

This will remove the block from the layout and prevent it from rendering. The <remove> tag is not valid and will cause an error. The name attribute should not include the module name, as it is not part of the block name. The delete attribute is not valid and will not work.

Reference: [Layout instructions], [Remove an element]

An Adobe Commerce developer wants to remove the default Wishlist and Compare Products blocks on a category page with layered navigation Where would this modification be placed, assuming the developer only wants to make this change?

A.
app/design/frontend/Vendor/Theme/Magento_LayeredNavigation/layout/override/catalog_category_view_type_layered.xml
A.
app/design/frontend/Vendor/Theme/Magento_LayeredNavigation/layout/override/catalog_category_view_type_layered.xml
Answers
B.
app/design/frontend/Vendor/Theme/Magento_Layered.Navigation/layout/catalog_category_view_type_layered.xml
B.
app/design/frontend/Vendor/Theme/Magento_Layered.Navigation/layout/catalog_category_view_type_layered.xml
Answers
C.
app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml
C.
app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml
Answers
Suggested answer: B

Explanation:

To remove the default Wishlist and Compare Products blocks on a category page with layered navigation, the developer should place the modification in the app/design/frontend/Vendor/Theme/Magento_LayeredNavigation/layout/catalog_category_view_type_layered.xml file. This file is specific to the category pages with layered navigation and will override the default layout file from the Magento_LayeredNavigation module. The modification should use the <referenceBlock> tag with the name attribute specifying the name of the block and the remove attribute set to true. For example:

<referenceBlock name=''catalog.compare.sidebar'' remove=''true''/> <referenceBlock name=''wishlist_sidebar'' remove=''true''/>

The app/design/frontend/Vendor/Theme/Magento_LayeredNavigation/layout/override/catalog_category_view_type_layered.xml file is not valid and will not work, as it is not a valid override path. The app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_category_view.xml file is not specific to the category pages with layered navigation and will affect all category pages.

Reference: [Layout override], [Remove an element]

An Adobe Commerce developer has created a system configuration field:

Using Layout XML, how can the visibility of a block be controlled by a system configuration?

A.
<block name='block.name' template='Vendor_Module::template.phtml='' ifconfig='vendor/general/enable' />
A.
<block name='block.name' template='Vendor_Module::template.phtml='' ifconfig='vendor/general/enable' />
Answers
B.
<block name='block.name' template=''Vendor_Module: :template.phtml''ifconfig='module/general/enable' />
B.
<block name='block.name' template=''Vendor_Module: :template.phtml''ifconfig='module/general/enable' />
Answers
C.
<block name='block.name' template='Vendor_Module::template.phtml' ifconfig='general/module/enable' />
C.
<block name='block.name' template='Vendor_Module::template.phtml' ifconfig='general/module/enable' />
Answers
Suggested answer: A

Explanation:

To control the visibility of a block using a system configuration, the developer should use the ifconfig attribute in the <block> tag. The ifconfig attribute should specify the path to the system configuration field that determines whether the block is visible or not. For example:

<block name=''block.name'' template=''Vendor_Module::template.phtml'' ifconfig=''vendor/general/enable'' />

This will render the block only if the vendor/general/enable system configuration field is set to true. The module/general/enable and general/module/enable paths are not valid and will not work, as they do not match the system configuration field defined in the image.

Reference: [Layout instructions], [System configuration]

An Adobe Commerce developer has been asked to add text to an email template that supports translations. Which two options would they use during their implementation? (Choose two.)

A.
{{translations 'Lorem Ipsum is simply dummy text of the printing'}}
A.
{{translations 'Lorem Ipsum is simply dummy text of the printing'}}
Answers
B.
{{translations '%items items' items='numltems'}}
B.
{{translations '%items items' items='numltems'}}
Answers
C.
{{trans 'Lorem Ipsum is simply dummy text of the printing'}}
C.
{{trans 'Lorem Ipsum is simply dummy text of the printing'}}
Answers
D.
{{trans '%items items' items='numltems'}}
D.
{{trans '%items items' items='numltems'}}
Answers
Suggested answer: B, D

Explanation:

To add text to an email template that supports translations, the developer should use the {{trans}} directive with the text enclosed in double quotes. For example:

{{trans ''Lorem Ipsum is simply dummy text of the printing''}}

This will render the text as it is, or translate it if a translation file is available for the current locale. If the text contains a variable, the developer should use a placeholder with a percent sign and pass the variable name as an argument. For example:

{{trans ''%items items'' items=''numItems''}}

This will render the text with the value of numItems replacing the %items placeholder, or translate it if a translation file is available for the current locale. The {{translations}} directive is not valid and will not work.

Reference: [Translate email templates], [Email template syntax]

An Adobe Commerce developer wants to completely overwrite _module. less of Orange_Checkout module, in their theme. Where would the developer place the file?

A.
Custom/theme/Orange_Checkout/frontend/web/css/_module.less
A.
Custom/theme/Orange_Checkout/frontend/web/css/_module.less
Answers
B.
Custom/theme/web/css/source/Orange_Checkout/_module.less
B.
Custom/theme/web/css/source/Orange_Checkout/_module.less
Answers
C.
Custom/theme/Orange_Checkout/web/css/source/_module.less
C.
Custom/theme/Orange_Checkout/web/css/source/_module.less
Answers
Suggested answer: C

Explanation:

To completely overwrite _module.less of Orange_Checkout module in a custom theme, the developer should place the file in the Custom/theme/Orange_Checkout/web/css/source directory. This will override the default _module.less file from the Orange_Checkout module and apply the custom styles to the theme. The Custom/theme/Orange_Checkout/frontend/web/css/_module.less and Custom/theme/web/css/source/Orange_Checkout/_module.less paths are not valid and will not work, as they do not follow the theme structure or the module naming convention.

Reference: [Theme structure], [Module naming convention]

Total 50 questions
Go to page: of 5