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()?
Answer(s): A
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?
Answer(s): C
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
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.)
Answer(s): A,C
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.
An Adobe Commerce developer wants to create a product EAV attribute programmatically which should appear as WYSIWYG in the admin panel. They have made sure that wysiwyg_enabled has been set to true, however, the attribute is not appearing as WYSIWYG in the admin panel.What would be a possible reason?
The input_type attribute of a product EAV attribute specifies the type of input field that will be used to enter the value of the attribute in the admin panel. The textarea input type is used for WYSIWYG fields. If the input_type attribute is not set to textarea, then the attribute will not appear as WYSIWYG in the admin panel.To fix this, the developer should set the input_type attribute to textarea.
An Adobe Commerce Developer has written an importer and exporter for a custom entity. The client is using this to modify the exported data and then re-importing the file to batch update the entities. There is a text attribute, which contains information related to imagery in JSON form, media_gallery. This is not a field that the client wants to change, but the software they are using to edit the exported data seems to be modifying it and not allowing it to import correctly.How would the developer prevent this?
The _transformAttrs class property array of the importer and exporter classes can be used to specify a serializer class for a particular attribute. The serializer class will be used to convert the attribute value from one format to another when the data is exported or imported. In this case, the developer can specify a serializer class that will convert the JSON data in the media_gallery attribute to a string. This will prevent the software that the client is using to modify the exported data from changing the JSON data.The following code shows how to specify a serializer class for the media_gallery attribute:PHPclass MySerializer{public function serialize($value){return json_encode($value);}public function deserialize($value){return json_decode($value);}}$importer->setSerializer('media_gallery', MySerializer::class); $exporter->setSerializer('media_gallery', MySerializer::class);Once the serializer class has been specified, the JSON data in the media_gallery attribute will be converted to a string when the data is exported or imported. This will prevent the software that the client is using to modify the exported data from changing the JSON data.
Post your Comments and Discuss Adobe AD0-E716 exam prep with other Community members:
Our website is free, but we have to fight against AI bots and content theft. We're sorry for the inconvenience caused by these security measures. You can access the rest of the AD0-E716 content, but please register or login to continue.