ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 10 - AD0-E716 discussion

Report
Export

An Adobe Commerce developer has been tasked with applying a pricing adjustment to products on the website. The adjustments come from a database table. In this case, catalog price rules do not work. They created a plugin for getPrice on the price model, but the layered navigation is still displaying the old price.

How can this be resolved?

A.
Create an implementation for \Magento\Catalog\Hodel\Product\PriceModifierlnterf ace.
Answers
A.
Create an implementation for \Magento\Catalog\Hodel\Product\PriceModifierlnterf ace.
B.
Create an after plugin On \Magento\Catalog\Api\Data\BasePriceInterface:: getPrice.
Answers
B.
Create an after plugin On \Magento\Catalog\Api\Data\BasePriceInterface:: getPrice.
C.
Create a plugin for\Magento\Catalog\Model\Indexer\Product\Price::executeRow.
Answers
C.
Create a plugin for\Magento\Catalog\Model\Indexer\Product\Price::executeRow.
Suggested answer: C

Explanation:

The developer can resolve this issue by creating a plugin for the Magento\Catalog\Model\Indexer\Product\Price::executeRow() method. This method is responsible for updating the product price index.

The plugin can be used to add the pricing adjustment from the database to the product price index. Once the product price index is updated, the layered navigation will display the correct price.

Here is an example of a plugin for the executeRow() method:

PHP

class MyPlugin

{

public function executeRow(

\Magento\Catalog\Model\Indexer\Product\Price $subject,

\Magento\Catalog\Model\Product $product,

array $data

) {

$adjustment = $this->getAdjustment($product);

$product->setPrice($product->getPrice() + $adjustment);

}

private function getAdjustment(Product $product)

{

$adjustment = $product->getData('adjustment');

if (!is_numeric($adjustment)) {

return 0;

}

return $adjustment;

}

}

This plugin will add the adjustment data from the product to the product price index. Once the product price index is updated, the layered navigation will display the correct price.

asked 02/10/2024
Exam Prepping
29 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first