Skip to content

Commit

Permalink
Fix bug with data being altered multiple times by reseting data array…
Browse files Browse the repository at this point in the history
…. Check for channelcode and prefer it over locale. (#14)

Co-authored-by: Robin Mulder <[email protected]>
  • Loading branch information
rbnmulder and Robin Mulder authored Jan 3, 2022
1 parent 496c215 commit 9e2d96c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Plugin/FixProductUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,18 @@ public function fixDuplicateUrls($tmpTableName)
$identifier = " LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM(`identifier`), ':', ''), ')', ''), '(', ''), ',', ''), '\/', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '--', '-'), '--', '-')) ";

foreach ($stores as $local) {
$data = [];
$channelCode = $local[0]['channel_code'] ?? false;
$local = "url_key-" . $local[0]['lang'];
$urlKey = $connection->tableColumnExists($tmpTableName, $local);

if ($channelCode) {
if ($connection->tableColumnExists($tmpTableName, $local.'-'.$channelCode)) {
$urlKey = true;
$local = $local.'-'.$channelCode;
}
}

if ($urlKey) {
$data[$local] = new expression("CONCAT(`" . $local . "`,'-' ," . $identifier . ")");

Expand Down

0 comments on commit 9e2d96c

Please sign in to comment.