QuestionQ36

VerifiedCustomizing the Catalog

An Adobe Commerce developer is developing a custom gallery extension.

The module uses the Magento\Catalog\Model\ImageUploader class to upload images. The admin controller for custom image uploads is Vendor\CustomGallery\Controller\Adminhtml\Image\Upload.

The images must be stored with basePath and baseTmpPath values different from the defaults. How can the default ImageUploader class be extended and used without impacting other modules that already use it?

Explanation

A virtual type provides a distinct, dependency-injection-configured instance of Magento\Catalog\Model\ImageUploader with custom basePath and baseTmpPath arguments. Assigning that virtual type only to the upload controller’s constructor argument isolates the custom storage paths, while other consumers retain the default ImageUploader configuration.

Learn more

Community Discussion

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