ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 26 - AD0-E716 discussion

Report
Export

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:

C)

Create a new file etc/eav attributes.xmi:

A.
Option A
Answers
A.
Option A
B.
Option B
Answers
B.
Option B
C.
Option C
Answers
C.
Option C
Suggested answer: 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>

<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.

asked 02/10/2024
Martijn Bot
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first