Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/community/Pimgento/Api/Model/Job/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ public function updateOption($task)
$columnParts = explode('-', $column, 2);
/** @var string $columnPrefix */
$columnPrefix = reset($columnParts);
$columnPrefix = sprintf('%s_', $columnPrefix);
$columnPrefix = sprintf('%s-', $columnPrefix);
/** @var int $prefixLength */
$prefixLength = strlen($columnPrefix) + 1;
/** @var string $entitiesTable */
Expand Down
17 changes: 13 additions & 4 deletions app/code/community/Pimgento/Api/Model/Resource/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,16 @@ public function matchEntity($entityCode, $entityTableAlias, $primaryKey, $prefix
/** @var string $entityCodeColumnName */
$entityCodeColumnName = sprintf('t.`%s`', $entityCode);
if ($prefix !== '') {
$entityCodeColumnName = sprintf('CONCAT(t.`%s`, "_", t.`%s`)', $prefix, $entityCode);
/* Use new error-free separator */
$entityCodeColumnName = sprintf('CONCAT(t.`%s`, "-", t.`%s`)', $prefix, $entityCode);

/* Legacy: update columns still using former "_" separator */
/** @var string $oldEntityCodeColumnName */
$oldEntityCodeColumnName = sprintf('CONCAT(t.`%s`, "_", t.`%s`)', $prefix, $entityCode);
/** @var string $update */
$update = 'UPDATE `' . $pimgentoTable . '` AS `e`, `' . $tableName . '` AS `t` SET e.code = ' . $entityCodeColumnName . ' WHERE e.code = ' . $oldEntityCodeColumnName . ' AND e.`import` = "' . $import . '"';

$adapter->query($update);
}

/* Update entity_id column from pimgento_entities table */
Expand Down Expand Up @@ -560,9 +569,9 @@ public function matchEntity($entityCode, $entityTableAlias, $primaryKey, $prefix
/** @var string $maxCode */
$maxCode = $adapter->fetchOne(
$adapter->select()->from($pimgentoTable, new Zend_Db_Expr(sprintf('MAX(`%s`)', $entitiesIdFieldName)))->where(
'import = ?',
$import
)
'import = ?',
$import
)
);
/** @var string $maxEntity */
$maxEntity = $adapter->fetchOne(
Expand Down