php - Magento 2安装claue主题后加载主页时出错
问题描述
我使用 bitnami docker 容器运行 magento2 并安装了 claue 主题。安装 claue 主题后,我在加载登录页面(主页)时遇到错误。
错误:
[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
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 的新手。我不知道如何解决这个问题。请帮助解决这个问题。如果需要任何细节,请告诉我。
提前致谢。
解决方案
: array
正如错误消息所说,您必须通过在方法声明的末尾添加返回类型(在本例中)来使您的方法与您覆盖的方法兼容。这行代码:public function getProductMediaGallery(ModelProduct $product){
将变为:public function getProductMediaGallery(ModelProduct $product): array {
推荐阅读
- android - 将自签名 SSL 证书添加到 HttpURLConnection
- typescript - 如何使用 Create React App 和 TypeScript 启用可选链接
- json - JSON 查询表达式 (JMESPath) 从嵌套的字典列表中删除键/值
- javascript - 对数组进行分组和排序
- oracle - 创建索引组织表的正确方法
- c# - 在wpf中计算具有已知宽度和高度以及字体的文本框的字符容量
- apache-spark - GraphX 的基于内存的 shuffle 和 Spark Core 的 shuffle 有什么区别
- python - 替换缺失数据,显示为 ? 在数据集中,平均值为 SimpleImputer
- pascal - Turbo Pascal 7 中的弹出窗口
- java - 有没有一种方法可以使用 JPA 存储库方法关键字来搜索列中的术语列表?