CD206

Ms Rani
Quiz by Ms Rani, updated 9 months ago
Ms Rani
Created by Ms Rani 11 months ago
285
2

Description

Quiz on CD206, created by Ms Rani on 10/21/2019.

Resource summary

Question 1

Question
What functions are handled by a product’s type instance? (Select 4)
Answer
  • Preparing a product to be added to the cart.
  • Loading child products.
  • Determining the SKU for the product.
  • Calculating the product’s final price.
  • Triggering the catalog_product_is_salable_before event.

Question 2

Question
Magento offers two commands that apparently clear the cache: bin/magento cache:clean and bin/magento cache:flush. Why is cache:clean the better command to run?
Answer
  • cache:clean deletes all items from enabled Magento cache types only.
  • cache:clean deletes all cache entries for disabled cache types.
  • cache:clean removes all out-dated cache entries.
  • cache:clean removes entries that are associated with cache tags.

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.
  • Create an after plugin for the \Magento\Sales\Block\Order\History::setTemplate.
  • In sales_order_history.xml add: <referenceBlock name=”sales.order.history”><arguments><argument name=”template” xsi:type=”string”>...</argument></arguments>
  • In sales_order_history.xml add: <referenceBlock name=”sales.order.history” template=”...”/>

Question 4

Question
You are creating a new shipping method that will connect to an online shipping API. What class or interface does Magento require that you extend or implement?
Answer
  • Nothing is required
  • Magento\Shipping\Model\Carrier\AbstractCarrierOnline
  • Magento\Shipping\Model\Carrier\CarrierInterface
  • Magento\Shipping\Model\Carrier\AbstractCarrier

Question 5

Question
You are asked to override product/image.phtml in Magento_Catalog with a custom template in your theme, MyCompany_MyTheme. Where do you place this file?
Answer
  • app/design/frontend/MyCompany/MyTheme/Magento_Catalog/templates/product/image.phtml
  • app/design/frontend/MyCompany/MyTheme/templates/Magento_Catalog/product/image.phtml
  • app/design/frontend/MyCompany/MyTheme/Magento_Catalog/override/product/image.phtml
  • app/design/frontend/MyCompany/MyTheme/Magento_Catalog/product/image.phtml

Question 6

Question
You are needing to create a new cron group for custom functionality that you are building. Where do you store the default configuration options in your module?
Answer
  • etc/cron_groups.xml
  • etc/di.xml
  • etc/config.xml
  • etc/adminhtml/system.xml

Question 7

Question
You have built a module called ABC_MyModule that updates values in the catalog_category_entity table. Users are reporting that when they add the module to a Magento project before installing Magento for the first time, those values are not updated. What is the resolution?
Answer
  • Use getDependencies to ensure that the categories are created first.
  • Utilize theUpgradeData class instead of InstallData.
  • Add logic to check if categories are not created. Send store owner a email notification to re-run setup:upgrade
  • Add instructions to never install module unless Magento is installed first.

Question 8

Question
You are adding a fee total model to quotes. What class should your new total model extend?
Answer
  • Magento\Quote\Model\Quote\Address\Total\AbstractTotal
  • Magento\Sales\Model\Quote\Total\AbstractTotal
  • Magento\Sales\Model\Total\AbstractTotal
  • Magento\Quote\Model\Address\AbstractTotal

Question 9

Question
You are instructed to set a cookie on a Magento website. This cookie must be set after any controller is finished executing and only set if the resulting HTML contains a specific word. What event is executed at the correct timing to facilitate the requirements?
Answer
  • controller_front_send_response_before
  • controller_router_match_after
  • controller_before_set_response
  • controller_front_process_response_before

Question 10

Question
In a Magento block, what is the protected method that is called in the setLayout method, but before _toHtml?
Answer
  • _prepareLayout()
  • _toHtml()
  • _beforeToHtml()
  • _afterSetLayout()

Question 11

Question
You are a module vendor and are providing a version of your module that is friendly to DB Schema in Magento 2.3. You would like to split out your old upgrade scripts to the new patch format. How do you ensure that these scripts will not be executed twice?
Answer
  • Specify the applicable version in your setup script.
  • Specify the applicable module version when you add the patch to etc/db_schema.xml.
  • Provide instructions on how to add applicable patches to patch_list table.
  • Combine all upgrades into one patch and check a saved value in the config table.

Question 12

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

Question 13

Question
Where is the base template file for all Magento HTML requests located?
Answer
  • vendor/magento/module-theme/view/base/templates/root.phtml
  • vendor/magento/module-page/view/base/templates/primary.phtml
  • vendor/magento/module-core/view/base/templates/base.phtml
  • vendor/magento/module-ui/view/base/templates/default.phtml

Question 14

Question
You are building a new module that needs to utilize a custom URL path like: /maps/{MAP_ID} What steps do you take to accomplish this?(Select 2)
Answer
  • In di.xml, add your router to the RouterList class' routerList parameter
  • Create a class that implements RouterInterface and configure in di.xml.
  • Create an interface that extends RouterInterface details additional methods added.
  • Create a plugin for the RouterList class to insert your router into the selection criteria.

Question 15

Question
You are building functionality that saves the values of many models in a for loop. To boost performance, you wrapped the for loop in beginTransaction and commit. After doing this, you are getting a “Integrity Violation Constraint” in an observer you created for the _after_save event for this model. Keeping maintainability in mind, what is the solution?
Answer
  • Switch the observer for _after_save to observe _save_commit_after.
  • Remove the foreign key.
  • Remove the observer and add the code directly to the model’s afterSave method.
  • Utilize an after plugin for the model’s save method.

Question 16

Question
What is the purpose of the getFlatColumns method in an EAV's Source model?
Answer
  • It returns columns that will be added to the EAV model's flat table.
  • It converts option values into row values for the attribute value tables.
  • It flattens an array attribute value into a JSON string.
  • It returns a list of columns in the entity's _text table.

Question 17

Question
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?
Answer
  • Create Conditions rules for the specific requirements.
  • Use the Actions rules for the specific requirements.
  • This is not possible without a 3rd-party customization.
  • Add a Product filter to the Apply To rules for the specific requirements.

Question 18

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

Question 19

Question
You have written the following code in your module’s etc/adminhtml/menu.xml file to add a new menu item to the Content menu: <menu> <add id="MyCompany_MyModule::Menu" title="Field Help Items" module="MyCompany_MyModule" parent="Magento_Backend::content" resource=”MyCompany_MyModule::menu_item”/> </menu> Yet, when you click on the menu item, nothing happens. What is the problem?
Answer
  • The action attribute is missing from the add node.
  • The add node should be addLink.
  • No details were specified in etc/adminhtml/routes.xml.
  • The module is not a valid module.

Question 20

Question
A module contains the following files: ModuleA/ |-- etc/ |-- di.xml |-- frontend/ |-- di.xml When a visitor is browsing the frontend of the website, what happens if a similar XML directive is specified in both di.xml files above?
Answer
  • The two di.xml files are merged with etc/frontend/di.xml taking precedence.
  • An error is thrown: Conflicting values are found in etc/di.xml and etc/frontend/di.xml
  • etc/di.xml is used instead of etc/frontend/di.xml.
  • etc/frontend/di.xml replaces etc/di.xml.

Question 21

Question
What layout handle contains the layout instructions for rendering a product’s price?
Answer
  • catalog_product_prices
  • default
  • catalog_category_view
  • catalog_product_view

Question 22

Question
You performing a code review on an existing module. You see some interesting files in the Setup/ folder.What files in the Setup/ does Magento understand? (Select 3)
Answer
  • Setup/InstallSchema.php
  • Setup/RecurringData.php
  • Setup/UpgradeSchema.php
  • Setup/Migrations/...php
  • Setup/InstallDetails.php

Question 23

Question
You are writing a new admin form uiComponent. The table that you are loading data from has an id column. However, you need to send the data back to the controller with the save_id key and NOT the id key.How do you do this? (Select 2)
Answer
  • Create a custom data provider class that extends \Magento\Framework\...\DataProvider.
  • In the dataSource node, set the save.
  • Create a plugin for \Magento\Framework\...UiComponent\Context.php and change the requestId parameter.
  • In your admin controller that loads the uiComponent’s page, add a requestIdVariable value to the registry.

Question 24

Question
Magento's Product repository uses the getList($filter) method retrieve a list of products. As you are preparing to retrieve a list of products, you need to specify what products to retrieve. Which of the following classes will help you formulate the filter?
Answer
  • \Magento\Framework\Api\SearchCriteriaBuilder
  • \Magento\Framework\Api\SearchFilterBuilder
  • \Magento\Framework\Api\RepositorySearchBuilder
  • \Magento\Framework\Api\AppSearchBuilder

Question 25

Question
You are upgrading a Magento website from version 2.2 to 2.3. In the process of doing this, you see this error: Cannot process definition to array for type tinytext . How do you resolve this error?
Answer
  • Locate the table that contains a column type of tinytext and change to something else.
  • Disable DB Schema in app/etc/env.php.
  • Locate the DB Schema definitions in app/etc/db_schema.xml and enable the tinytext type.
  • Install a vanilla version of Magento, then re-copy the database over the newly-installed table.

Question 26

Question
You have loaded NewCompany_NewModule through composer. This module has the following plugin statement: <type name="ClassName"><plugin name="NewModulePlugin" type="NewModuleClass" sortOrder=”20”/></type> You found that this plugin has a afterDoAction method that depends on data that has been altered with your customizations. As a result of your alterations, the above after plugin throws a fatal PHP error. How can you adjust the data before it reaches this plugin?
Answer
  • Create a new after plugin with a sortOrder=”30”.
  • Adjust the module load order to load your custom module before NewCompany_NewModule
  • Override the original method and adjust the data that is being returned.
  • Adjust the code in NewCompany_NewModule to prevent the fatal PHP error.

Question 27

Question
What ways are possible to wrap a block with an HTML tag? (Select 2)
Answer
  • Add the tag to the template.
  • Layout XML container
  • Listen to the core_block_html_output_after event.
  • Add a plugin for the afterHtml method.

Question 28

Question
You are tasked with creating a new EAV attribute. What steps do you take to be able to call the addAttribute method? (Select 2)
Answer
  • Inject and use an instance of EavSetup.
  • Create a new data patch.
  • Utilize the module’s UpgradeData class.
  • Use the ModuleDataSetup class.

Question 29

Question
You are creating a new category in a setup script. Which attributes are required? (Select 3)
Answer
  • Is Active
  • Available Product Listing Sort By
  • Name
  • Is Anchor
  • URL Key

Question 30

Question
You are troubleshooting a product with a price of $25. The special price is $20 and is active through 2017. The tiered pricing has a discount for 2 or more products at $22.00. Additionally, a catalog price rule applies a 10% off discount. What is the final price that is shown on the product page?
Answer
  • $22.50
  • $18.00
  • $22.00
  • $20.00

Question 31

Question
Where are admin uiComponents located?
Answer
  • view/adminhtml/ui_component/[COMPONENT NAME].xml
  • view/components/[COMPONENT NAME].xml
  • view/components/adminhtml/[COMPONENT NAME].xml
  • view/adminhtml/layout/[COMPONENT NAME].xml

Question 32

Question
You need to create a variation of the 2columns-left page layout. This new layout is named text.How do you instruct Magento regarding the new layout type?
Answer
  • Create view/frontend/layouts.xml with a <layout/> node.
  • Insert text in to the layouts table.
  • Create a new page_layout.xml in the applied theme with <type name="text"/>.
  • Create view/frontend/layout/text.xml, with <update handle="2columns-left"/>.

Question 33

Question
What additional tools are available in the backend and not in frontend? (Select 3)
Answer
  • ACL
  • URL secret keys
  • Global records search
  • uiComponents
  • Redis cache storage

Question 34

Question
A merchant has asked you to setup a 20% sale on all products in the Men’s Tops category, such that the discount is visible on the product page. What Magento feature is best utilized for this?
Answer
  • Catalog Price Rules
  • Cart Price Rules
  • Special Price for each product
  • Tiered Pricing

Question 35

Question
You have created a custom theme and need to customize the view/frontend/templates/product/list.phtml file in the Magento_Catalog module. Where do you place this file inside your theme?
Answer
  • Magento_Catalog/templates/product/list.phtml
  • templates/product/list.phtml
  • templates/Magento_Catalog/product/list.phtml
  • Magento_Catalog/templates/override/product/list.phtml

Question 36

Question
You are investigating a Continuous Integration build script and see this command: bin/magento setup:static-content:deploy --jobs=2 What is the effect of the --jobs flag?
Answer
  • Parallel PHP processes are started to process assets faster.
  • Causes the built content to be multiple-node ready.
  • Prevents Magento from including too many theme dependencies.
  • Content deployment is metered to reduce memory utilization.

Question 37

Question
You see this code in etc/frontend/routes.xml: <route id="mymodule" frontName="user-subscriptions"> <module name="MyCompany_MyModule" /> </route> You have placed a controller in Controller/Index/Subscribe.php. At what URL would you visit the controller listed above?
Answer
  • /user-subscriptions/index/subscribe
  • /mymodule/index/subscribe
  • /user-subscriptions/subscribe
  • /mymodule/subscribe

Question 38

Question
You are tasked with changing a column’s name in a module built for a merchant using Magento 2.3. After changing the column’s type in etc/db_schema.xml, what two actions do you take? (Select 2)
Answer
  • Re-generate the module’s whitelist.
  • Use the migrateDataFrom keyphrase.
  • Create a patch file to delete the old column.
  • Increase the module’s version.

Question 39

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? (Select 2)
Answer
  • SearchCriteriaBuilder should be used instead of SearchCriteria.
  • Sort order should not be specified as a string.
  • Sort orders must be added one at a time with the addSortOrder method.
  • One line 2, when loading $search, you need to use $search->getCriteria().

Question 40

Question
You need to perform a string replacement for some words in a Magento block. The string replacement should not happen globally throughout the system. Keeping maintainability in mind, how do you accomplish this?
Answer
  • Create a after plugin for the block’s toHtml method.
  • Override the block with a preference in the di.xml module.
  • Create a translation for the words to replace.
  • Override the block’s template to make the change.

Question 41

Question
Which Magento features use or require a customer group? (Select 2)
Answer
  • Cart Pricing rules
  • Tiered pricing
  • Content widgets
  • Online customers report

Question 42

Question
How do you make a new category attribute available to be edited in the admin panel?
Answer
  • Add the new attribute to the category_form.xml uiComponent.
  • This is done automatically.
  • In the data setup script, add the attribute to the category's default attribute set.
  • Create a plugin for the `Form` class that renders the category form and add the extra field.

Question 43

Question
You need to programmatically create a new customer attribute. What steps are required to do this? (Select 3)
Answer
  • Save the attribute.
  • Specify the used_in_forms data for the attribute.
  • Create the attribute with \Magento\Eav\Setup\EavSetup::addAttribute
  • Set the source_model value for the attribute.
  • Add the attribute to the customer_eav_attribute table.

Question 44

Question
What requirejs-config.js configuration node allows you to replace another RequireJS module?
Answer
  • map
  • replace
  • shim
  • paths

Question 45

Question
You are creating a module that adds a free item into the cart when another item is present. The last part of this is to also remove the free item when the originating item is removed. Where do you plug in to accomplish this?
Answer
  • Magento\Checkout\Model\Cart::removeItem
  • Magento\Checkout\Model\Cart::save
  • Magento\Quote\Model\Quote::removeItem
  • Magento\Quote\Model\Quote\Item::setQty

Question 46

Question
You have successfully added a new link to the sidebar of the customer account. However, the merchant just came back to you that they would like some authentication built in: the customer must only be able to see this link if they have placed an order. Keeping maintainability in mind, how do you accomplish this?
Answer
  • Use a plugin to add the link to the Navigation block.
  • Replace the sidebar.phtml template to add conditional logic.
  • Override the AccountSidebar class because the necessary method is protected.
  • Use the helper attribute in the block declaration.

Question 47

Question
What interface allows you to access values saved in Store > Configuration?
Answer
  • \Magento\Framework\App\Config\ScopeConfigInterface
  • \Magento\Framework\App\Store\ConfigInterface
  • \Magento\Backend\Api\Data\StoreScopeConfigInterface
  • \Magento\Store\Api\Data\StoreConfigInterface

Question 48

Question
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? (Select 2)
Answer
  • Ensure the extension attributes property is an object.
  • Use after plugins in customer repository and collection.
  • Create an observer for the customer_load_after event.
  • Specify a extensionAttributeLoader in the db_schema.xml

Question 49

Question
What are valid plugin types: (Select 3)
Answer
  • after
  • around
  • before
  • instead
  • post

Question 50

Question
When creating a form field with a Magento PHP block grid, what configuration key prevents editing of the field?
Answer
  • disabled => true
  • allow_entry => false
  • visible => false
  • enabled => false

Question 51

Question
You need to create a custom price calculator for simple products. You have already created the new price model. Keeping simplicity in mind, what additional steps do you take to implement this? (Select 2)
Answer
  • In your product_types.xml module, reference the simple product type, and set a value for the priceModel attribute.
  • Make your new price model extend \Magento\Catalog\Model\Product\Type\Price.
  • Create a plugin for the getPriceModel() method and return your price model.
  • Update the frontend templates to use the new price methods.

Question 52

Question
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?
Answer
  • 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 must have a default value set—no default value is appropriate here.
  • The store scope is only available when a specific store is selected.

Question 53

Question
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?
Answer
  • sales_quote_add_item
  • sales_quote_product_add_after
  • checkout_cart_add_product_complete
  • cart_add_item_after

Question 54

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
  • Override the Order model to add a getComments method.
  • Ensure the comments key is in the Order model’s $data array.
  • Create a new REST API endpoint to fetch the comments per order.

Question 55

Question
You are tasked with building a new module to show product promotions to a customer. What two steps do you take to make the module active? (Select 2)
Answer
  • php bin/magento setup:upgrade
  • php bin/magento module:enable MyCompany_MyModule
  • php bin/magento deploy:mode:set developer
  • php bin/magento sampledata:deploy

Question 56

Question
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?
Answer
  • Retrieve the product.price.render.default block and call the render method.
  • Magento\Framework\Pricing\Renderer class and call the renderPrice method.
  • Use dependency injection to get an instance of the
  • Trigger the catalog_product_render_price event, attaching the product as event data.
  • Use the protected property, $priceRenderer injected in the $context in the Template.

Question 57

Question
Magento uses the concept of service contracts to create a blueprint for modules to communicate with each other. Where are these service contracts stored in a module?
Answer
  • Api/
  • Model/
  • Services/
  • Api/ServiceContracts/

Question 58

Question
You are investigating a problem on the staging server environment. Here is the error: The source file was not found. Stack trace: #0 vendor/magento/framework/App/View/Asset/Publisher.php(73): Magento\Framework\View\Asset\File->getSourceFile(). Where is Magento\Framework\View\Asset\File found?
Answer
  • vendor/magento/framework/View/Asset/File.php
  • lib/internal/Magento/Framework/View/Asset/File.php
  • app/code/Magento/Framework/View/Asset/File.php
  • vendor/magento/module-framework/View/Asset.php

Question 59

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

Question 60

Question
You need to add a fee (additional to tax and shipping) to every order placed. In what file do you specify the new total?
Answer
  • etc/sales.xml
  • etc/extension_attributes.xml
  • etc/di.xml
  • etc/totals.xml

Question 61

Question
Keeping maintability in mind, how do you customize the format of addresses in emails?
Answer
  • Stores > Configuration > Customers > Customer Configuration > Address Templates
  • Set the new template in etc/order_addresses.xml
  • Create a plugin for the \Magento\Sales\Order\Address::getFormatted method.
  • Use di.xml to add a new address formatter to \Magento\Sales\Model\Order\Address\FormatterList

Question 62

Question
You have written a free module that is distributed on GitHub. Unfortunately, people are reporting that they found a typo in the CMS block. How do you get this resolved?
Answer
  • Create a new data patch.
  • Fix the content in your module's UpgradeData class.
  • Tell users to update the content.
  • Switch to hardcoding the value into your module and release an update.

Question 63

Question
You are creating a new module and have specified this in the etc/module.xml: <module name=”MyCompany_MyModule” setup_version=”1.5.0”> <sequence name=”Magento_Catalog”/> </module> , However, after regenerating app/etc/config.php, the module load order is not changed. What is the solution?
Answer
  • Change the syntax for the sequence to <sequence><module name=”Magento_Catalog”/></sequence>
  • Add Magento_Catalog to the dependencies in composer.json
  • Clear the Magento cache.
  • Run bin/magento setup:regenerate:config

Question 64

Question
Keeping maintainability in mind, how do you add a new link to the customer account sidebar?
Answer
  • Create customer_account.xml and add a block to the customer_account_navigation.
  • Create customer_account_index.xml and add a block to the sidebar container.
  • Create customer_account_index.xml and add the link to the uiComponent configuration in jsLayout
  • Create a plugin for the customer Navigation class.

Question 65

Question
You have just completed building a new module and have tested that it works. You are now are ready to commit the code for review. This module uses extension attributes and stores data about orders, but in a separate table. What action must you take to ensure that this module will behave properly in production?
Answer
  • Create a schema whitelist for the module.
  • Ensure composer.json contains the correct version.
  • Double-check that the install process properly executes.
  • Add the module’s name to app/etc/config.php.

Question 66

Question
You are evaluating a 3rd-party module and you see some custom functionality that is executed in an observer of the checkout_cart_add_product_complete. This functionality is expected to run every time a product is added to the cart. Is there a problem?
Answer
  • Yes. This only is only triggered when the cart is added to the cart on the frontend and in no other case.
  • Yes. This event doesn't exist.
  • No: checkout_cart_add_product_complete is triggered as expected.
  • Yes. This event is used only triggered in the admin Sales > Order > Create process.

Question 67

Question
What must be done differently to properly generate a URL in the Magento backend?
Answer
  • Generate the URL from an instance of \Magento\Backend\Model\UrlInterface
  • Instead of calling the getUrl() method, you must call the getBackendUrl() method.
  • Nothing: generating URLs in the frontend and backend are the same.
  • Ensure that the controller is configured for the correct ACL path.

Question 68

Question
As part of a new feature you are writing, you are tasked with adding a new column to the catalog_product_entity table. However, when you update the value in $product->setData(‘my_column’, ‘value’);, you get this error: Cannot call getBackend() on non-object. What is the solution?
Answer
  • Create a new static attribute.
  • Flush the cache after adding the new column.
  • Use $product->setCustomAttributeValue instead.
  • Reindex to update flat table columns.

Question 69

Question
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?
Answer
  • 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.
  • Set the grid_column_type to be datetime in the customer_eav_attribute table.
  • Change the backend_type from date to datetime.

Question 70

Question
You are needing to reindex information when data in an entity table has been modified. You have already created an indexer and registered it in indexer.xml. The last step is to register the class that will be triggered when data is updated. Keeping upgradeability in mind, where do you make this registration?
Answer
  • Add a new view in mview.xml.
  • Create an observer for the _after_save event in observer.xml
  • Setup an extension attribute watcher in extension_attributes.xml.
  • Add <auto_reindex/> into the indexer registration in indexer.xml.

Question 71

Question
How do you configure a store configuration field to obscure input (password entry) and store that value securely? (Select 2)
Answer
  • Set the type=”obscure”.
  • Set the field’s backend_model node to be Magento\Config\Model\Config\Backend\Encrypted.
  • Add the attribute encrypted=”1”.
  • Set the field’s encryption_model node to be Magento\Config\Model\Config\EncryptedInterface.

Question 72

Question
Magento's JavaScript application has a means to instantiate a object through RequireJS. What is the correct node to do this?
Answer
  • <script type="text/x-magento-init">
  • <script type="text/javascript">
  • <script type="application/magento" src="path/to/script.js">
  • <script type="text/require-js" module="path/to/module">

Question 73

Question
Which native Magento products are also composite products? (Select 2)
Answer
  • Grouped
  • Bundle
  • Simple
  • Kit

Question 74

Question
You are creating an admin uiComponent form. You have written this code for an email field: <!-- … --> <input name="email"> <settings> <dataType>text</dataType> <label translate="true">Email</label> </settings> </input> <!-- … --> However, no data is loading into the email field. What is the solution?
Answer
  • Add a <dataScope>email</dataScope> element into the <settings/> tag.
  • Utilize the textEntry type instead of input.
  • Configure the data source class to load the email data.
  • Change the <dataType> contents to email.

Question 75

Question
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?
Answer
  • Create an after plugin for Magento\Customer\Model\Vat::checkVatNumber method.
  • Observe the customer_validate_vat_id_after event.
  • Change the Stores > Configuration > Customer > VAT Validation Fallback method to be “Regex”.
  • Override the Magento\Quote\Model\VatValidator::validate method.

Question 76

Question
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? (Select 3)
Answer
  • Specify the date component for the component attribute.
  • Set the date type for the dataType setting.
  • Utilize the date node type.
  • Add a data/config/dateFormat node.
  • Specify the Date module for the class attribute.

Question 77

Question
What is the difference between setting cacheable="false" on a block in layout XML attribute and the block's getCacheLifetime() === null?
Answer
  • cacheable="false" prevents the entire page from caching. getCacheLifetime() === null prevents the block from being cached, but it would still be cached by the full page caching mechanism.
  • cacheable="false" and the effect of getCacheLifetime === null are the same.
  • cacheable="false" affects the parent block or container. getCacheLifetime() === null prevents the current block from being cached.
  • cacheable="false" prevents a block from being cached. getCacheLifetime() has been deprecated.

Question 78

Question
What container contains the columns container?
Answer
  • main.content
  • page.wrapper
  • columns.wrapper
  • main

Question 79

Question
You have successfully added a new customer attribute to the eav_attribute_entity table. You also have imported some customers into the system with this attribute value specified, and those values are present in the customer_entity_varchar table. However, no entry field for this attribute is present in admin view of the customer. Keeping maintainability in mind, what is the resolution?
Answer
  • Ensure the appropriate value is configured in the used_in_forms.
  • Set the attribute to be visible_in_adminhtml.
  • Add the attribute to the correct areas with the customer form uiComponent.
  • Clear the Magento EAV cache.

Question 80

Question
You have configured a new Catalog Price Rule on Open Source edition. Even after double-checking that the Conditions match products, the updates are not going into effect. No errors are being thrown when the rule is saved. What is the solution?
Answer
  • You need to click “Apply Rules” on the Catalog Price Rules page.
  • A 3rd-party module is preventing the rules from saving.
  • The Magento cron is not running.
  • The cache needs to be flushed.

Question 81

Question
You are customizing a very basic Magento installation that is using the Luma theme. You are requested to alter the code in the Magento_Catalog::product/list.phtml template. Keeping upgradeability in mind, how do you do this?
Answer
  • Create a new theme and copy the template into the appropriate directory inside the new theme.
  • In a custom module, create a layout XML file that changes the template attribute to a new template.
  • Add layout XML to the Content > Design > Theme page.
  • Override the Magento\Catalog\Block\Product\List block to specify a new template file.

Question 82

Question
Due to some legacy coding practices and an integration with an ERP, a product’s attribute value is stored as a JSON array. On the frontend, the value is expected to be unserialized into a PHP array. How do you intercept all saving and loading operations for an attribute?
Answer
  • Create a backend model class for the attribute and set this model as the attribute’s backend model.
  • Create plugins for the product resource model’s save and load methods.
  • Add a helper attribute in the attribute’s declaration in etc/eav.xml.
  • Create plugins for the Product::beforeSave and Product::afterSave methods.

Question 83

Question
You have just created the following acl.xml file in your module: <acl> <resources> <resource id="MyCompany_MyProject::DoSomething" title="Do Something"/> </resources> </acl> After deploying code, the merchant complains that they cannot find “Do Something” in the Role Permissions dialog. What is the solution?
Answer
  • The backend node is missing.
  • The merchant needs to log out and then back in.
  • The cache needs to be flushed.
  • The parent attribute need to be specified.

Question 84

Question
What only happens in the Production deploy mode?
Answer
  • Errors are only logged, not shown to the user.
  • Automatic code file compilation / generation happens as needed.
  • Static assets are created when the user downloads them.
  • Performance is faster because symlinks are established in the pub/static folder.

Question 85

Question
You are helping a merchant who is very distraught: they imported a CSV file, and the values for several custom attributes were reset to “0”. You found that the CSV file did not contain the additional_attributes column and the import behavior was Replace. What is the problem?
Answer
  • The attribute values were reset to the default value.
  • There is an error in a custom module that is resetting these values.
  • The values are present—the merchant has not refreshed the Catalog EAV index.
  • If Magento does not locate the additional attributes column, Magento will clear the values for these attributes.

Question 86

Question
You are configuring a new entry in etc/adminhtml/system.xml that is a select / dropdown type. What must the class for the source model extend or implement?
Answer
  • \Magento\Framework\Data\OptionSourceInterface
  • \Magento\Framework\Source\OptionInterface
  • \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
  • \Magento\Backend\Model\AbstractSource

Question 87

Question
How do you create a new cache type?
Answer
  • Create etc/cache.xml and specify a <type name="cache_name" instance="Class\Path"/>.
  • Inject a new caching class into \Magento\Framework\App\CacheList.
  • Use a plugin to append to the method arguments for the \Magento\Framework\App\CacheList::collect method.
  • Add an event observer for the cache_type_collector observer.

Question 88

Question
You are writing a data patch that will convert the data in a column from a PHP serialized value to JSON. The problem is that you also have another data patch that updates some sample data. This sample data patch must be run after the data conversion patch. How do you accomplish this?
Answer
  • Implement the getDependencies method.
  • Configure the patch relationship in etc/db_schema.xml.
  • Place in separate modules and make one module dependent on the other.
  • Patches must be independent of each other.

Question 89

Question
What Magento layout XML instructions instruct Magento to render HTML output? (Select 2)
Answer
  • block
  • container
  • referenceBlock
  • action

Question 90

Question
What interface is an event listener required to implement?
Answer
  • Magento\Framework\Event\ObserverInterface
  • Magento\Events\ListenerInterface
  • Magento\Framework\EventInterface
  • Magento\Framework\Observers\DelegateInterface

Question 91

Question
You have overridden a core Magento template in your theme. Your updates require logic from \MyClass\Path to render properly. Keeping upgradeability in mind, how do you make this logic available?
Answer
  • In layout XML, <arguments><argument name=”logic” xsi:type=”object”>\MyClass\Path</argument></arguments> inside the referenceBlock declaration.
  • In layout XML, set <referenceBlock name=”...” type=”\MyClass\Path”/>.
  • In the template, use the ObjectManager to obtain the class.
  • Override the block that originally renders the Magento template and add the logic.

Question 92

Question
You added a new widget for the WYSIWYG editor. After reviewing your work, your client, who is familiar with HTML, states that MyCompany\MyModule\Block\Widgets\PowerfulWidget is verbose in the code. Keeping maintainability in mind, How can you shorten this up?
Answer
  • Use a virtualType declaration to create a shorter name.
  • Use a preference that will substitute the name of the class.
  • Create a plugin that would contain a map for class names.
  • Override the frontend Javascript files to replace instances of the class names.

Question 93

Question
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?
Answer
  • Create a router that watches for the noroute action; if it matches, forward the front controller to a custom controller.
  • Create a layout XML file cms_noroute_index.xml and place updates in it.
  • Create an observer for the front_controller_match_after event.
  • Create a plugin for the dispatch method in vendor/magento/framework/App/FrontController.php.

Question 94

Question
What qualifiers are available for configuring a product’s pricing tiers? (Select 3)
Answer
  • Quantity
  • Customer Group
  • Website
  • Store View
  • Customer

Question 95

Question
What category path is the category that is the closest to the top of the tree, but still is visible in the admin?
Answer
  • 1/2
  • 1
  • 1/2/8
  • 0

Question 96

Question
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? (Select 2)
Answer
  • Add new column to the sales_order_address table.
  • Create a checkout_index_index.xml file and add the uiComponent details.
  • Override \Magento\Block\Checkout\ShippingAddress and add a getter for the selector value.
  • Add a Javascript mixin to render the selector.

Question 97

Question
Which Magento areas natively allow products to be added to the cart? (Select 3)
Answer
  • webapi_rest
  • adminhtml
  • frontend
  • crontab
  • base

Question 98

Question
A root category is associated with which scope:
Answer
  • Store
  • Global
  • Store View
  • Website

Question 99

Question
When writing a model triad (model, resource model, collection), what is the correct way to save a model to the database?
Answer
  • Call the save method in the resource model class.
  • Call the save method in the collection class.
  • Call the save method in the repository.
  • Call the save method in the model class.

Question 100

Question
You are creating a product feed export. To do this, you are loading in a list of products to render in the XML format. Here is the code you have written so far: $products = $productCollection->addFieldToFilter(‘entity_id’, [‘in’ => /* … */]); foreach ($products as $product) { // … iterating through thousands of products } What needs to be added to the above code to improve performance?
Answer
  • $products->addAttributeToSelect([‘name’, ‘url’]);
  • $products->addFilterByRequiredOptions();
  • $products->addOrder(‘name’);
  • $products->addIdFilter([/* … */]); (instead of addFieldToFilter)

Question 101

Question
You are tasked with adding a custom fee structure to product prices. This pricing must show on category and product pages. The fees are stored in a separate table in the database. Keeping performance in mind, how do you implement this?
Answer
  • Use a price modifier to update prices.
  • Create a plugin for getPrice.
  • Replace the price calculation logic.
  • Use the custom price data option.

Question 102

Question
You have written the following code for a router: public function match (\Magento\Framework\App\RequestInterface $request) { if (strpos($request->getPathInfo(), 'test') === false) return; $request->setModuleName(‘MyCompany_MyModule’) ->setControllerName('test')->setActionName('test'); return $this->actionFactory->create( \Magento\Framework\App\Action\Forward::class, ['request' => $request] ); } What is the result of this code being executed when navigating to /test?
Answer
  • “Front controller reached 100 router match iterations” error.
  • Success
  • A 404 error.
  • “Invalid action type specified” error.

Question 103

Question
You need to make some modifications to an entity before it is saved to the database. Your tool of choice is a plugin. What are requirements for a plugin? (Select 3)
Answer
  • The plugin class must be specified in di.xml.
  • The plugin method must begin with the type of the plugin.
  • The targeted method or class must not be marked final.
  • The plugin class must not inherit the targeted class.
  • The plugin class must not be marked abstract.

Question 104

Question
What class should you return from a controller’s execute method to redirect a visitor to another URL?
Answer
  • \Magento\Framework\Controller\Result\Redirect
  • \Magento\Framework\Controller\RedirectResponse
  • \Magento\Framework\Responses\RedirectType
  • \Magento\Framework\Controller\Result\ForwardAction

Question 105

Question
When creating a new data provider collection for a uiComponent, what class must you extend?
Answer
  • Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
  • Magento\Framework\View\UiComponent\ViewCollection
  • Magento\Framework\UiComponent\ComponentCollection
  • Magento\Framework\ViewDataProvider\UiComponent\CollectionProvider

Question 106

Question
As you create a controller in Magento's adminhtml area, you must configure it to respond appropriately to the ACL. Keeping simplicity in mind, what steps do you take to implement this?
Answer
  • Set the value of the ADMIN_RESOURCE constant to be the ACL resource.
  • Override _isAllowed and check the authorization class' isAllowed method for the ACL resource.
  • Create a plugin to ensure that the ACL resource is accessible.
  • Check the authorization class' isAllowed method as the first check in the execute function.

Question 107

Question
You are inspecting an existing Magento installation. Where do modules that affect the functionality of the Magento application reside? (Select 2)
Answer
  • vendor
  • app/code
  • code
  • modules

Question 108

Question
What files are required for a new theme? 2
Answer
  • theme.xml
  • etc/view.xml
  • composer.json
  • registration.php
Show full summary Hide full summary

Similar

French Beginner
PatrickNoonan
Geography Coastal Zones Flashcards
Zakiya Tabassum
Summary of Definitions/Key Terms for the PMP Exam
Andrea Leyden
Repaso prueba Revalida Enfermeria 2016 Parte:2
Rodrigo Lopez
Ingeniería Industrial
JUAN ADUNA RIVERA
Mapas mentales con ExamTime
VERO FONSECA
SISTEMA NERVIOSO Y REPRODUCTIVO
Lizbeth Domínguez
Mapa Conceptual
Brisa Jimenez Robles
Como realizar un resumen y la importancia de estrategias de comprension lectora en este proceso
Diana Marcela CONTRERAS RODRIGUEZ
Estado e Relaçao de Poder
Adeildoethatiane Silva
MAPA CONCEPTUAL DE POLITICAS PUBLICAS
mica mksssad