Magento2 没有拾取模块的块

Magento2 not picking up module's Block

我收到这个错误:

Fatal error: Call to a member function getPrice() on null in /home/.../public_html/vendor/magento/module-checkout/Block/Shipping/Price.php on line 71

所以,在阅读 this solution here 之后,我修改了这个文件:

/app/design/frontend/Package/Theme/Magento_Checkout/Block/Shipping/Price.php

但是,我仍然不断收到同样的错误:

Fatal error: Call to a member function getPrice() on null in /home/.../public_html/vendor/magento/module-checkout/Block/Shipping/Price.php on line 71

这让我觉得 Magento2 忽略了我在 Magento_Checkout 中的 Block,并默认回到 Magento2 自己的核心代码。

如何解决这个问题(不编辑核心代码)。

我需要做些什么来注册这个区块吗?


在我被问到之前:

我已经部署:

php bin/magento setup:static-content:deploy

我已经重新索引:

php bin/magento indexer:reindex

我已经清除了缓存:

php bin/magento cache:clean
php bin/magento cache:flush

而且 Magento 2 处于痛苦的缓慢开发者模式。

我已经对 /app/design/frontend/Package/Theme/Magento_Checkout/view/frontend/templates/... 中的视图文件进行了更改,这些都运行良好。他们没有被忽略,只有 /app/design/frontend/Package/Theme/Magento_Checkout/Block 被忽略。


我认为 my problem here 可能相关,我已经对 Magento_CatalogSearch 的 XML 布局进行了更改,但这些更改被忽略了,默认的 XML 布局是正在使用。

这似乎已经在另一个表格中得到了回答,https://mage2.pro/t/topic/1017

通过将 app/code/Magento/Checkout/Block/Shipping/Price.php 中的行 71 更改为 return !$this->shippingRate ? null : $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice()); 应该可以修复它。