I am working on a Magento 2 website and I have made a copy of the website in order to copy it to a different folder on the same server for staging / production environments.
I carried out the below actions:
- Copied all files and folders
- Copied the database
- Copied all files to new folder
- Created new database
- Imported database copy but with URLs changed
- Updated config to point to new database
- Removed var, vendor & pub static contents
- Ran the following commands:
- composer install
- php bin/magento setup:upgrade
- php bin/magento setup:di:compile
- php bin/magento setup:static-content:Deploy -f
- chmod -R 777 var/ generated/ pub/static
- php bin/magento cache:clean
- php bin/magento cache:flush
- bin/magento indexer:reindex
I have also enabled errors and developer mode. And when I visit the homepage I get a 500 internal server error but with no visible error.
The admin panel and sub pages seem to work fine, but getting an empty screen / 500 error for the homepage.
I see the following errors in the server log:
[23-May-2020 07:54:49 UTC] PHP Fatal error: Uncaught Error: Call to a member function addAttributeToFilter() on null in /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php:276
Stack trace:
#0 /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php(201): SmFilterProductsBlockFilterProducts->_featuredProducts()
#1 /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php(496): SmFilterProductsBlockFilterProducts->_getProducts()
#2 /var/www/vhosts/websitename/htdocs/generated/code/Sm/FilterProducts/Block/FilterProducts/Interceptor.php(102): SmFilterProductsBlockFilterProducts->getLoadedProductCollection()
#3 /var/www/vhosts/websitename/htdocs/app/design/frontend/Sm/shiny/Sm_FilterProducts/templates/default-grid.phtml(15): SmFilterProductsBlockFilterProductsInterceptor->getLoadedProductCollection()
#4 /var/www/vhosts/websitename/htdocs/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/var/ww in /var/www/vhosts/websitename/htdocs/app/code/Sm/FilterProducts/Block/FilterProducts.php on line 276
When I have viewed the magento debug log, I’m seeing the following errors:
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'wishlist_sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'yotpo_bottomline' element cannot be added as child to 'product.info.main', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'banner-sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'footer_blog_link' element cannot be added as child to 'footer_links', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'paypal.partner.right.logo' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'bml.right.logo' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2020-05-22 22:01:55] main.INFO: Broken reference: the 'yotpo_bottomline' tries to reorder itself towards 'product.info.addto', but their parents are different: 'product.info.main' and '' respectively. [] []
I’ve spent most of the day on this but have not been able to figure out the issue.
Many thanks in advance for any guidance anybody may be able to provide.
3
Answers
I recopied files from the app directory and it resolved the issue. I believe I may have been missing some classes.
I don’t know magento, but from experience with WordPress and other big PHP apps I would be inclined to do these steps first, then see what happens. You may find that the magento command line things you’re doing are somehow screwing with your configuration or data – don’t run them until the install is working first.
So, try starting again, but only doing these steps:
There may be some magento specific stuff with clearing caches or something, if it’s at all possible to do that before you start this process without messing up your prod environment try to do that.
I don’t know magento, but from experience with WordPress and other big PHP apps I would be inclined to do these steps first, then see what happens. You definitely don’t want to do multiple steps like upgrading magento while you’re also moving it to a new location. You may find that the magento command line things you’re doing are somehow screwing with your configuration or data – don’t run them until the install is working first.
So, try starting again, but only doing these steps:
There may be some magento specific stuff with clearing caches or something, if it’s at all possible to do that before you start this process without messing up your prod environment try to do that.