If you change a PHP, XML or template file in Magento 2 and still see the old version after clearing the cache, it does not necessarily mean you edited the wrong file. Generated code, static assets, PHP OPcache, Varnish or a CDN may continue to serve old content.
For templates, Magento Template Hints can help you identify which .phtml template and block are actually used. Run the following command from the CLI and reload the storefront.
|
1 |
bin/magento dev:template-hints:enable |
For PHP classes, dev:di:info is useful because it identifies the active preference and plugins for a given class.
|
1 |
bin/magento dev:di:info 'Magento\Catalog\Block\Product\View' |
When changing PHP classes, preferences or plugins, you may also need to compile again, especially in Production Mode.
|
1 |
bin/magento setup:di:compile |
Magento regenerates proxies, factories and interceptors. Old generated code can therefore prevent changes from appearing even after clearing the cache.
Custom modules can also involve preferences and plugins that replace or intercept the class you expected to execute. Template overrides and Magento’s fallback mechanism add another layer, so a simple bin/magento cache:flush cannot fix every such issue.
If your changes still do not appear, first determine which code is actually running and which module or theme provides it..