PROFESSIONAL DEVELOPER TEST POOL-02 (MAGENTO 2 CERTIFIED )

Description

POOL-1 30 question, This only my study notes, questions will NOT be found on the final exam. They might be similar. 60 questions 90mi 64%(more than 39) to pass Based on Magento Open Source (2.3) and Magento Commerce (2.3),
Dario Dorfelli
Quiz by Dario Dorfelli, updated more than 1 year ago More Less
Miska Red
Created by Miska Red over 4 years ago
Dario Dorfelli
Copied by Dario Dorfelli over 4 years ago
1211
2

Resource summary

Question 1

Question
You are debugging a before plugin implementation on the authenticate method of a third party extension’s class that is not being called. The definition of the plugin within your module’s di.xml is: <type name=”Extension\Module\Service\AuthProvider”> <plugin name=”authentication” type=”MyCompany\MyModule\Plugin\Service\AuthProvider” /> </type> The structure of the third party class is: final class AuthProvider { final public function hashToken(); public function authenticate(); private function send(); } What is causing the plugin on the authenticate method to not work as expected?
Answer
  • Plugins do not work on a class that is declared final
  • The XML definition does not define the method the plugin is intercepting
  • Plugins do not work on a class that contains a final public method
  • The XML definition should be defined within plugins.xml and not di.xml

Question 2

Question
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?
Answer
  • 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.

Question 3

Question
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?
Answer
  • 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=”...”/>

Question 4

Question
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?
Answer
  • 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.

Question 5

Question
There is a method which returns an entity: public function get($entityId, $editMode = false) { $entity = $this→entityLoader→load($entityId); return $entity; } You need to log all ocurrences of the entity being loaded successfully, along with the selected edit mode. What mechanism achieves this with the smallest increase of the call stack?
Answer
  • Around plugin
  • Event observer
  • After plugin
  • Before plugin

Question 6

Question
You are creating a module Micro Inventory that can update product stock quickly and also some feature, you implement public function resupply($productId, $qty) { $product = $this->productRepository->getById($productId); $stockItem = $this->stockRegistry->getStockItemBySku($product->getSku()); $stockItem->setQty($stockItem->getQty() + $qty); $stockItem->setIsInStock((bool)$stockItem->getQty()); $this->stockRegistry->updateStockItemBySku($product->getSku(), $stockItem); } Where is stockRegistry?
Answer
  • \Magento\CatalogInventory\Api\StockRegistryInterface
  • \Magento\Catalog\Api\ProductRepositoryInterface
  • \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory
  • \Magento\Ui\DataProvider\AbstractDataProvider

Question 7

Question
How would you create a custom product attribute which is only applicable to bundle products?
Answer
  • By setting the attribute’s apply_to property yo “bundle”
  • By creating a backend model that checks the product type parameter and throws an exception…... different from bundle.
  • By creating a special attribute set for these products and assigning only bundle pr….
  • By setting the attribute’s attribute_model property to “bundle”

Question 8

Question
Which two use cases would be valid causes to create a new block type? Choose 2 answers.
Answer
  • You need to change how the cache key is generated for multiple blocks
  • You want to hard code the template path for a block used multiple times……
  • You need to add custom data to the template
  • You need to change the behavior of the rendering methods……

Question 9

Question
You are creating an extension attribute on the customer entity to link data obtained from an external CRM system. The custom interface \MyCompany\MyCrm\Api\Data\ExternalCustomerDataInterface contains the accessors for the data. You already have implemented the interface and configured it with a <preference> node in di.xml The extension attribute is also registered in your modules etc/extension_attributes.xml file. Which 3 other steps are required to make this class available as an extension attribute on cus…….
Answer
  • Load the ExternalCustomerDataInterface instance and set it on the customers….
  • Create after* plugins on all methods of the CustomerRepositoryInterface…… instances
  • Add the getters and setters for the extension attribute to the \Magento\Customer\Api\Data\CustomerMetaDataInterface
  • Create an afterLoad plugin on \Magento\Customer\Model\ReesourceModel\Customer…... ExternalCustomerDataInterface instance to the loaded customer.
  • If the customer instance method getExtensionAttributes() returns null………. Extension attribute on.

Question 10

Question
Which three types of relations between blocks and templates are configured via layout XML? Choose 3 answers
Answer
  • Multiple block instances can be used from the same templates.
  • Multiple block instances of the same class can use the same template.
  • Multiple templates can be assigned to different instances of the same block class.
  • Multiple block classes can use the same template.
  • Multiple templates can be assigned to the same block instance.
Show full summary Hide full summary

Similar

Magento 2 Front-end Developer Certification Practice Exam
Érika Giroux
PROFESSIONAL DEVELOPER TEST POOL-1 (MAGENTO 2 CERTIFIED )
Miska Red
PROFESSIONAL DEVELOPER TEST POOL-1 (MAGENTO 2 CERTIFIED )
Станислав Матявин
Magento 2 Cloud
Oleksiy P
Magento Backend Test
eddie0236
PROFESSIONAL DEVELOPER TEST POOL-1 (MAGENTO 2 CERTIFIED )
Dario Dorfelli
Magento 2 Front-end Developer Certification Practice Exam
Sanjay Antala
M2 FE - OPV
Vladyslav Opuhliy
PROFESSIONAL DEVELOPER TEST POOL-1 (MAGENTO 2 CERTIFIED )
test test
Magento 2 Front-end Developer Certification Practice Exam
Keerthana S
Magento 2 Front-end Developer Certification Practice Exam
asdsad sdfadad