Skip to content

Commit

Permalink
Fixed issues #4134 undefined array index label_use_default in Mage_Ca…
Browse files Browse the repository at this point in the history
…talog_Model_Product_Attribute_Backend_Media (#4136)

* fix issues 4134

* better code
Co-authored-by: kiatng

---------

Co-authored-by: Ng Kiat Siong <kiatsiong.ng@gmail.com>
  • Loading branch information
empiricompany and kiatng authored Sep 2, 2024
1 parent 33adc74 commit 35f331b
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 35f331b

Please sign in to comment.