ExamGecko
Home Home / Adobe / AD0-E716

Adobe AD0-E716 Practice Test - Questions Answers, Page 2

Question list
Search
Search

List of questions

Search

Related questions











An Adobe Commerce developer is writing an integration test. They checked some Integration Tests for Magento core modules for reference and noticed that they use data fixtures initialized by adding annotations to test classes. For example:

The developer wants to add their own fixture to test a MyVendor_MyModule they created. Which steps will make this possible?

A.
1- Create a PHP file with the fixture data inside their own module in [module dir]/Test/integration/_fiies/my_fixture.php.2- Add the following annotation to the test method:
A.
1- Create a PHP file with the fixture data inside their own module in [module dir]/Test/integration/_fiies/my_fixture.php.2- Add the following annotation to the test method:
Answers
B.
1- Create a PHP file With the fixture data in [magento root dir]/dev/tests/integration/testsuite/MyVendor/MyModule/_files/my_fixture.php.2- Add the following annotation to the test method:
B.
1- Create a PHP file With the fixture data in [magento root dir]/dev/tests/integration/testsuite/MyVendor/MyModule/_files/my_fixture.php.2- Add the following annotation to the test method:
Answers
C.
1- Create a PHP file with the fixture data inside their own module in [module dir]/Test/integration/_f iies/my_f ixture.php.2- Add the following annotation to the test method:
C.
1- Create a PHP file with the fixture data inside their own module in [module dir]/Test/integration/_f iies/my_f ixture.php.2- Add the following annotation to the test method:
Answers
Suggested answer: B

Explanation:

To add a custom fixture to test a MyVendor_MyModule, the developer needs to do the following:

Create a PHP file with the fixture data in[magento root dir]/dev/tests/integration/testsuite/MyVendor/MyModule/_files/my_fixture.php.

Add the following annotation to the test method:

@magentoDataFixture(

'testsuite/MyVendor/MyModule/_files/my_fixture.php'

)

This will tell Magento to load the fixture data from the my_fixture.php file before the test method is executed.

An Adobe Commerce developer has created a before plugin for the save() function within the

Magento\Framework\App\cache\Proxy class. The purpose of this plugin is to add a prefix on all cache identifiers that fulfill certain criteria.

Why is the plugin not executing as expected?

A.
Another around plugin defined for the same function does not call the callable.
A.
Another around plugin defined for the same function does not call the callable.
Answers
B.
Cache identifiers are immutable and cannot be changed.
B.
Cache identifiers are immutable and cannot be changed.
Answers
C.
The target ClaSS implements Magento\Framework\ObjectManager\NoninterceptableInterface.
C.
The target ClaSS implements Magento\Framework\ObjectManager\NoninterceptableInterface.
Answers
Suggested answer: C

Explanation:

According to the Plugins (Interceptors) guide for Magento 2 developers, plugins are class methods that modify the behavior of public class methods by intercepting them and running code before, after, or around them. However, some classes in Magento 2 implement the NoninterceptableInterface interface, which prevents plugins from being generated for them. The Magento\Framework\App\cache\Proxy class is one of them, as it extends from Magento\Framework\ObjectManager\NoninterceptableInterface. Therefore, the plugin is not executing as expected because the target class implements NoninterceptableInterface. Verified

Reference: https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html

An Adobe Commerce developer has installed a module from a third-party vendor. This module fires a custom event named third_party_event_after and also defines an observer named third_party_event_after_observer that listens to that event. The developer wants to listen to this custom event in their own module but wants to execute their observer's logic after the third_party_event_after_observer observer has finished executing.

What would the developer do to ensure their observer runs after the observer defined by the third-party module?

A.
Ensure the third-party module is listed in the <sequence> node of the developer's module.xmi file.
A.
Ensure the third-party module is listed in the <sequence> node of the developer's module.xmi file.
Answers
B.
Set the sort order of the new observer to be less than that of the third-party vendor's observer.
B.
Set the sort order of the new observer to be less than that of the third-party vendor's observer.
Answers
C.
This is not possible as observers listening to the same event may be invoked in any order.
C.
This is not possible as observers listening to the same event may be invoked in any order.
Answers
Suggested answer: B

Explanation:

To ensure that the developer's observer runs after the observer defined by the third-party module, they need to set the sort order of the new observer to be less than that of the third-party vendor's observer.

The sort order is a number that is assigned to each observer. The lower the number, the earlier the observer will be executed.

For example, if the third-party vendor's observer has a sort order of 10, the developer's observer would need to have a sort order of 9 or lower.

An Adobe Commerce developer has been asked to modify the PageBuilder slider content type to allow a new custom content type (other than slide) to be assigned as a child. The developer has already created the new content type called improved_slide in their module. They now need to create a new view/adminhtml/pagebuilder/content_type/slider. xml file in their module to allow the new content type to be a child of slider content types.

What is the correct xml to accomplish this?

A)

B)

C)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
Suggested answer: B

Explanation:

The following XML will allow the new content type to be a child of slider content types:

<type>slider</type>

<children>

<type>improved_slide</type>

</children>

Use code with caution.https://bard.google.com/faq

This XML will tell Magento that the slider content type can have improved_slide content types as children.

An Adobe Commerce developer creates a new website using a data patch. Each website will have unique pricing by website. The developer does not have visibility into the production and staging environments so they do not know what the configuration currently is.

How would they ensure the configuration is deployed and consistent across all environments?

A.
A.
Answers
B.
B.
Answers
C.
C.
Answers
Suggested answer: B

Explanation:

To ensure that the configuration is deployed and consistent across all environments, the developer can use the following steps:

Create a data patch that contains the configuration for the new website.

Deploy the data patch to all environments.

Use themagento deploy:statuscommand to verify that the configuration has been deployed to all environments.

An Adobe Commerce developer was asked to provide additional information on a quote. When getting several quotes, the extension attributes are returned, however, when getting a single quote it fails to be returned.

What is one reason the extension attributes are missing?

A.
The developer neglected to add coiiection='trueM to their attribute in etc/extension_attributes.xmi file. O ottribute code='my_attributesM type='MyVendor\MyModule\Api\Data\^AttributeInterface[]M collection='true' />
A.
The developer neglected to add coiiection='trueM to their attribute in etc/extension_attributes.xmi file. O ottribute code='my_attributesM type='MyVendor\MyModule\Api\Data\^AttributeInterface[]M collection='true' />
Answers
B.
The developer neglected to provide a plugin On Hagento\Quote\Api\CartRepositoryInterface: :get.
B.
The developer neglected to provide a plugin On Hagento\Quote\Api\CartRepositoryInterface: :get.
Answers
C.
The developer neglected to implement an observer on the coiiection_ioad_after event.
C.
The developer neglected to implement an observer on the coiiection_ioad_after event.
Answers
Suggested answer: A

Explanation:

The extension attributes are missing because the collection='true' attribute is not set in the etc/extension_attributes.xmi file. This attribute tells Magento that the extension attributes should be returned when the quote is retrieved.

To fix this issue, the developer needs to add the collection='true' attribute to the my_attributes extension attribute.

Once the collection='true' attribute is set, the extension attributes will be returned when the quote is retrieved.

A logistics company with an Adobe Commerce extension sends a list of reviewed shipment fees to all its clients every month in a CSV file. The merchant then uploads this CSV file to a 'file upload' field in admin configuration of Adobe Commerce.

What are the two requirements to display the 'file upload' field and process the actual CSV import? (Choose two.)

A)

B)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: A, B

Explanation:

To display the 'file upload' field and process the actual CSV import, the following two requirements must be met:

The developer must create a new system configuration setting that specifies the path to the CSV file.

The developer must create a new controller action that handles the file upload and import process.

The system.xml file is used to define system configuration settings. The following XML snippet shows how to define a new system configuration setting for the CSV file path:

XML

<config>

<system>

<config>

<shipment_fees_csv_path>/path/to/csv/file</shipment_fees_csv_path>

</config>

</system>

</config>

The Controller\Adminhtml\ShipmentFees controller class is used to handle the file upload and import process. The following code shows how to create a new controller action that handles the file upload and import process:

PHP

public function uploadAction()

{

$file = $this->getRequest()->getFile('shipment_fees_csv_file');

if ($file->isUploaded()) {

$importer = new ShipmentFeesImporter();

$importer->import($file);

}

return $this->redirect('adminhtml/system_config/edit/section/shipment_fees');

}

An Adobe Commerce developer is tasked with adding custom data to orders fetched from the API. While keeping best practices in mind, how would the developer achieve this?

A.
Create an extension attribute on Nagento\sales\Api\E)ata\orderinterface and an after plugin on Magento\Sales\Model\Order: :getExtensionAttributes() to add the custom data.
A.
Create an extension attribute on Nagento\sales\Api\E)ata\orderinterface and an after plugin on Magento\Sales\Model\Order: :getExtensionAttributes() to add the custom data.
Answers
B.
Create an extension attribute On Magento\Sales\Api\Data\OrderInterface and an after plugin On Magento\Sales\Api\OrderRepositoryInterface On geto and getListo to add the custom data.
B.
Create an extension attribute On Magento\Sales\Api\Data\OrderInterface and an after plugin On Magento\Sales\Api\OrderRepositoryInterface On geto and getListo to add the custom data.
Answers
C.
Create a before plugin on Magento\sales\model\ResourceModel\order\collection: :load and alter the query to fetch the additional data. Data will then be automatically added to the items fetched from the API.
C.
Create a before plugin on Magento\sales\model\ResourceModel\order\collection: :load and alter the query to fetch the additional data. Data will then be automatically added to the items fetched from the API.
Answers
Suggested answer: B

Explanation:

The developer should create an extension attribute on the Magento\Sales\Api\Data\OrderInterface interface and an after plugin on the Magento\Sales\Api\OrderRepositoryInterface::get() and Magento\Sales\Api\OrderRepositoryInterface::getList() methods.

The extension attribute will store the custom data. The after plugin will be used to add the custom data to the order object when it is fetched from the API.

Here is the code for the extension attribute and after plugin:

PHP

namespace MyVendor\MyModule\Api\Data;

interface OrderExtensionInterface extends \Magento\Sales\Api\Data\OrderInterface

{

/**

* Get custom data.

*

* @return string|null

*/

public function getCustomData();

/**

* Set custom data.

*

* @param string $customData

* @return $this

*/

public function setCustomData($customData);

}

namespace MyVendor\MyModule\Model;

class OrderRepository extends \Magento\Sales\Api\OrderRepositoryInterface

{

/**

* After get order.

*

* @param \Magento\Sales\Api\OrderRepositoryInterface $subject

* @param \Magento\Sales\Api\Data\OrderInterface $order

* @return \Magento\Sales\Api\Data\OrderInterface

*/

public function afterGetOrder($subject, $order)

{

if ($order instanceof OrderExtensionInterface) {

$order->setCustomData('This is custom data');

}

return $order;

}

/**

* After get list.

*

* @param \Magento\Sales\Api\OrderRepositoryInterface $subject

* @param \Magento\Sales\Api\Data\OrderInterface[] $orders

* @return \Magento\Sales\Api\Data\OrderInterface[]

*/

public function afterGetList($subject, $orders)

{

foreach ($orders as $order) {

if ($order instanceof OrderExtensionInterface) {

$order->setCustomData('This is custom data');

}

}

return $orders;

}

}

Once the extension attribute and after plugin are created, the custom data will be added to orders fetched from the API.

An Adobe Commerce developer has created a process that exports a given order to some external accounting system. Launching this process using the Magento CLI with the command php bin/magento my_module:order: process --order_id=<order_id> is required.

Example: php bin/magento my_module:order:process --order_id=1245.

What is the correct way to configure the command?

A)

B)

C)

D)

A.
Option B
A.
Option B
Answers
B.
Option C
B.
Option C
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: C

Explanation:

According to the How to use the Magento command-line interface (CLI) guide, to configure and run the Magento CLI, the developer needs to make the bin/magento file executable and then use it to run commands. To create a custom command, the developer needs to create a class that implements \Symfony\Component\Console\Command\Command and define its name, description, arguments, options, and logic. The developer also needs to register the command in the di.xml file of their module using the Magento\Framework\Console\CommandList argument. Therefore, option C is the correct answer, as it shows the correct class and di.xml code to configure the custom command. Verified

Reference: https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/magento1/using-the-magento-command-line-interface-cli/

An Adobe Commerce developer is working on a Magento 2 instance which contains a B2C and a B2B website, each of which contains 3 different store views for English, Welsh, and French language users. The developer is tasked with adding a link between the B2C and B2B websites using a generic link template which is used throughout the sites, but wants these links to display in English regardless of the store view.

The developer creates a custom block for use with this template, before rendering sets the translate locale and begins environment emulation using the following code:

They find that the template text is still being translated into each stores language. Why does this occur?

A.
startEnvironmffntEmulation() SetS and locks the locale by Using the setLocale() Optional Second $lock parameter, i.e. setLocale($newLocaleCode, true), to override and lock the locale of the emulated store. If this is set and locked initially then the environment emulation will not be able to override this.
A.
startEnvironmffntEmulation() SetS and locks the locale by Using the setLocale() Optional Second $lock parameter, i.e. setLocale($newLocaleCode, true), to override and lock the locale of the emulated store. If this is set and locked initially then the environment emulation will not be able to override this.
Answers
B.
startEnvironmentEmuiation() resets the translation locale to the one of the emulated stores, which overrides the locale the developer has set when the order of setLocate and startEnvironmentEmulation is used as displayed above.
B.
startEnvironmentEmuiation() resets the translation locale to the one of the emulated stores, which overrides the locale the developer has set when the order of setLocate and startEnvironmentEmulation is used as displayed above.
Answers
C.
setLocate() does not change translation locale after it has been initially set, the $this->_translate->emulate($newLocaiecode) method exists to temporarily modify this by pushing the new locale to the top of the current emuiatedLocales stack.
C.
setLocate() does not change translation locale after it has been initially set, the $this->_translate->emulate($newLocaiecode) method exists to temporarily modify this by pushing the new locale to the top of the current emuiatedLocales stack.
Answers
Suggested answer: B

Explanation:

The startEnvironmentEmulation() method resets the translation locale to the one of the emulated stores, which overrides the locale the developer has set when the order of setLocale() and startEnvironmentEmulation() is used as displayed above.

The correct way to achieve the desired result is to use the emulate() method to temporarily modify the translation locale. The following code shows how to do this:

PHP

$this->_translate->emulate('en_US');

// Render the template

$this->_translate->revert();

This code will set the translation locale to English before rendering the template, and then revert the locale back to the default value after the template has been rendered.

The startEnvironmentEmulation() method is used to emulate a different store view or website. This can be useful for testing purposes, or for developing features that need to work in different environments.

The emulate() method is used to temporarily modify the translation locale. This can be useful for rendering templates in a specific language, or for testing features that need to work in different languages.

Total 69 questions
Go to page: of 7