[英]Magento 2 after installing claue theme getting error while loading home page
我使用 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 {
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.