On an Adobe Commerce Cloud platform, what type of environment will be provisioned when launching the CLI for Commerce command magento-cloud environment:branch
Answer : C
The type of environment that will be provisioned when launching the CLI for Commerce command magento-cloud environment:branch <environment-name>
The developer is required to convert a modules database scripts from old install/upgrade setup files to a data patches format and does not want to apply database changes that were already done by install/upgrade scripts.
The current module version is 1.5.4.
What would be the recommended solution to skip changes that were already applied via old format (install/upgrade scripts)?
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?
A) Specify a serializer class for the attribute using the $_transformAttrs class property array for both the exporter and importer so it gets converted:
B) Strip the attribute from the imported file by adding it to the s_strippedAttrs class property array:
C) Prevent it from being exported by adding it to the $_disat>iedAttrs class property array:
Answer : A
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:
PHP
class 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.
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?
Answer : C
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 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 : A, C
The correct answers are A and C.
The errors in the snippet are:
Columnroll_nodoes not have an index. It is needed sinceattribute_identityis set totrue.
Columnstudent_namedoes 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>
<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 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?
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()?
A)
Create a new file etc/catalog_attributes.xmi:
B)
Create a new file etc/extension attributes.xmi:
Create a new file etc/eav attributes.xmi:
Answer : 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>
<label>Is Delayed</label>
<note>This attribute indicates whether the product is delayed.</note>
<sort_order>10</sort_order>
<required>false</required>
</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.