3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Eav \Model \Entity \Attribute \Source ;
7
8
8
9
/**
@@ -65,7 +66,7 @@ public function getOptionText($value)
65
66
{
66
67
$ options = $ this ->getAllOptions ();
67
68
// Fixed for tax_class_id and custom_design
68
- if (sizeof ($ options ) > 0 ) {
69
+ if (count ($ options ) > 0 ) {
69
70
foreach ($ options as $ option ) {
70
71
if (isset ($ option ['value ' ]) && $ option ['value ' ] == $ value ) {
71
72
return isset ($ option ['label ' ]) ? $ option ['label ' ] : $ option ['value ' ];
@@ -88,7 +89,7 @@ public function getOptionText($value)
88
89
public function getOptionId ($ value )
89
90
{
90
91
foreach ($ this ->getAllOptions () as $ option ) {
91
- if (strcasecmp ($ option ['label ' ], $ value ) == 0 || $ option ['value ' ] == $ value ) {
92
+ if ($ this -> mbStrcasecmp ($ option ['label ' ], $ value ) == 0 || $ option ['value ' ] == $ value ) {
92
93
return $ option ['value ' ];
93
94
}
94
95
}
@@ -166,4 +167,20 @@ public function toOptionArray()
166
167
{
167
168
return $ this ->getAllOptions ();
168
169
}
170
+
171
+ /**
172
+ * Multibyte support strcasecmp function version.
173
+ *
174
+ * @param string $str1
175
+ * @param string $str2
176
+ * @return int
177
+ */
178
+ private function mbStrcasecmp ($ str1 , $ str2 )
179
+ {
180
+ $ encoding = mb_internal_encoding ();
181
+ return strcmp (
182
+ mb_strtoupper ($ str1 , $ encoding ),
183
+ mb_strtoupper ($ str2 , $ encoding )
184
+ );
185
+ }
169
186
}
0 commit comments