@@ -52,11 +52,6 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
52
52
*/
53
53
private $ imageUploader ;
54
54
55
- /**
56
- * @var string
57
- */
58
- private $ additionalData = '_additional_data_ ' ;
59
-
60
55
/**
61
56
* Image constructor.
62
57
*
@@ -85,9 +80,9 @@ public function beforeSave($object)
85
80
{
86
81
$ attributeName = $ this ->getAttribute ()->getName ();
87
82
$ value = $ object ->getData ($ attributeName );
83
+ $ imageName = $ this ->getUploadedImageName ($ value );
88
84
89
- if ($ imageName = $ this ->getUploadedImageName ($ value )) {
90
- $ object ->setData ($ this ->additionalData . $ attributeName , $ value );
85
+ if ($ imageName ) {
91
86
$ object ->setData ($ attributeName , $ imageName );
92
87
} else if (!is_string ($ value )) {
93
88
$ object ->setData ($ attributeName , '' );
@@ -130,27 +125,15 @@ private function getImageUploader()
130
125
}
131
126
132
127
/**
133
- * Check if temporary file is available for new image upload.
134
- *
135
- * @param array $value
136
- * @return bool
137
- */
138
- private function isTmpFileAvailable ($ value )
139
- {
140
- return is_array ($ value ) && isset ($ value [0 ]['tmp_name ' ]);
141
- }
142
-
143
- /**
144
- * Save uploaded file and set its name to category
128
+ * Save uploaded file and set its name to category.
145
129
*
146
130
* @param \Magento\Framework\DataObject $object
147
131
* @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
148
132
*/
149
133
public function afterSave ($ object )
150
134
{
151
- $ value = $ object ->getData ($ this ->additionalData . $ this ->getAttribute ()->getName ());
152
-
153
- if ($ this ->isTmpFileAvailable ($ value ) && $ imageName = $ this ->getUploadedImageName ($ value )) {
135
+ $ imageName = $ object ->getData ($ this ->getAttribute ()->getName (), null );
136
+ if ($ imageName ) {
154
137
try {
155
138
$ this ->getImageUploader ()->moveFileFromTmp ($ imageName );
156
139
} catch (\Exception $ e ) {
0 commit comments