I fixed it with the modification shown in the beginning. To reproduce the issue, do this:
1. Go to a product's page. There search in the Smart search module.
2. You will see that the website will launch the 404 Error.
In our case, the error is already fixed. You may test in your side. Thank you.