I'm using Magento\Catalog\Model\CategoryFactory in my module and in unit tests.
Unit tests doesn't pass because CategoryFactory doesn't exists.
Class CategoryFactory exists in generated directory and doesn't exists in vendor. Magento 2 in first order check generated directory and if there is no searched class, then search inside vendor directory.
Directory generated was deleted many times and now have rights 777. I clean it many times and nothings help. During compile (setup:di:compile), Magento 2 creates needed files but some files doesn't use.
Earlier this code works and nothings change inside code, only programming environment. I'm using vagrant and CentOs on VirtualBox.
The same problem is with other *Factory classes. Do You have any idea, what is the problem?

  • try to delete the generated folder then run bin/magento setup:di:compile which will generate all necessary classes
    – Asad Khan
    Jun 21, 2019 at 10:57
  • I wrote that i did it many times. CategoryFactory exists inside generated but Magento don't use it and returns error.
    – Michal
    Jun 21, 2019 at 10:59
  • It would help if you shared the exact error you are getting. Jun 21, 2019 at 11:09
  • OK then I'm guessing not sure.. you can check the permission of the specific CategoryFactory file maybe the file don't have the permission
    – Asad Khan
    Jun 21, 2019 at 11:09
  • This file have 644 - file was created by magento during setup:di:compile
    – Michal
    Jun 21, 2019 at 11:13


Your Answer

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

Browse other questions tagged or ask your own question.