Frage 1
Frage
You are debugging a problem with a UI Component form and notice that Magento_Ui/js/dynamic-rows/action-delete.js does not specify a template, but is loading the templates/dynamic-rows/cells/action-delete.html. You have already looked in the UI Component XML file and it is not there. Where would the template path be specified?
Antworten
-
definition.xml under the <actionDelete/> node.
-
The dynamic-rows parent component’s defaults object.
-
requirejs-config.js in Magento_Ui under the template key.
-
Nowhere specifically. Magento automatically looks up the template by default based on the component name.
Frage 2
Frage
A 3rd-party module installed on the site you are working on adds several pie-chart reports in the admin panel. It uses a 1000-line jQuery widget to render the pie chart. You have been asked to fix a bug and after some work discover the problem within the jQuery widget. Keeping maintainability in mind, how should you fix the problem?
Antworten
-
Create a mixin and return a jQuery widget with the same name as the original. Use the second parameter in the widget constructor for the original widget object and override only the necessary methods.
-
Copy the entire 3rd party extension directory from vendor/ into the site’s app/code folder and edit the Javascript file directly since it is a bug.
-
Create a mixin for the module and copy the entire original widget into it, updating the problematic method as needed.
-
Copy the Javascript module into your own module and use RequireJs config with the “map” key to update the path so the custom version you have created is used instead.
Frage 3
Frage
You are working on a site that extends a 3rd-party theme. You need to completely change how the breadcrumb component renders (originally in Magento_Catalog/js/product/breadcrumbs.js). However, the 3rd-party theme already modifies this. You are building a module, SwiftOtter_Catalog, that contains similar updates. Keeping upgradeability and maintainability in mind, what two ways that you can make these updates?
Antworten
-
Create a mixin in SwiftOtter_Catalog’s requirejs-config.js and override all applicable methods.
-
Copy app/design/frontend/3rd-party/Theme/Magento_Catalog/web/js/product/breadcrumbs.js to app/design/frontend/merchant/Theme/Magento_Catalog/web/js/product/breadcrumbs.js.
-
Edit app/design/frontend/3rd-party/Theme/Magento_Catalog/web/js/product/breadcrumbs.js to include the necessary changes.
-
Delete app/design/frontend/3rd-party/Theme/Magento_Catalog/web/js/product/breadcrumbs.js and create a new file in app/code/SwiftOtter/Catalog/view/frontend/web/web/js/product/breadcrumbs.js
Frage 4
Frage
You have built a Javascript module that relies on the following .phtml code:<?php // app/code/MyCompany/MyModule/view/frontend/templates/render.phtml ?> <div data-mage-init=’{“MyCompany_MyModule/js/welcome”: {}}’>
<?php if ($viewModel->canRenderWelcome()):?>
<span data-bind=”text: welcomeText()”></span>
<?php endif;?> </div> Unfortunately, the span is always empty. What is the solution?
Antworten
-
Add the attribute data-bind=”scope: ‘[component in uiRegistry]’” to the <div/> tag.
-
Add a bind-directives: true into the properties passed into MyCompany_MyModule/js/welcome.
-
Convert the data-mage-init statement into initializing a uiComponent so that the content is properly rendered.
-
Refactor into using an external template. Then, use Knockout getTemplate in the constructor of MyCompany_MyModule/js/welcome.
Frage 5
Frage
A merchant wants you to add a close button to collapse an opened tab on a product page. The Magento Tabs widget is used for the tabs. You add this code to your template: <button data-action="close" translate="'Close'"/> Keeping upgradability in mind, how do you implement this functionality?
Antworten
-
Extend the Magento Tabs widget and add a callback for the button there
-
Add an attribute onclick="$.mage.tabs.close()" to the button
-
Add a callback for the button in the Magento Tabs widget in lib/web/mage/tabs.js
-
Add a data-bind="click: close" attribute to the button
Frage 6
Frage
A merchant has asked that the price of their free shipping method, which natively is displayed as $0.00, instead is displayed as FREE in the checkout in their store's theme. How do you make the change?
Antworten
-
Copy the shipping-method-item Knockout HTML template from Magento_Checkout to your theme and add the following to the template: <!-- ko if: (element.getRegion('price') === '$0.00') -->FREE<!-- /ko --> <!-- ko if: (element.getRegion('price') !== '$0.00') -->element.getRegion('price')<!-- /ko-->
-
Add the translation '$0.00','FREE' to your theme's translation CSV file.
-
Copy the appropriate view/shipping.js file from Magento_Checkout to your theme and change the form
uiComponent's rate property to: rates:shippingService.getShippingRates().replace('$0.00', 'FREE');
-
Create a requirejs-config.js file and create a Magento mixin to replace the native shipping-method-item Knockout HTML template.
Frage 7
Frage
During a code review you notice the following code:
$('#element').collapsible({ ajaxContent: 'true', ajaxUrlElement: '.my-ajax-url', content: '.my-content' }); What is your peer's desired result in using ajaxUrlElement?
Antworten
-
Magento will replace the element .my-ajax-url with content loaded via AJAX from the data-url attribute set in the element .my-ajax-url.
-
Magento will find the element .my-ajax-url and load the content from that element's href attribute into .mycontent.
-
Magento will do a POST AJAX request on the href in .my-content and load the content in the .my-ajax-url element.
-
.my-ajax-url element.
-
Magento will do a GET AJAX request on the data-url attribute in my-ajax-url and load the content in the
Frage 8
Frage
You Create a RequireJS configuration file requirejs-config.js, having specified the following: var config = { "map": { "*": { "<default_component><custom_component>" } } };
What do you meaning <default_component> & <custom_component> ? (select 2)
Antworten
-
<default_component>: the name of the default component you replace
-
<custom_component>: the name of the custom component
-
<default_component>: the name of the custom component
-
<custom_component>: the name of the default component you replace
Frage 9
Frage
You need to Replace a default JS component, To use a custom implementation of an existing Magento JS component: Place the custom component source file in one of the --------- locations:
(Select 2)
Antworten
-
Theme JS files: /web/js or /_/web/js
-
Module view JS files:<module_dir>/view/frontend/web/js
-
Module view JS files: <module_dir>/web/js
-
Theme JS files: /view/frontend/web/js or /_/view/frontend/web/js
Frage 10
Frage
By default, the Magento application uses the --- and ---to optimize the time of loading pages with included JavaScript files, and to manage dependencies of JavaScript resources.
Antworten
-
RequireJS
-
module loader
-
VueJs
-
AngualJS
Frage 11
Frage
You are Explore JavaScript resources JS resources location
Where you can find the JS components of Library level?
Antworten
-
(lib/web). Resources located here are available in any place in Magento.
-
<module_dir>/view/<areaname>/web. If the module is enabled, resources added here are available in other modules and themes.
-
<theme_dir>/<VendorName>_<ModuleName>/web. Resources added here are available for [inheriting] themes.
-
<theme_dir>/web. Resources added here are available for [inheriting] themes.
Frage 12
Frage
You are Explore JavaScript resources JS resources location
Where you can find the JS components of "Module level" ?
Antworten
-
(<module_dir>/view/<areaname>/web). If the module is enabled, resources added here are available in other modules and themes
-
(<theme_dir>/<VendorName>_<ModuleName>/web). Resources added here are available for [inheriting] themes.
-
(<theme_dir>/web). Resources added here are available for [inheriting] themes.
-
(lib/web). Resources located here are available in any place in Magento.
Frage 13
Frage
You are Explore JavaScript resources JS resources location
Where you can find the JS components of "Theme level, for a particular module" ?
Antworten
-
(<theme_dir>/<VendorName>_<ModuleName>/web). Resources added here are available for [inheriting] themes
-
(<theme_dir>/web). Resources added here are available for [inheriting] themes.
-
(lib/web). Resources located here are available in any place in Magento.
-
(<module_dir>/view/<areaname>/web). If the module is enabled, resources added here are available in other modules and themes.
Frage 14
Frage
You are Explore JavaScript resources JS resources location
Where you can find the JS components of "Theme level " ?
Antworten
-
(<theme_dir>/web). Resources added here are available for [inheriting] themes.
-
(<theme_dir>/<VendorName>_<ModuleName>/web). Resources added here are available for [inheriting] themes.
-
(<module_dir>/view/<areaname>/web). If the module is enabled, resources added here are available in other modules and themes
-
(lib/web). Resources located here are available in any place in Magento
Frage 15
Frage
You are Accessing JS resources JS resources are accessed using relative paths. File actual location: app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
File published to pub/static: pub/static/frontend/Magento/<theme>/<locale>/Magento_ConfigurableProduct/js/configurable.js. Here <theme> and <locale> are the currently applied in your instance theme and locale. How to Called in script?
Antworten
-
require(["Magento_ConfigurableProduct/js/configurable"], function(Configurable){ });
-
require(["js/theme.js"], function(){ });
-
require(["jquery"], function($){ });
-
require(["configurable"], function($){ });
Frage 16
Frage
You are Accessing JS resources, JS resources are accessed using relative paths.File actual location: app/design/frontend/Magento/blank/Magento_Theme/web/js/theme.js File published to pub/static: pub/static/frontend/Magento/<theme>/<locale>/js/theme.js
How to Called in script?
Antworten
-
require(["js/theme.js"], function(){ });
-
require(["web/js/theme.js"], function(){ });
-
require(["theme"], function($){ });
-
require(["theme.js"], function($){ });
Frage 17
Frage
You are Accessing JS resources, JS resources are accessed using relative paths actual location: lib/web/jquery.js File published to pub/static: pub/static/<area>/Magento/<theme>/<locale>/jquery.js
How to Called this script?
Antworten
-
require(["jquery"], function($){ });
-
require(["jquery.js"], function($){ });
-
require(["lib/web/jquery.js"], function($){ });
-
require(["web/jquery.js"], function($){ });
Frage 18
Frage
You are creating Dependencies between JavaScript resources
To build a dependency on the third-party plugin, specify a [shim] in the following configuration files: requirejs-config.js
var config = { "shim": { "3-rd-party-plugin": ["jquery"] } };
What is content example of <third-party-plugin>.js ?
Antworten
-
!(function($){
// plugin code
// where $ == jQuery
})(jQuery);
-
(function($){
// plugin code
// where $ == jQuery
})(jQuery);
-
(function($shim){
// plugin code
// where $ == jQuery
})(jQuery);
-
(function(shim){
// plugin code
// where $ == jQuery
})($);