Magento 2 Certified Associate Developer Exam Sample Questions Answers

Question No 1:

You are working on a new entity called vendor. You implemented the model, resource model and collection. You want to ensure that standard model events will be fired for your model, so an observer can be created for the events vendor_save_after, vendor_save_commit_after and others. How do you do that?

A. Create an entry in etc/di.xml and add the argument eventPrefix with the value of vendor
B. Declare the $_eventPrefix property in your vendor model and set it to vendor
C. You must implement all appropriate methods and fire the events manually
D. Ensure that the primary key in the corresponding table is named vendor_id

Answer: B

Question No 2:

You have created a module controller that responds to the following URL: /mycompany/product/load/id/123. Which two methods will load the product model by ID as specified in the URL? (Choose two.)

A. \Magento\Catalog\Model\ResourceModel\Product::load($productModel, $id)
B. \Magento\Catalog\Model\ResourceModel\Product\Collection::load()->fetchById($id)
C. \Magento\Catalog\Model\ResourceModel\Product\Collection::fetchItemById($id)
D. \Magento\Catalog\Api\ProductRepositoryInterface::getById($id)

Answer: B D

Question No 3:

A merchant gives you the module MyCompany_MyModule to install. How do you identify which REST endpoints are supported by the module?

A. REST endpoints are declared in etc/webapi_rest/di.xml
B. Every public method of every interface in the Api folder automatically is exposed as a REST endpoint
C. REST endpoints are declared in etc/rest.xml
D. REST endpoints are declared in etc/webapi.xml

Answer: D

Question No 4:

You are working on a custom web API endpoint and have configured it in etc/webapi.xml. This config is cached as part of the config_webservice cache type.

Keeping performance in mind, how do you refresh the cached version of this config using Magento CLI?

A. cache:clean config_webservice
B. cache:refresh config_webservice
C. cache:flush
D. cache:purge

Answer: A

Question No 5:

A third-party module uses a layout update that changes the template path for a core block from product/view/addto/compare.phtml of the Magento_Catalog module to custom/view/addto/compare.phtml of your custom module. The merchant has a customized version of this template in their custom theme. What is a consequence of this setup?

A. If the custom module is removed, the custom template will no longer apply
B. This setup will throw an IllegalStateException
C. If a preference for the core block is set, the template will no longer apply
D. If another module is installed which also customizes the same core template, the templates will be rendered sequentially

Answer: A