Magento 2:启用整页缓存后,获得500内部服务器错误

时间:2017-09-15 07:03:48

标签: magento2

在Magento2站点中启用FPC(整页缓存)功能后,它会显示“内部服务器错误500”并且站点未运行。

1 个答案:

答案 0 :(得分:1)

最后我收到了来自哪里的错误并设法解决了它。它对我有用。

通过覆盖\ Magento \ Catalog \ Block \ Product \ View

中的函数getIdentities()

public function getIdentities()
{
    $identities = $this->getProduct()->getIdentities();
    $category = $this->_coreRegistry->registry('current_category');
    if ($category) {
        $identities[] = Category::CACHE_TAG . '_' . $category->getId();
    }
    return $identities;
}

public function getIdentities()
{
    $identities = [];

    if (is_array($this->getItems()) || is_object($this->getItems()))
    {
        foreach ($this->getItems() as $item)
        {
            $identities = array_merge($identities, $item->getIdentities());
        }
    }
    return $identities;
}