Open
Fix category image backend normalization for store-view saves#5623
Conversation
1 task
Copilot
AI
changed the title
[WIP] Fix array to string conversion error when saving category
Fix category image backend normalization for store-view saves
Jun 1, 2026
|
Hanmac
approved these changes
Jun 1, 2026
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes category image attribute normalization when saving a category in a non-default store view. It ensures that when the image field posts as an array payload ([value]/[delete] from Varien_Data_Form_Element_Image), the backend converts it back to a scalar filename (or clears it on delete), preventing “Array to string conversion” errors during/after the save flow.
Changes:
- Extend
Mage_Catalog_Model_Category_Attribute_Backend_Image::afterSave()to handle non-delete array payloads by mapping them to$value['value'] ?? ''. - Preserve existing delete behavior (clear attribute +
saveAttribute()+ early return). - Ensure the category model holds a scalar image value before subsequent processing (e.g., file upload handling and post-save observers).
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Saving a category in a non-default store view could trigger an
Array to string conversionwhen an image was already assigned. The image field posts as an array (value/delete), but the category image backend only handleddelete, leaving array data to reach persistence.Root cause
Mage_Catalog_Model_Category_Attribute_Backend_Image::afterSave()handled['delete' => 1]but did not normalize['value' => '...'].Change
$value['value'] ?? '')Scope
app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php