QuestionQ38

VerifiedWorking with Databases and EAV

An Adobe Commerce developer needs to change the tracking level in a custom module that enables free downloads of PDFs and images.

The module includes the following models:

  • Vendor\FreeDownload\Model\Download
  • Vendor\FreeDownload\Model\DownloadPdf extends Vendor\FreeDownload\Model\Download
  • Vendor\FreeDownload\Model\DownloadImage extends Vendor\FreeDownload\Model\Download

The Download class has a tracking_level parameter.

How should the developer configure the tracking_level parameter in di.xml so it has a value of 4 for the Download class and every class that extends Download?

Explanation

Adobe Commerce propagates constructor-parameter configuration declared for a class type in di.xml to that type’s descendant classes. Configuring tracking_level with the value 4 on Vendor\FreeDownload\Model\Download therefore applies the value to Download, DownloadPdf, and DownloadImage, unless a descendant explicitly overrides it.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!