From 35f331bc86ef2390cf73e23966f1fa0db862c879 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 2 Sep 2024 07:46:44 +0200 Subject: [PATCH] Fixed issues #4134 undefined array index label_use_default in Mage_Catalog_Model_Product_Attribute_Backend_Media (#4136) * fix issues 4134 * better code Co-authored-by: kiatng --------- Co-authored-by: Ng Kiat Siong --- .../Mage/Catalog/Model/Product/Attribute/Backend/Media.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php index 142faed3128..9bbd405d247 100644 --- a/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php +++ b/app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php @@ -167,11 +167,13 @@ public function beforeSave($object) foreach ($value['values'] as $mediaAttrCode => $attrData) { if (array_key_exists($attrData, $newImages)) { $object->setData($mediaAttrCode, $newImages[$attrData]['new_file']); - $object->setData($mediaAttrCode . '_label', ($newImages[$attrData]['label'] === null || $newImages[$attrData]['label_use_default']) ? $newImages[$attrData]['label_default'] : $newImages[$attrData]['label']); + $label = $newImages[$attrData]['label'] === null || !empty($newImages[$attrData]['label_use_default']) ? $newImages[$attrData]['label_default'] : $newImages[$attrData]['label']; + $object->setData($mediaAttrCode . '_label', $label); } if (array_key_exists($attrData, $existImages)) { - $object->setData($mediaAttrCode . '_label', ($existImages[$attrData]['label'] === null || $existImages[$attrData]['label_use_default']) ? $existImages[$attrData]['label_default'] : $existImages[$attrData]['label']); + $label = $existImages[$attrData]['label'] === null || !empty($existImages[$attrData]['label_use_default']) ? $existImages[$attrData]['label_default'] : $existImages[$attrData]['label']; + $object->setData($mediaAttrCode . '_label', $label); } }