What are two functions of a resource model? (Choose two.)
- A . It executes create, retrieve, update and delete actions for an entity
- B . It loads lists of entity models
- C . It is made available in the Magento API for the purpose of data manipulation
- D . It maps an entity to one or more database rows
A,D
Explanation:
https://devdocs.magento.com/guides/v2.4/architecture/archi_perspectives/persist_layer.ht ml
There are two different configurable products which both share one variation. The shared variation is represented by the same simple product.
A customer added both configurables to the cart with the same selected variation?
How will they be displayed?
- A . As two separate line items with quantity 1 each
- B . As one line item which lists both configurable products with quantity 1 each
- C . As one line item of the first product with quantity 2
- D . As one line item of the second product with quantity 2
You need to add the Google Tag Manager (GTM) to every page.
What three steps do you take to accomplish this in MyCompany_MyModule?
- A . Add into view/frontend/layout/default.xml.
- B . Create view/frontend/layout/default.xml.
- C . Create view/frontend/templates/script.phtml and add GTM code.
- D . Run bin/magento create:module:template script.phtml
- E . Copy vendor/module-catalog/view/template/script.phtml to view/template/script.phtml and add GTM script.
A merchant requires the ability to configure contact information for their brick and mortar stores as a CSV file upload. The module already exists and contains an etc/adminhtml/system.xml file where the new field can be added.
How do you specify the class that will process the uploaded file?
- A . <upload_model>MagentoConfigModelConfigUploadFile</upload_model>
- B . <frontend_model>MagentoConfigModelConfigFrontendFile</frontend_model>
- C . <backend_model>MagentoConfigModelConfigBackendFile</backend_model>
- D . <source_model>MagentoConfigModelConfigSourceFile</source_model>
As you are scanning folder in the vendor/module-catalog directory, you see a directory that is named Ui.
What is this folder’s purpose?
- A . It contains UI component data providers and component information.
- B . It contains templates, CSS and JS pertinent to the module.
- C . It contains the block PHP files that render HTML onto the frontend.
- D . It is not a normal folder and further investigation is necessary to determine the purpose.
How many shipping addresses may be selected for an order during the checkout process?
- A . One shipping address per line item is possible
- B . Only one shipping address per order is possible
- C . One shipping addresses per unit of quantity is possible
- D . One shipping address per product type is possible
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 . MagentoCatalogModelResourceModelProduct::load($productModel, $id)
- B . MagentoCatalogModelResourceModelProductCollection::load()->fetchById($id)
- C . MagentoCatalogModelResourceModelProductCollection::fetchItemById($id)
- D . MagentoCatalogApiProductRepositoryInterface::getById($id)
A custom module needs to log all calls of MagentoCustomerApiAddressRepositoryInterface::save().
Which mechanism do you use?
- A . An observer on the customer_address_repository_save event, which is automatically fired for every repository save
- B . A proxy configured to intercept all calls to any public method and log them
- C . An extension attribute configured in the extension_attributes.xml
- D . A plugin declared for the save() method
The module MyCompany_MyModule provides custom admin interface pages.
Access to these pages should only be granted to specific users.
You add the required configuration to the module’s acl.xml file, but the setting does not seem to work as expected.
How do you visually check if Magento evaluates your ACL resource as expected?
- A . Write a plugin for the class MagentoFrameworkAclLoaderInterface::populateAcl() and echo out the loaded roles
- B . Inspect the output of the CLI command bin/magento admin:role:resources C all
- C . In the browser, open the admin User Roles page. Choose a role and inspect the tree of available resources
- D . Inspect the response of a GET request to the webapi endpoint http://example.com/rest/V1/acl/resources
Your module adds a new controller class which will return a JSON response.
What will be the return type of the execute method?
- A . You should implement a new API endpoint instead of returning JSON from a controller
- B . The string value of Zend_Json::encode()
- C . An instance of MagentoFrameworkControllerResultJson
- D . No return needed, an object that can be converted to JSON must be set as the
Response body
How do you pass an array [‘one’, ‘two] as a parameter to you block using the layout XML arguments directive?
- A . Option A
- B . Option B
- C . Option C
- D . Option D
A Magento industry partner shipping provider has tasked you to build their integration module called MyCompany_ShippingProvider.
Where do you define the class that provides options for the select field that enables or disables the provider in the file etc/adminhtml/system.xml?
- A . <option_model>MagentoConfigModelConfigOptionYesno</option_model>
- B . <source_model>MagentoConfigModelConfigSourceYesno</source_model>
- C . <frontend_model>MagentoConfigModelConfigFrontendYesno</frontend_model>
- D . <backend_model>MagentoConfigModelConfigBackendYesno</backend_model>
A custom module is performing an optimized custom query for quote items.
The class applies the query customizations on the select object of a quote item collection instance.
You are tasked to resolve an issue where the query sometimes does not deliver the expected results. You have debugged the problem and found another class is also using a quote item collection and is loading the collection before the custom module.
How do you resolve the issue, keeping maintainability in mind?
- A . You change the argument type toMagentoQuoteModelResourceModelQuoteItemCollectionFactory and instantiate the collection using $collectionFactory->create();
- B . You remove the constructor argument and use ObjectManager::getInstance()->create(MagentoQuoteModelResourceModelQuoteItemCollection::class) to instantiate the collection instead.
- C . You inject MagentoFrameworkDBSelect instead of the collection and perform the desired query independently of the collection.
- D . You inject MagentoQuoteApiCartItemRepositoryInterface because low level query customizations are not allowed.
A merchant tasks you to keep sales managers out of the system configuration backend pages.
How do you do that using the admin interface?
- A . You remove access to the restricted pages from each user’s ACL settings
- B . You create a role with limited permissions and assign all sales manager users to the new role
- C . This is not possible in a native Magento instance and requires customization
- D . You create a role with access to the system configuration pages and assign it to all users except the sales managers
A merchant tasked you to add an input field for notes to the Customer Account Information backend page.
Which three actions do you specify in a module’s Data Patch to add a customer notes attribute? (Choose three.)
- A . $cache->clean([‘eav’, ‘db_ddl’]);
- B . $customerSetup->addAttribute(‘customer’, ‘notes’, $options);
- C . $customerSetup->getConnection()->addColumn(‘customer_entity’, ‘notes’, $columnSpecs);
- D . $notesAttribute->setData(‘used_in_forms’, [‘adminhtml_customer’]);
- E . $customerSetup->addAttributeToSet(‘customer’, $attributeSetIdCustomer, $groupId, ‘notes’);
You want to remove a column introduced by a third-party extension via declarative schema.
How do you do that?
- A . Create the etc/db_schema.xml file and specify disable=”true” on the column
- B . Modify the original etc/db_schema.xml file and remove the column from there
- C . Create a SchemaPatch file and remove the column programmatically
- D . Copy the etc/db_schema.xml file into your module and remove the column from your copy
You need to find all orders in the processing state. You have written the code:
How do you resolve the exception?
- A . Use dependency injection to load an instance of the SearchCriteria class
- B . Change the getList parameter to: $searchCriteraBuilder->addFilter(‘state’,’processing’)->create()
- C . Clear generated code to get a new version of SearchCriteriaBuilder
- D . Specify a preference in di.xml to map SearchCriteriaBuilder to SearchCriteriaInterface
How do you add a foreign key to an existing table created by another module?
- A . Create etc/db_schema.xml file with the table node and constraint child node
- B . Run the command bin/magento setup:db-schema:upgrade <table> <constraint declaration>
- C . This can only be done with raw SQL in a Schema Patch file
- D . Create the etc/db_constraints.xml file and specify foreign key there in the constraint node
A
Explanation:
https://magento.stackexchange.com/questions/192317/magento-2-how-to-add-foreign-key-in-update-schema
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
You see this code in etc/adminhtml/routes.xml:
<route id="mymodule" frontName="user-subscriptions">
<module name="MyCompany_MyModule" />
</route> You have placed a controller in Controller/Index/Subscribe.php.
If you want to create layout XML instructions for this controller, what would be the layout XML’s filename?
- A . mymodule_index_subscribe.xml
- B . mymodule_subscribe_[ACTION NAME].xml
- C . user_subscriptions_index_subscribe.xml
- D . user_subscriptions_subscribe_[ACTION NAME].xml
You have created a module to show manufacturer-list, but in your page need to show Pagination that already ready in your block. Keeping maintainability in mind, where you call echo $block->getPagerHtml();?
- A . /Manufacturer/view/frontend/templates/content.phtml
- B . /Manufacturer/Block/Index.php
- C . /Manufacturer/Controller/Index/Index.php
- D . /Manufacturer/view/frontend/layout/manufacturer_index_index.xml
The constructor function for MagentoCatalogModelCategory contains this excerpt:
With the automatic dependency injection that Magento provides, how is the StoreManagerInterface resolved?
- A . If no $storeManager is provided, Magento’s code generator creates a shell concrete class based on MagentoStoreModelStoreManagerInterface
- B . Magento finds all classes that implement MagentoStoreModelStoreManagerInterface (ordered alphabetically) and injects the first class.
- C . Magento looks to the di.xml files in the entire system for a preference node for MagentoStoreModelStoreManagerInterface. This class is constructed and injected
- D . Magento throws an exception because you cannot instantiate an interface
C
Explanation:
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/depend-inj.html
You are adding a new menu item to the admin backend which will link to a custom backend page.
The declaration of the route:
What do you specify as the menu item action attribute value so it links to /admin/mycompany/mymodule/?
- A . action=”adminhtml/mycompany/mymodule/”
- B . action=”admin/mycompany/mymodule/”
- C . It is not possible without extending the adminhtml route in routes.xml
- D . action=”mycompany/mymodule/”
You are creating a new indexer which must run after the targetrule_product_rule index process. When you run bin/magento indexer:reindex, your rule always runs first creating inaccurate data.
What is the resolution?
- A . Use a dependencies node in your indexer configuration.
- B . Specify the sortOrder in your indexer configuration.
- C . Use a plugin on the IndexManager class to change load order.
- D . Create a bash script to execute each indexer in the correct order.
You are developing a module and need to add another column to a table introduced by another module MyCompany_MyModule via db schema.
How do you do that?
- A . Create a etc/db_schema.xml file in your module, add the column and run bin/magento setup:upgrade
- B . Create a etc/db.xml file in your module, add the column and run bin/magento setup:db-schema:upgrade
- C . Run a command: bin/magento setup:db-schema:upgrade <table> <column definition>
- D . Create a etc/db_schema_whitelist.json file in your module, add the column and run bin/magento setup:upgrade
In a code review of a merchant’s site you have discovered that there are multiple observers for the checkout_submit_all_after event. After closer inspection, you notice one of these observers is relying on the others being executed before it is called.
What risk does this pose, and how can it be mitigated?
- A . There is no risk posed as long as each event observer specifies a correct sortOrder. Nothing needs to be changed.
- B . Event observers are fired in alphabetical order of the observer name. There is no risk here.
- C . Magento only supports one observer per event. These observers will need to be combined into a single point of customization.
- D . Order of listener execution cannot be guaranteed, resulting in a fragile implementation. This code should be re-worked using plugins
You are reviewing a Magento module and see a directory named Service.
What can you determine from this directory’s name?
- A . It is where the API response cache is stored
- B . It is where API-related configuration resides
- C . It is where the module’s service contracts are stored
- D . You need to review the files in this folder to understand its purpose
A module MyModule needs to send notifications to customers only when the account was modified from a mobile app using the REST web APIs.
You decided to implement an observer for customer_save_after_data_object event.
In which file do you declare the observer?
- A . etc/webapi_rest/events.xml
- B . etc/adminhtml/events.xml
- C . etc/webapi/rest_events.xml
- D . etc/events.xml
You are building an tool that imports products from an ERP. There are 20 columns of additional information that are associated with each product. This extra information must also be associated with an update time to know when to refresh the data.
Keeping maintainability in mind, how do you build this into Magento?
- A . Utilize an extension attribute.
- B . Override the Product model and add the fields.
- C . Create a separate model and build code to associate the two record types.
- D . Create 20 EAV attributes and check their updated_at column.
In layout files you can change al element’s order on a page.
This can be done using one of the following:
✑ <move> instruction
✑ before and after element attributes?
How are two methods different?
- A . They are the same, both provide access to the same functionality
- B . Elements are renamed by default when using the move instruction
- C . The move instruction allows altering an element’s parent node
- D . Before and after attributes can only be used with referenceContainer and referenceBlock
You have created a custom module which must perform an action immediately after an order is placed, but only on the store front of the merchant site. You have selected the checkout_submit_all_after as the target event which the module will observe.
In which file will the event observer be declared?
- A . etc/frontend.xml
- B . etc/events.xml
- C . etc/config.xml
- D . etc/frontend/events.xml
There is a custom extension called MyCompany_MyModule.
It has the following layout customization declared in MyCompany/MyModule/view/frontend/layout/default.xml:
<referenceContainer name=”content”>
<block class=”MagentoFrameworkViewElementTemplate”
name=”my.block”
template=”MyCompany_MyModule::my_template.phtml”
cacheable=”false”/>
</referenceContainer>
What will be the result of the customization?
- A . All store front pages will be non-cacheable
- B . Only the default landing page will be non-cacheable
- C . my.block on the default landing page only will be cached using ESI.
- D . my.block on the all store front pages will be cached using ESI
You have configured an event observer to watch the checkout_submit_all_after event using this XML:
What is the required class definition for the event observer?
- A . Option A
- B . Option B
- C . Option C
- D . Option D
You are building a new module to add extra functionality to the Magento application.You want to works with CustomerData the data stored on the client side.
Where initialized sections Cart and Directory-data are on the server side via the classes?
- A . MagentoCheckoutCustomerDataCart and
MagentoCheckoutCustomerDataDirectoryData - B . MagentoCheckoutApiCart and MagentoCheckoutApiDirectoryData
- C . MagentoCheckoutBlockCart and MagentoCheckoutBlockDirectoryData
- D . MagentoCheckoutPluginCart and MagentoCheckoutPluginDirectoryData
You are working on a project that contains a million SKUs. The merchant has requested the product view page to have a custom color schema and page layout depending on the product price range.
How do you implement this, keeping simplicity in mind?
- A . Create a custom block which will dynamically choose the appropriate template
- B . Specify custom layout update XML in the admin panel for every product
- C . Write a Data Patch which will set the appropriate layout update XML for every product record
- D . Enable the dynamic product page UI component and configure it to use a different layout per price range
A
Explanation:
https://www.rohanhapani.com/magento-2-change-product-view-page-layout-based-on-price/
A module declares the route:
What is the layout handle of the storefront path /custom/feature/?
- A . mymodule_feature
- B . custom_feature
- C . mymodule_feature_index
- D . custom_feature_index
Assume that $collection is a new instance of a class that extends MagentoFrameworkModelResourceModelDbCollectionAbstractCollection, and $ids is an array of ids.
How do you select a list of records from the database where the record ids are in the $ids list?
- A . Option A
- B . Option B
- C . Option C
- D . Option D
You have loaded an instance of MagentoCatalogModelProduct in the $product variable. You know that the loaded product has the type configurable with four variations. These variations have the prices: $10, $12, $12, $15.
What will be the result of the $product->getFinalPrice() call?
- A . [10, 12, 15]
- B . 10
- C . [10, 12, 12, 15]
- D . 15
You are trying to determine why a product is not appearing in a category.
What table does Magento on the frontend to locate the relationship between a category and its products?
- A . catalog_category_product
- B . catalog_product_parent
- C . catalog_category_product_index
- D . catalog_category_product_relationship
What order operation is available in the My Account section in the storefront?
- A . Edit order
- B . Refund
- C . Reorder
- D . Invoice