Skip to content

Commit 4ac4143

Browse files
authored
Update ConvertConfigToJsonPatch.php
1 parent 1454dd4 commit 4ac4143

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Setup/Patch/Data/ConvertConfigToJsonPatch.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,30 @@ public function apply()
114114
$this->moduleDataSetup->endSetup();
115115
}
116116

117+
/**
118+
* @param $block
119+
* @return string
120+
*/
121+
protected function getNumberHashForBlock ($block): string {
122+
$numberHashFromString = sprintf('%u', crc32($block));
123+
$numberHashFromStringSuffix = substr($numberHashFromString, -3);
124+
125+
return '_' . $numberHashFromString . $numberHashFromStringSuffix . '_' . $numberHashFromStringSuffix;
126+
}
127+
117128
/**
118129
* @param $blocks
119130
* @return bool|string
120131
*/
121132
protected function getJsonForBlocks($blocks)
122133
{
123134
$arrayBlocks = [];
124-
$counter = 1;
125135
foreach ($blocks as $block) {
126-
$arrayBlocks[(string)$counter] =
136+
$arrayBlocks[$this->getNumberHashForBlock($block)] =
127137
[
128138
'block_identifier' => $block,
129139
'first_images_to_skip' => ($block == 'category.products.list') ? '2' : '0'
130140
];
131-
132-
$counter++;
133141
}
134142

135143
return $this->serializer->serialize($arrayBlocks);

0 commit comments

Comments
 (0)