5

I am getting this error on a page enter image description here 1 exception(s): Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Search\Model\EngineResolver, Argument 2 passed to Magento\Search\Model\EngineResolver::__construct() must be of the type array, null given, called in /var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

I am not sure how to fix this error ? any suggestions ?

1
  • any thoughts on this please ?
    – magedev
    Commented Oct 11, 2021 at 7:14

6 Answers 6

5
+25
  • First : Try to rm -rf generated/ then bin/magento setup:di:compile to be sure your generated code is the good one.

  • If the error persist you might have an issue in your magento installation ? I would recommend to make sure your composer dependencies is up do date with the vendor.

  • Quick fix if nothing works try to setup an empty array for the required null parameter and see what happens after compilation ?

7
  • Thanks for the advice. i am using magento 2.4.3 though Elastic search is not yet installed. i have disabled Elasticsearch extensions. I have debugged with disabling extension one by one to find out exact error. its related to elasticsearch.
    – magedev
    Commented Oct 11, 2021 at 8:33
  • If you disabled some module that are required by others modules, it might make sense that it's not working. I'm not saying that's what is happening but it might be. What was your error with ES ?
    – Claims
    Commented Oct 11, 2021 at 8:39
  • Exception #0 (BadMethodCallException): Missing required argument $adapters of Magento\Search\Model\AdapterFactory.
    – magedev
    Commented Oct 11, 2021 at 8:40
  • The above error i am facing.
    – magedev
    Commented Oct 11, 2021 at 8:48
  • This error basically means once again a constructor is called with a missing parameter. Which is usually due to a wrong code (but I assume your code is fine) or a not compiled code then setup di compile does the trick. Eventually try to make sure the ES modules are well activated : bin/magento module:enable Magento_Elasticsearch6 Magento_Elasticsearch Magento_Elasticsearch7 cause basically the above errors is magento telling you he need elastic.
    – Claims
    Commented Oct 11, 2021 at 8:56
3

You need to follow this steps :

  1. Confirm the Elasticsearch is configured and running properly for magento 2.4.3

  2. Try to run this command.

     php bin/magento cache:clean
     php bin/magento cache:flush
     php bin/magento indexer:reindex
     php bin/magento setup:upgrade
     php bin/magento setup:static-content:deploy -f
    
     php bin/magento setup:di:compile
    
     sudo chmod -R 777 var/ generated/ pub/
    
  3. Still It show the error then according to your screenshot, disable all the extension from "Amasty" and then check it.

  4. Still it not resolve then disable all third party extension first, then enable one by one and debug from where this issues comes.

3

I've faced same problem & solved as below details:

As per error log Magento\Search\Model\EngineResolver that meaning the problem in the Search module in Magento 2.4.0 and above required with Elasticsearch. So you will check if your server has Elasticsearch installed by here ref. and make sure that your Magento is enabled Elasticsearch modules by run:

sudo bin/magento module:status

if disabled then enable it by run:

sudo bin/magento module:enable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}

3

It's Error say must be enable below search engine extension in your magento2.

Magento/Elasticsearch6 
Magento/Elasticsearch 
Magento/Elasticsearch7
Magento/InventoryElasticsearch
Magento/AdvancedSearch

Also, you can run composer install / update.

Please check using below command your module in enable or not in magento.

php bin/magento module:status
1

Elasticsearch is required for latest Magento installations, it won't work without it.

You can work towards building your own mysql search after removing search functionality entirely for Magento along with elasticsearch if you do want to remove elasticsearch. If you want to go that route you can follow this blog post - https://www.yireo.com/blog/2020-09-26-removing-search-from-magento2

Also a heads up if you do want to install elasticsearch now, there have been people before reporting issues that the elasticsearch does not work if you install it after installing Magento. So, you might have to disable and then enable the Elasticsearch modules or in the worst case scenerio install the Magento again.

1

Issue 1. Magento 2.4.3 : Type Error occurred when creating object: Magento\Search\Model\EngineResolver

Solution: - This error basically means once again a constructor is called with a missing parameter. Which is usually due to a wrong code (but I assume your code is fine) or a not compiled code then setup di compile does the trick. Eventually try to make sure the ES modules are well activated :Hit This Command

php bin/magento module:enable Magento_Elasticsearch6 Magento_Elasticsearch Magento_Elasticsearch7

cause basically the above errors is magento telling you he need elastic.

And after that hit this commond

sudo rm -rf pub/static/frontend/ var/cache/;php bin/magento s:up;php bin/magento s:di:c;php bin/magento setup:static-content:deploy -f;php bin/magento indexer:reindex;php bin/magento c:f;sudo chmod -R 777 generated/ var/cache/ pub/static var/

I hope issues has been fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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