安装 claue 主题后 Magento 2 在加载主页时出现错误
Magento 2 after installing claue theme getting error while loading home page
我 运行 magento2 使用 bitnami docker 容器,我安装了 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
Swatches/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 的新手。我无法找到解决此问题的方法。请帮助解决这个问题。如果需要任何详细信息,请告诉我。
提前致谢。
正如错误消息所说,您必须通过在方法声明的末尾添加 return 类型(在本例中为 : array
)使您的方法与您覆盖的方法兼容。
您的这行代码:public function getProductMediaGallery(ModelProduct $product){
将变为:public function getProductMediaGallery(ModelProduct $product): array {
我 运行 magento2 使用 bitnami docker 容器,我安装了 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
Swatches/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 的新手。我无法找到解决此问题的方法。请帮助解决这个问题。如果需要任何详细信息,请告诉我。
提前致谢。
正如错误消息所说,您必须通过在方法声明的末尾添加 return 类型(在本例中为 : array
)使您的方法与您覆盖的方法兼容。
您的这行代码:public function getProductMediaGallery(ModelProduct $product){
将变为:public function getProductMediaGallery(ModelProduct $product): array {