An Adobe Commerce developer is developing a custom module. As part of their implementation they have decided that all instances of their CustomModuleModelExample class should receive a new instance of MagentoFilesystemAdapterLocal.
How would the developer achieve this using di. xml?
A)
B)
C)
Correct Answer:C
An Adobe Commerce developer is working on a custom gallery extension.
The module uses the MagentocatalogModeliinageUploader class for image uploading. The admin controller for custom image uploads is VendorCustomGalleryControllerAdminhtmlImageUpload.
The images need to be stored in different basePath and baseTmpPath than the default ones.
How can the default imageuploader class be extended and used without affecting the other modules that are already using it?
A)
B)
C)
Correct Answer:A
By explicitly injecting the virtual type into the controller, you localize the configuration changes to only the desired functionality. This approach is efficient and maintains module independence, a key principle in Magento development.
Options B and C are incorrect for the following reasons:
Option Bdirectly modifies Magento\Catalog\Model\ImageUploader with the new paths. This change will affect all usages of the ImageUploader class across the site, which contradicts the requirement to avoid impacting other modules.
Option Cinvolves creating a virtual type and then setting it as a preference. However, using a preference would replace all instances of ImageUploader across the entire Magento application, leading to the same issue as Option B.