4

When I compile I get this error:

PHP Fatal error: Class 'Magento\Catalog\Controller\Adminhtml\Category\Image\Upload' not found in /var/www/html/magento/app/code/Plazathemes/Override/Controller/Adminhtml/Category/Image/Upload.php on line 11

EDIT with the code:

enter image description here

Still unable to fix can someone write the soltion to fix this.

  • Are you sure all composer packages are installed? If something is corrupt in your composer and you do composer install/update it won't fix it. You have to force reinstall that package. Try cleaning the vendor folder and run composer install or composer update – Stijn Duynslaeger - Echron Dec 29 '16 at 0:41
  • Can you please provide the steps to follow to do this. – DiLjiT singh Dec 29 '16 at 7:58
  • Did you remove var/di, var/generation and try run di compile again? – Khoa TruongDinh Dec 29 '16 at 14:44
  • Clear cache and generated files and again recompile. Hope this will help you – Kishor Hase Sep 25 '17 at 16:28
0

Seem that you're trying to override the class Magento\Catalog\Controller\Adminhtml\Category\Image\Upload. So, make sure your custom class will extend from this class.

class Upload extends \Magento\Catalog\Controller\Adminhtml\Category\Image\Upload {
   ......
}
0

Not sure why you are getting the error itself but if i may suggest just making your file like this?

    namespace ....
    use Magento\Backend\App\Action;
use Magento\Catalog\Model\ImageUploader;

    class Upload extends Action{

        /**
         * Image uploader
         *
         * @var \Magento\Catalog\Model\ImageUploader
         */
        protected $imageUploader;

        /**
         * Upload constructor.
         *
         * @param Action\Context $context
         * @param \Magento\Catalog\Model\ImageUploader $imageUploader
         */
        public function __construct(
            Action\Context $context,
            ImageUploader $imageUploader
        ) {
            parent::__construct($context);
            $this->imageUploader = $imageUploader;
        }

    public function execute(){
    ....
    }

    }

I also suggest you use the Magento image uploader instead of the category uploader unless that is really your intention. Like here Create beautiful image upload in configuration magento 2

  • Just a comment. Since i do not know the intend or the page where you are using this i can not provide a specific solution but i hope this helps – CompactCode Mar 29 '18 at 2:49
0

Try to give a alias name for the extended class - as shown below:

use Magento\Catalog\Controller\Adminhtml\Category\Image\Upload as CatalogImageUopload

class Upload extends CatalogImageUopload
{
 -----write your code here---
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.