Free AD0-E716 Exam Braindumps (page: 8)

Page 7 of 18

An Adobe Commerce developer is tasked with creating a custom block that will be displayed on every page in the footer of the site.
After completing and optimizing the development, the developer notices that the block takes too much time to be generated on each page and decides to store it in the system cache after enabling it for all cache groups.
What would be the minimum requirement to achieve this?

  1. Set a value for the cache_Lifetime data property of the block.
  2. Set a value for cache_key data property of the block.
  3. Set values for both cache_lifetime and cache_key data properties of the block.

Answer(s): C

Explanation:

To store a block in the system cache, the developer needs to set values for both the cache_lifetime and cache_key data properties of the block. The cache_lifetime property specifies how long the block should be cached, and the cache_key property specifies a unique identifier for the block. The following code shows how to set the cache_lifetime and cache_key data properties of a block:
PHP
$block->setData('cache_lifetime', 600);
$block->setData('cache_key', 'my_custom_block');

Once the cache_lifetime and cache_key data properties have been set, the block will be stored in the system cache and will not be regenerated on each page load.



There is the task to create a custom product attribute that controls the display of a message below the product title on the cart page, in order to identify products that might be delivered late. The new EAV attribute is_delayed has been created as a boolean and is working correctly in the admin panel and product page.
What would be the next implementation to allow the is_delayed EAV attribute to be used in the .phtml cart page such as $block->getProduct()->getIsDelayed()?


  1. Create a new file etc/catalog_attributes.xmi:


  2. Create a new file etc/extension attributes.xmi:


  3. Create a new file etc/eav attributes.xmi:

Answer(s): A

Explanation:

To allow the is_delayed EAV attribute to be used in the .phtml cart page, the developer needs to create a new file called etc/catalog_attributes.xmi. This file will contain the definition of the is_delayed attribute.
The following code shows how to create the etc/catalog_attributes.xmi file:
XML
<?xml version="1.0"?>
<catalog_attributes>
<attribute code="is_delayed" type="int">
<label>Is Delayed</label>
<note>This attribute indicates whether the product is delayed.</note> <sort_order>10</sort_order>
<required>false</required>
</attribute>
</catalog_attributes>

Once the etc/catalog_attributes.xmi file has been created, the is_delayed attribute will be available in the .phtml cart page. The attribute can be accessed using the getIsDelayed() method of the Product class.
PHP
$product = $block->getProduct();
$isDelayed = $product->getIsDelayed();

The isDelayed variable will contain the value of the is_delayed attribute. If the value of the attribute is 1, then the product is delayed. If the value of the attribute is 0, then the product is not delayed.



An Adobe Commerce developer is creating a module (Vendor.ModuleName) to be sold on the Marketplace. The new module creates a database table using declarative schema and now the developer needs to make sure the table is removed when the module is disabled.
What must the developer do to accomplish this?

  1. There is nothing further the developer needs to do. The table will be removed when the module is disabled and bin/magento setup:upgrade is run.
  2. There is nothing further the developer needs to do. The table will be removed when the when bin/magento module:uninstall vendor_ModuleName is run.
  3. Add a schema patch that implements Magento\Framework\setup\Patch\PatchRevertabieinterface and drops the table in the revert function.

Answer(s): C

Explanation:

According to the Declarative Schema Overview guide for Magento 2 developers, declarative schema is a new feature that allows developers to declare the final desired state of the database and has the system adjust to it automatically, without performing redundant operations. However, declarative schema does not support uninstalling modules or reverting changes. To remove a table when a module is disabled, the developer needs to add a schema patch that implements Magento\Framework\setup\Patch\PatchRevertabieinterface and drops the table in the revert function. The revert function will be executed when the module is disabled using bin/magento module:disable command. Verified


Reference:

https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/



An Adobe Commerce developer is trying to create a custom table using declarative schema, but is unable to do so.



What are two errors in the snippet above? (Choose two.)

  1. Column (roll_no) does not have index. It is needed since attribute identity is set to true.
  2. Column (entity_id) does not have index. It is needed since attribute identity is set to false.
  3. Column (student_name) does not have attribute length.
  4. null is not a valid value for column (roll_no).

Answer(s): A,C

Explanation:

The correct answers are A and C.
The errors in the snippet are:
Column roll_no does not have an index. It is needed since attribute_identity is set to true. Column student_name does not have an attribute length. The attribute_identity attribute specifies whether the primary key of the table should be auto- incremented. If attribute_identity is set to true, then the roll_no column must have an index. The student_name column does not have an attribute length, which is required for string columns.

The following code shows how to fix the errors:
XML
<table name="vendor_module_table">
<entity_id>
<type>int</type>
<identity>true</identity>
<unsigned>true</unsigned>
<nullable>false</nullable>
</entity_id>
<roll_no>
<type>int</type>
<identity>false</identity>

<unsigned>true</unsigned>
<nullable>false</nullable>
<primary_key>true</primary_key>
<index>true</index>
</roll_no>
<student_name>
<type>string</type>
<length>255</length>
<nullable>false</nullable>
</student_name>
</table>

Once the errors have been fixed, the table can be created successfully.






Post your Comments and Discuss Adobe AD0-E716 exam with other Community members:

AD0-E716 Discussions & Posts