首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安装claue主题后,Magento 2在加载主页时出现错误

安装claue主题后,Magento 2在加载主页时出现错误
EN

Stack Overflow用户
提问于 2020-08-26 13:33:33
回答 1查看 465关注 0票数 1

我使用bitnami docker容器运行magento2,并安装了claue主题。安装了claue主题后,我得到了错误,同时加载登录页(主页)。

错误:

代码语言:javascript
复制
[php7:error] [pid 524] [client 172.18.0.1:36096] PHP Fatal error: Declaration of MGS\\Mpanel\\Helper\\Swatches\\Data::getProductMediaGallery(Magento\\Catalog\\Model\\Product $product) must be compatible with Magento\\Swatches\\Helper\\Data::getProductMediaGallery(Magento\\Catalog\\Model\\Product $product): array in /bitnami/magento/htdocs/app/code/MGS/Mpanel/Helper/Swatches/Data.php on line 0

样例/Data.php

代码语言:javascript
复制
use Magento\Catalog\Model\Product as ModelProduct;

public function getProductMediaGallery(ModelProduct $product){
    if(!in_array($product->getData('image'), [null, self::EMPTY_IMAGE_VALUE], true)){
        $baseImage = $prodcut->getData('image');
    }else{
        $productMedaiAttributes = array_filter($product->getMediaAttributeValues(), function($value){
            return $value !== self::EMPTY_IMAGE_VALUE && $values !== null;
        });
        foreach ($productMediaAttributes as $attributeCode => $value){
            if($attributeCode !== 'swatch_image'){
                $baseImage = (string)$value;
                break;
            }
        }
    }
    
    if(empty($baseImage)){
        return [];
    }

    $resultGallery = $this->getAllSizeImages($product, $baseImage);
    $resultGallery['gallery'] = $this->getGalleryImages($product);
    return $resultGallery;
}

我是php和magento的新手。我找不到解决这个问题的办法。请帮助解决这个问题。如果需要任何细节,请让我知道。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-26 14:11:08

正如错误消息所说,您必须通过在方法声明的末尾添加返回类型(在本例中为: array),使您的方法与您覆盖的方法兼容。您的代码行:public function getProductMediaGallery(ModelProduct $product){将变为:public function getProductMediaGallery(ModelProduct $product): array {

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63591088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档