简体   繁体   English

无法覆盖Magento块(可能与缓存有关)

[英]Cannot Override Magento Block (Possibly Cache Related)

For some odd reason I cannot override Mage_Catalog_Block_Product_List on my production server. 由于某些奇怪的原因,我无法在生产服务器上覆盖Mage_Catalog_Block_Product_List

I have Magento running locally where I develop, then I rsync to my production server, so I'm pretty sure that the filesystems are the same (other than caches). 我有Magento在我开发的本地运行,然后我同步到我的生产服务器,所以我很确定文件系统是相同的(缓存除外)。

Here's what I've done so far - please note that this is working perfectly locally, just not on my production server for some reason: 这是我到目前为止已经完成-请注意,这是工作完全在本地,只是不是我由于某种原因,生产服务器上:

  • Created app/code/local/Mage/Catalog/Block/Product/List.php to override the Core version. 创建了app/code/local/Mage/Catalog/Block/Product/List.php以覆盖Core版本。

  • Added necessary code, tested locally, works fine. 添加了必要的代码,在本地测试,可以正常工作。 The updated code simply updates the _getProductCollection() function so that Magento sorts products in descending order by created_at date if $_GET['newest'] is set. 更新的代码仅更新_getProductCollection()函数,以便在设置了$_GET['newest']情况下,Magento按created_at日期对产品进行降序排序。 This works fine locally 这在本地工作正常

  • rsync'ed my updates to the production server. 将我的更新同步到生产服务器。 Didn't work, so I assumed it was cache-related. 没有用,所以我认为它与缓存有关。

  • Turned off caches, refreshed indexes. 关闭缓存,刷新索引。 Still nothing. 依然没有。

  • Deleted var/cache files, still nothing. 删除的var/cache文件,仍然没有。

  • Compared backend configuration to see if anything was off. 比较了后端配置,看是否有任何问题。 Everything looks good. 一切看起来都很好。

  • Added invalid code in my new block (List.php) on the production version so that it would cause an error. 在生产版本的新块(List.php)中添加了无效代码,这样会导致错误。 No error (?!). 没有错误(?!)。 It's as if the new file I uploaded is being ignored. 好像我上传的新文件被忽略了。

Any ideas would be greatly appreciated, as I am at a loss for ideas. 任何想法都将不胜感激,因为我对想法不知所措。

I'm on Magento v 1.7.0.2 我正在使用Magento v 1.7.0.2

Is your production server using Magento compilation mode? 您的生产服务器是否使用Magento编译模式? Magento compilation mode isn't really a compilation, it just copies all your class files out of the code cools, and places then in a single folder. Magento编译模式并不是真正的编译,它只是将所有类文件从代码库中复制出来,然后放在一个文件夹中。 This speeds up PHP (particularly older versions) tremendously. 这极大地提高了PHP(特别是较旧的版本)的速度。 If you've uploaded a new file to the local code pool for an override and you're using compilation mode, you'll probably need to recompile your classes ( System -> Tools -> Compiler , or the command line scripts in the shell/ folder). 如果您已将新文件上传到本地代码池中以供覆盖,并且您使用的是编译模式,则可能需要重新编译类( System -> Tools -> Compilershell/的命令行脚本) shell/文件夹)。

Also, is your production system using APC? 另外,您的生产系统是否使用APC? If so, then PHP has cached the old version of the class into APC, and won't look at your new version until you clear the APC cache. 如果是这样,则PHP已将类的旧版本缓存到APC中,并且在您清除APC缓存之前不会查看您的新版本。

Finally — are you uploading from a Mac/Windows machine to a unix environment? 最后-您是要从Mac / Windows计算机上传到UNIX环境吗? If so, try looking REALLY HARD at the file for case sensitivity errors. 如果是这样,请尝试在文件上查找“非常困难”,以区分大小写错误。 I usually go as far to try explicit ls 's from the root folder to make sure the file paths are named like I think they are. 我通常会尽量从根文件夹尝试显式ls ,以确保文件路径的命名方式与我认为的相同。

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM