@@ -49,7 +49,6 @@ class Product extends AbstractEntity
49
49
{
50
50
private const DEFAULT_GLOBAL_MULTIPLE_VALUE_SEPARATOR = ', ' ;
51
51
public const CONFIG_KEY_PRODUCT_TYPES = 'global/importexport/import_product_types ' ;
52
- private const HASH_ALGORITHM = 'sha256 ' ;
53
52
54
53
/**
55
54
* Size of bunch - part of products to save in one step.
@@ -264,6 +263,11 @@ class Product extends AbstractEntity
264
263
*/
265
264
protected $ _mediaGalleryAttributeId = null ;
266
265
266
+ /**
267
+ * @var string
268
+ */
269
+ private $ hashAlgorithm = 'crc32c ' ;
270
+
267
271
/**
268
272
* @var array
269
273
* @codingStandardsIgnoreStart
@@ -904,7 +908,7 @@ public function __construct(
904
908
$ this ->linkProcessor = $ linkProcessor ?? ObjectManager::getInstance ()
905
909
->get (LinkProcessor::class);
906
910
$ this ->linkProcessor ->addNameToIds ($ this ->_linkNameToId );
907
-
911
+ $ this -> hashAlgorithm = ( version_compare ( PHP_VERSION , ' 8.1.0 ' ) >= 0 ) ? ' xxh128 ' : ' crc32c ' ;
908
912
parent ::__construct (
909
913
$ jsonHelper ,
910
914
$ importExportData ,
@@ -3344,17 +3348,17 @@ private function findImageByColumnImage(string $productMediaPath, array &$images
3344
3348
*/
3345
3349
private function findImageByColumnImageUsingHash (string $ productMediaPath , array &$ images , string $ content ): string
3346
3350
{
3347
- $ hash = hash (self :: HASH_ALGORITHM , $ content );
3351
+ $ hash = hash ($ this -> hashAlgorithm , $ content );
3348
3352
foreach ($ images as &$ image ) {
3349
3353
if (!isset ($ image ['hash ' ])) {
3350
3354
$ imageContent = $ this ->getFileContent ($ this ->joinFilePaths ($ productMediaPath , $ image ['value ' ]));
3351
3355
if (!$ imageContent ) {
3352
3356
$ image ['hash ' ] = '' ;
3353
3357
continue ;
3354
3358
}
3355
- $ image ['hash ' ] = hash (self :: HASH_ALGORITHM , $ imageContent );
3359
+ $ image ['hash ' ] = hash ($ this -> hashAlgorithm , $ imageContent );
3356
3360
}
3357
- if (isset ($ image ['hash ' ]) && $ image ['hash ' ] === $ hash ) {
3361
+ if (! empty ($ image ['hash ' ]) && $ image ['hash ' ] === $ hash ) {
3358
3362
return $ image ['value ' ];
3359
3363
}
3360
3364
}
0 commit comments