Questão 1
Questão
You are customizing a third-party module and need to prevent an event handler from triggering. Keeping upgradeability in mind, how do you do this?
Responda
-
Create an observer in events.xml with the same name and specify the disabled="true" attribute.
-
Create a plugin that will disable the 3rd-party's event observer method.
-
Override the event observer's class.
-
Comment the observer from the 3rd-party's module.
Questão 2
Questão
When writing a model triad (model, resource model, collection), what is the correct way to save a model to the database?
Responda
-
Call the save method in the resource model class.
-
Call the save method in the collection class.
-
Call the save method in the model class.
-
Call the save method in the repository.
Questão 3
Questão
When creating a new data provider collection for a uiComponent, what class must you extend?
Responda
-
Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
-
Magento\Framework\View\UiComponent\ViewCollection
-
Magento\Framework\ViewDataProvider\UiComponent\CollectionProvider
-
Magento\Framework\UiComponent\ComponentCollection
Questão 4
Questão
You are tasked with creating a widget that will render a product’s price using the Magento price rendering system. How do you do this?
Responda
-
Retrieve the product.price.render.default block and call the render method.
-
Use the protected property, $priceRenderer injected in the $context in the Template.
-
Trigger the catalog_product_render_price event, attaching the product as event data.
-
Use dependency injection to get an instance of the Magento\Framework\Pricing\Renderer class and call the renderPrice method.
Questão 5
Questão
What must be done differently to properly generate a URL in the Magento backend?
Responda
-
Generate the URL from an instance of \Magento\Backend\Model\UrlInterface.
-
Ensure that the controller is configured for the correct ACL path.
-
Instead of calling the getUrl() method, you must call the getBackendUrl() method
-
Nothing: generating URLs in the frontend and backend are the same.
Questão 6
Questão
You need to add a residential / commercial destination selector to the shipping address on the checkout.What are the steps needed to add this selector? 2
Responda
-
Add new column to the sales_order_address table.
-
Create a checkout_index_index.xml file and add the uiComponent details.
-
Add a Javascript mixin to render the selector.
-
Override \Magento\Block\Checkout\ShippingAddress and add a getter for the selector value.
Questão 7
Questão
Keeping maintainability in mind, how do you add a new link to the customer account sidebar?
Responda
-
Create customer_account.xml and add a block to the customer_account_navigation.
-
Create a plugin for the customer Navigation class.
-
Create customer_account_index.xml and add the link to the uiComponent configuration in jsLayout
-
Create customer_account_index.xml and add a block to the sidebar container.
Questão 8
Questão
You need to implement a fallback for VAT ID validation to prevent downtime should the validator service be unavailable. How do you add the fallback?
Responda
-
Create an after plugin for Magento\Customer\Model\Vat::checkVatNumber method.
-
Override the Magento\Quote\Model\VatValidator::validate method.
-
Observe the customer_validate_vat_id_after event.
-
Change the Stores > Configuration > Customer > VAT Validation Fallback method to be “Regex”
Questão 9
Questão
You need to add a date column to a uiComponent in a Magento admin grid. What three actions must you take to successfully implement this? 3
Responda
-
Specify the Date module for the class attribute.
-
Set the date type for the dataType setting.
-
Specify the date component for the component attribute.
-
Utilize the date node type.
-
Add a data/config/dateFormat node.
Questão 10
Questão
You have created a custom customer attribute that displays the last time that the customer made a purchase, stored in UTC. This attribute needs to be visible in the Customer grid. The column is visible, but, when it is loaded, only the date is visible—not the time. You have verified that both the date and time are stored in the database. Keeping user experience in mind, what is the solution?
Responda
-
Add a new column to the customer_listing uiComponent and specify the date column type.
-
Override the customer uiComponent data provider and format the data as a string.
-
Change the backend_type from date to datetime.
-
Set the grid_column_type to be datetime in the customer_eav_attribute table.
Questão 11
Questão
A root category is associated with which scope:
Responda
-
Store
-
Website
-
Global
-
Store View
Questão 12
Questão
You wish to create a custom 404 page that only displays for specific URLs. This was necessary because of the Magento 1 to Magento 2 migration and the need to redirect URLs from the old site to the new site. This custom 404 page should only appear once all other routers have not matched the URL. Keeping maintainability in mind, how do you implement this?
Responda
-
Create a router that watches for the noroute action; if it matches, forward the front controller to a custom controller.
-
Create a plugin for the dispatch method in vendor/magento/framework/App/FrontController.php.
-
Create an observer for the front_controller_match_after event.
-
Create a layout XML file cms_noroute_index.xml and place updates in it.
Questão 13
Questão
When should static files be placed in a theme rather than in a specific module?
Responda
-
When the files are general files that affect all the pages (ex: logo image).
-
When the files apply to a specific application feature (ex: price box size on the product view page).
-
It is better to place all static files in a module rather than in a theme – it makes the overall structure better.
-
It is better to place all static files in a theme rather than in a module, as having all
the files in one place makes them easier to manage.
Questão 14
Questão
You wish to create a new router which below steps are need ? (select 3)
Responda
-
Inject new item under routerList argument of Magento\Framework\App\RouterList type via di.xml
-
Create router file (by using match method implements \Magento\Framework\App\RouterInterface).
-
Return instance of \Magento\Framework\App\ActionInterface
-
inject an instance of \Magento\Framework\Event\ManagerInterface into constructor
Questão 15
Questão
What ways are possible to wrap a block with an HTML tag?
2
Responda
-
Layout XML container
-
Add the tag to the template.
-
Listen to the core_block_html_output_after event.
-
Add a plugin for the afterHtml method.
Questão 16
Questão
You are adding an extension attribute to the CustomerInterface class. You have specified data for the extension attribute, but when you check the database, nothing has been saved. Why is that?
Responda
-
Extension attribute data is not automatically persisted to the database.
-
You need to ensure that the extension attribute getter and setter exists in CustomerExtensionInterface.
-
You need to add a <persist/> node to the extension attribute XML details.
-
The appropriate columns in customer_entity have not been created.
Questão 17
Questão
You are creating a new store configuration entry. As part of the requirements, this entry must only be visible in the global and website scopes. What is the purpose of this limitation?
Responda
-
A primary use of the global and website scopes is to enable/disable features.
-
The global and website scopes cannot be overridden by store scopes.
-
The store scope is only available when a specific store is selected.
-
The store scope must have a default value set—no default value is appropriate here.
Questão 18
Questão
You are connecting Magento customers with a Customer Relationship Manager (CRM). You need to associate each customer’s CRM unique ID, CRM notes and a list of their current opportunities. This information must always available for each Customer object. You have configured the interface, class implementation and set up extension_attributes.xml What two steps remain to access this data? 2
Responda
-
Use after plugins in customer repository and collection.
-
Ensure the extension attributes property is an object.
-
Specify a extensionAttributeLoader in the db_schema.xml
-
Create an observer for the customer_load_after event.
Questão 19
Questão
You are assisting a merchant setting up a Cart Price Rule. They wish to apply free shipping to specific items in the cart (and not the entire cart). How do you implement the filter for the specific products?
Responda
-
Create Conditions rules for the specific requirements.
-
Use the Actions rules for the specific requirements.
-
Add a Product filter to the Apply To rules for the specific requirements.
-
This is not possible without a 3rd-party customization.
Questão 20
Questão
You are tasked with creating a new EAV attribute. What steps do you take to be able to call the addAttribute method? 2
Responda
-
Create a new data patch.
-
Inject and use an instance of EavSetup.
-
Utilize the module’s UpgradeData class.
-
Use the ModuleDataSetup class.
Questão 21
Questão
You are customizing a Magento website that will be connected to an ERP through the REST API. Also on this website, you have written a way for a customer to add comments to the order. These comments need to be sent to the ERP. Keeping maintainability in mind, how do you accomplish this?
Responda
-
Add an extension attribute to OrderInterface
-
Create a new REST API endpoint to fetch the comments per order.
-
Ensure the comments key is in the Order model’s $data array.
-
Override the Order model to add a getComments method.
Questão 22
Questão
How do you make a new category attribute available to be edited in the admin panel?
Responda
-
Add the new attribute to the category_form.xml uiComponent.
-
This is done automatically.
-
Create a plugin for the `Form` class that renders the category form and add the extra field.
-
In the data setup script, add the attribute to the category's default attribute set.
Questão 23
Questão
You have injected \Magento\Framework\Api\SearchCriteria into the constructor method. You then wrote the following code in a method:
1: $search = $this->searchCriteria->setSortOrders([‘entity_id ASC’]);
2: $this->productRepository>getList($search);
When running this code, you get an error: Fatal error: Uncaught TypeError: Argument 1 must be an instance of SortOrder, string given. What are two errors present in the examples given?
Responda
-
Sort order should not be specified as a string.
-
SearchCriteriaBuilder should be used instead of SearchCriteria.
-
One line 2, when loading $search, you need to use $search->getCriteria().
-
Sort orders must be added one at a time with the addSortOrder method.
Questão 24
Questão
You need to locate several products. You run this code: $productRepository->getList($criteriaBuilder->addFilter(‘type_id’, ‘bundle’)->getItems(); However, you get an error: Type SearchCriteriaInterface expected. What is the solution?
Responda
-
Call the ->create() method after addFilter().
-
Run bin/magento setup:di:compile.
-
Create a custom wrapper for SearchCriteriaBuilder to utilize classes in your module.
-
Don’t use a SearchCriteriaBuilder. Instead, inject a SearchCriteriaInterface.
Questão 25
Questão
For fraud prevention purposes, you need to notate the IP address from which a user adds an item to their cart. Which event will allow you access to every cart addition?
Questão 26
Questão
You are building a customization for Magento sites that must change the template for the customer account order history view. How do you accomplish this?
Responda
-
Override \Magento\Sales\Block\Order\History and specify a new $_template variable.
-
In sales_order_history.xml add: <referenceBlock name=”sales.order.history”><arguments><argument name=”template” xsi:type=”string”>...</argument></arguments>
-
Create an after plugin for the \Magento\Sales\Block\Order\History::setTemplate.
-
In sales_order_history.xml add: <referenceBlock name=”sales.order.history” template=”...”/>
Questão 27
Questão
Front Controller: Creating the List of Routers . Where is located in <magento_installation_dir>-----?
Responda
-
/lib/internal/Magento/Framework/App/FrontController.php
-
/app/code/Magento/Framework/App/FrontController.php
-
/vendor/Magento/Framework/App/FrontController.php
-
/app/design/Magento/Framework/App/FrontController.php
Questão 28
Questão
What is the default router in Magento 2?
Responda
-
Magento\Framework\App\Router\DefaultRouter
-
Magento\Core\App\Router\Base
-
Magento\Cms\Controller\Router
-
Magento\UrlRewrite\Controller\Router
-
Magento\DesignEditor\Controller\Varien\Router\Standard
Questão 29
Questão
Where CMS router, which processes CMS pages in Magento 2.?
Responda
-
Magento\Cms\Controller\Router
-
Magento\UrlRewrite\Controller\Router
-
Magento\DesignEditor\Controller\Varien\Router\Standard
-
Magento\Framework\App\Router\DefaultRouter
Questão 30
Questão
URL Processing: Base Router URL Composition
For example, the URL: http://magento-installation.com/catalog/product/view/id/1 Write structure of the URL, as accepted by the router?
Responda
-
$baseUrl/$frontName/$controllerName/$actionName/$otherParams
-
$baseUrl/$controllerName/$frontName/$actionName/$otherParams
-
$baseUrl/$frontName/$routerName/$actionName/$otherParams
-
$baseUrl/$frontName/$modelName/$actionName/$otherParams