Adobe AD0-E722 Practice Test - Questions Answers, Page 3
List of questions
Question 21

A single Adobe Commerce Cloud instance is set up with two websites (each with a single store view) with different domains.
* The default website is website_one, with store view store_one, and domain storeone. com.
* The second website is website_two, with store view store_two, and domain storetwo. com.
The magento-vars. php file is set up as follows to determine which website each request runs against:
When testing a new GraphQL integration, all requests returned data relating to the default website, regardless of the domain. What is causing this issue?
Explanation:
The magento-vars.php file is used to set the website or store view based on the HTTP host, but it does not affect GraphQL requests. GraphQL requests are handled by a separate controller that does not use the magento-vars.php file. Instead, GraphQL requests use the default store view of the default website, unless a store header or store cookie is provided in the request. The store header or cookie should contain the store code of the desired store view.For example, to query data from website_two, the request should include a header likestore: store_twoor a cookie likestore=store_two12.Reference:
GraphQL overview | Adobe Commerce 2.4 User Guide - Magento
How to set up multiple websites with Magento 2 - Mageplaza
Question 22

An Architect needs to integrate an Adobe Commerce store with a new Shipping Carrier. Cart data is sent to the Shipping Carrier's API to retrieve the price and display to the customer. After the feature is implemented on the store, the API hits its quota and returns the error 'Too many requests'. The Shipping Carrier warns the store about sending too many requests with the same content to the API.
In the carrier model, what should the Architect change to fix the problem?
Explanation:
The carrier model class can implement caching methods to store and retrieve the quotes from the API based on the request parameters. This can reduce the number of API calls and improve the performance of the shipping rate calculation. The _setCachedQuotes() method can save the response from the API to a cache storage, and the _getCachedQuotes() method can check if there is a cached response for the current request and return it if it exists.Reference:Caching in carrier model,Carrier model interface
Question 23

An Architect working on a headless Adobe Commerce project creates a new customer attribute named my_attribute. Based on the attribute value of the customer, the results of GraphQI queries are modified using a plugin. The frontend application is communicating with Adobe Commerce through Varnish by Fastly. which is already caching the queries that will be modified. The Adobe Commerce Fastly extension is installed, and no other modifications are made to the application.
Which steps should the Architect take to make sure the vcl_hash function of Varnish also considers the newly created attribute?
Explanation:
To make sure the vcl_hash function of Varnish considers the newly created attribute, the Architect needs to do the following steps:
Create a new class that implements the Magento\GraphQlCache\Model\CacheId\CacheIdFactorProviderInterface interface. This interface defines two methods: getFactorName and getFactorValue. The getFactorName method should return the name of the attribute, in this case, my_attribute.The getFactorValue method should return the value of the attribute for the current customer, which can be obtained from the customer session or customer repository1.
Add this class to the idFactorProviders array of Magento\GraphQlCache\Model\CacheId\CacheIdCalculator through dependency injection. The CacheIdCalculator is responsible for generating a cache ID for each GraphQL request based on the factors provided by the idFactorProviders.By adding the new class to this array, the Architect ensures that the cache ID will include the value of my_attribute1.
The cache ID is then used by Varnish to hash and lookup the cached response for each request.By including my_attribute in the cache ID, the Architect ensures that Varnish will serve different responses based on the attribute value of the customer2.Reference:
Magento_GraphQlCache module | Magento 2 Developer Documentation
Varnish caching | Adobe Commerce 2.4 User Guide - Magento
Question 24

An Architect wants to create an Integration Test that does the following:
* Adds a product using a data fixture
* Executes $this->someLogic->execute($product) on the product
* Checks if the result is true.
$this->someLogic has the correct object assigned in the setup() method.
Product creation and the tested logic must be executed in the context of two different store views with IDs of 3 and 4, which have been created and are available for the test.
How should the Architect meet these requirements?
Explanation:
To create an integration test that executes different logic in different store views, the Architect needs to do the following steps:
Create one test class that extends \Magento\TestFramework\TestCase\AbstractController or \Magento\TestFramework\TestCase\AbstractBackendController, depending on the type of controller being tested1.
Create one test method that uses the @magentoDataFixture annotation to specify the data fixture file that creates the product2.
Use the \Magento\TestFramework\Store\ExecuteInStoreContext class to execute the fixture and the tested logic in different store views. This class has a method called executeInStoreContext, which takes two parameters: the store ID and a callable function.The callable function will be executed in the context of the given store ID, and then the original store ID will be restored3. For example:
PHPAI-generated code. Review and use carefully.More info on FAQ.
public function testSomeLogic()
{
// Get the product from the fixture
$product = $this->getProduct();
// Get the ExecuteInStoreContext instance from the object manager
$executeInStoreContext = $this->_objectManager->get(\Magento\TestFramework\Store\ExecuteInStoreContext::class);
// Execute the fixture in store view 3
$executeInStoreContext->executeInStoreContext(3, function () use ($product) {
// Do some operations on the product in store view 3
});
// Execute the tested logic in store view 4
$result = $executeInStoreContext->executeInStoreContext(4, function () use ($product) {
// Call the tested logic on the product in store view 4
return $this->someLogic->execute($product);
});
// Assert that the result is true
$this->assertTrue($result);
}
Integration tests | Magento 2 Developer Documentation
Data fixtures | Magento 2 Developer Documentation
Magento\TestFramework\Store\ExecuteInStoreContext | Magento 2 Developer Documentation
Question 25

An Adobe Commerce Architect notices that the product price index takes too long to execute. The store is configured with multiple websites and dozens of customer groups.
Which two ways can the Architect shorten the full price index execution time? (Choose two.)
Explanation:
The product price index can be optimized by using parallel mode and customer group merging. Parallel mode allows the indexer to run multiple threads simultaneously, which can speed up the indexing process. Customer group merging reduces the number of rows in the price index table by merging customer groups that have the same product prices. This can improve the performance of the price index queries and reduce the index size.Reference:Indexing optimization,Price index customer group merging
Question 26

While reviewing a newly developed pull request that refactors multiple custom payment methods, the Architect notices multiple classes that depend on \Magento\Framework\Encryption\EncryptorInterface to decrypt credentials for sensitive dat a. The code that is commonly repeated is as follows:
The Architect needs to recommend an optimal solution to avoid redundant dependency and duplicate code among the methods. Which solution should the Architect recommend?
Explanation:
The Architect should recommend replacing all Vendor\PaymentModule\Gateway\Config\Config Classes with virtualType of Magento\Payment\Gateway\Config\Config and setting <user_secret backend_Model=''Magento\Config\Model\Config\Backend\Encrypted'' /> under config.xml. This will avoid redundant dependency and duplicate code among the methods. The virtualType of Magento\Payment\Gateway\Config\Config will inherit the functionality of the base class and allow the customization of the constructor arguments, such as the pathPattern and valueHandlerPool.The backend_Model attribute of the user_secret field will specify that the value of this field should be encrypted and decrypted by the Magento\Config\Model\Config\Backend\Encrypted class, which implements the \Magento\Framework\App\Config\ValueInterface interface and uses the \Magento\Framework\Encryption\EncryptorInterface internally12.This way, the payment modules do not need to depend on the \Magento\Framework\Encryption\EncryptorInterface or the \Magento\Framework\App\Config\ScopeConfigInterface directly, and can use the getValue method of the Magento\Payment\Gateway\Config\Config class to get the decrypted value of the user_secret field3.Reference:
How to encrypt system configuration fields in Magento 2 - Mageplaza
Magento 2: How to Encrypt/Decrypt System Configuration Fields - Webkul Blog
Magento 2: How to create custom payment method - BelVG Blog
Question 27

Since the last production deployment, customers can not complete checkout.
The error logs show the following message multiple times:
main.CRITICAL: Report ID: webapi-61b9fe83f0c3e; Message: Infinite loop detected, review the trace for the looping path
The Architect finds a deployed feature that should limit delivery for some specific postcodes.
The Architect sees the following code deployed in etc/webapi_rest/di. xml and etc/frontend/di. Xml
LimitRates.php:
Which step should the Architect perform to solve the issue?
Question 28

An Adobe Commerce Architect runs the PHP Mess Detector from the command-line interface using the coding standard provided with Adobe Commerce. The following output appears:
The Architect looks at the class and notices that the constructor has 15 parameters. Five of these parameters are scalars configuring the behavior of MyService. The class also contains three constants referencing one other class.
How should the Architect fix the code so that it complies with the coding standard rule?
Explanation:
The issue is being caused by the high coupling between objects (CBO) value of the class MyService.CBO is a metric that measures the number of classes that are coupled to a given class, either by method calls, property or parameter references, inheritance, or constants1.A high CBO value indicates that the class is too tightly coupled with other classes, which makes it more difficult to maintain, test, and reuse2. To reduce the CBO value, the Architect should introduce a new class that encapsulates the five scalar parameters that configure the behavior of MyService. This way, the constructor of MyService will only have one parameter of the new class type, instead of five scalar parameters. This will also make the code more readable and maintainable, as the new class can provide methods to access and manipulate the configuration data.The constants referencing other classes should not be consolidated into a string representation, as this would not reduce the CBO value and would make the code less clear and type-safe3.The number of different classes and interfaces referenced anywhere inside the class is not relevant for the CBO metric, as it only counts the classes that are coupled to the given class1.Reference:CBO coupling between object,Coupling Between Object classes (CBO),Cohesion and coupling of an object in OO programming
Question 29

Due to a marketing campaign, a website is experiencing a very large number of simultaneously placed orders, which is affecting checkout performance. The website is in the production deploy mode.
Which two website settings can an Architect optimize to decrease the impact on checkout performance? (Choose two.)
Explanation:
Option A is correct because enabling asynchronous indexing can improve the checkout performance by reducing the database load and avoiding locking issues. Asynchronous indexing allows the indexers to run in the background without affecting the frontend operations.The commandbin/magento config:set dev/grid/async_indexing 1can be used to enable this option in the production mode1.
Option C is correct because creating a new database and splitting the sales tables can also improve the checkout performance by distributing the database load and avoiding contention. Splitting the database allows the checkout and order management operations to use a separate master database from the rest of the Magento application tables.The commandbin/magento setup:db-schema:split-sales --host='<checkout db host or ip>' --dbname='<name>' --username='<checkout db username>' --password=''can be used to configure this feature2.
Option B is incorrect because enabling asynchronous email notifications does not affect the checkout performance directly. Asynchronous email notifications allow the order confirmation emails to be sent in batches by a cron job instead of immediately after placing an order.This option can reduce the server load and improve the customer experience, but it does not impact the checkout process itself3.
Option D is incorrect because there is no such deploy mode as siege in Magento 2. The available deploy modes are default, developer, and production.Changing the deploy mode can affect the performance, caching, and error handling of the Magento application, but it does not directly affect the checkout performance4.
Option E is incorrect because there is no such admin panel setting as multithreaded checkout processing in Magento 2. The number of PHP threads used for checkout is determined by the web server configuration and the PHP-FPM settings, not by the Magento application settings.Increasing the number of PHP threads may improve the checkout performance, but it also requires more server resources and may cause other issues5.
1: Asynchronous indexing | Adobe Commerce Developer Guide
2: Split database performance solution | Adobe Commerce Developer Guide
3: Sales Emails | Adobe Commerce User Guide
4: Set up Magento modes | Adobe Commerce Developer Guide
5: PHP-FPM configuration settings | Adobe Commerce Developer Guide
Question 30

An Adobe Commerce Architect is reviewing API-functional test code. Some tests send errors to indicate that the customer address does not exist. The test codes show the following:
Which step should the Architect take to fix the test errors?
Explanation:
The issue is being caused by the use of @magentoDataFixture annotation, which creates a temporary data fixture that is rolled back after each test execution1. This means that the customer address created by the fixture is not persisted in the database and cannot be retrieved by subsequent tests.To fix this, the Architect should use @magentoPersistDataFixture annotation, which creates a permanent data fixture that is not rolled back after each test execution2. This way, the customer address created by the fixture will be persisted in the database and can be accessed by subsequent tests.Changing the annotation to use @magentoApiDataFixture or specifying address_id in the annotation will not solve the issue, as they are not related to the persistence of the data fixture3.Reference:Data fixtures,Persistent data fixtures,API-functional tests
Question