public function getProductMediaGallery(ModelProduct $product)
{
if (!in_array($product->getData('image'), [null, self::EMPTY_IMAGE_VALUE], true)) {
$baseImage = $product->getData('image');
} else {
$productMediaAttributes = array_filter($product->getMediaAttributeValues(), function ($value) {
return $value !== self::EMPTY_IMAGE_VALUE && $value !== 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;
}
how can i set isset condition please kindly help
this is my error after updating Magento from 2.2.3 to 2.3.5
[Sat Oct 10 01:11:06.447121 2020] [php7:error] [pid 19107] [client 72.255.57.102:33964] 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 /var/www/html/app/code/MGS/Mpanel/Helper/Swatches/Data.php on line 0,
For me the solution was to set function
getProductMediaGalleryto array:
public function getProductMediaGallery(ModelProduct $product): array