An Adobe Commerce developer needs to alias URLs and third party libraries inside a require js-config.js file. Which configuration would the developer use?
A)
B)
C)
Answer : B
To alias URLs and third party libraries inside a requirejs-config.js file, the developer should use the paths configuration option. This option allows the developer to map module names to URLs or paths relative to the baseUrl. For example:
var config = { paths: { 'jquery': 'https://code.jquery.com/jquery-3.6.0.min', 'custom': 'Vendor_Module/js/custom' } };
This will map the module name 'jquery' to the URL of the jQuery library and the module name 'custom' to the path of the custom module. The developer can then use these module names in other modules or files without specifying the full URL or path.
Option A is not correct because it uses the shim configuration option, which is used to define dependencies and exports for non-AMD modules, not to alias URLs or paths. Option C is not correct because it uses the map configuration option, which is used to map module names to other module names for specific contexts, not to alias URLs or paths. Reference: [RequireJS configuration], [RequireJS paths]
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?
Answer : B
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 is trying to remove a block using the
Answer : A
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 needs to display a URL in the template. How would the variable $ur1 be securely output in the template?
Answer : A
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 created a module called Orange_Customer. In customer information.
Where would the developer place this file?
Answer : C
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 wants to override the following Layout XML file in the theme ExampleCorp/orange.
app/design/frontend/ExampleCorp/blank/Vendor_Module/layout/catalog_product_view.xml
What path would the developer use inside the layout directory of the theme to override the file?
Answer : C
To override a layout XML file from a parent theme, the developer just needs to place the modified file in the same path relative to the layout directory of the child theme. In this case, the file would be app/design/frontend/ExampleCorp/orange/Vendor_Module/layout/catalog_product_view.xml. The override directory is not used for overriding layout files, but for overriding templates and web assets. Reference: [Layout instructions], [Override templates and layout files]
The merchant needs to create a new website, and is need modify a template the third party vendor's, because the customer is different. The file is found in a module here: app/code/Vendor/Module
Keep it simple in your mind!