u
This commit is contained in:
@@ -8,9 +8,8 @@ import {
|
||||
INSERT_ROW as SQLITE_INSERT,
|
||||
GET_VALUE_DETAIL as SQLITE_GET_DETAIL,
|
||||
} from '../../providers/sqlite3/queries/articleattributevalue.js';
|
||||
import { INSERT as MSSQL_INSERT_HISTORY } from '../../providers/mssql/queries/articlehistory.js';
|
||||
import { INSERT as SQLITE_INSERT_HISTORY } from '../../providers/sqlite3/queries/articlehistory.js';
|
||||
import resolveArticleBySku from '../article/resolveArticleBySku.js';
|
||||
import { recordAttributeChangeHistory } from '../articlehistory/record.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
export default function setByArticleSku(provider) {
|
||||
@@ -19,7 +18,6 @@ export default function setByArticleSku(provider) {
|
||||
const deleteSql = isSqlite ? SQLITE_DELETE : MSSQL_DELETE;
|
||||
const insertSql = isSqlite ? SQLITE_INSERT : MSSQL_INSERT;
|
||||
const getDetailSql = isSqlite ? SQLITE_GET_DETAIL : MSSQL_GET_DETAIL;
|
||||
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
|
||||
|
||||
/**
|
||||
* Replaces all attribute values for an article by its SKU.
|
||||
@@ -182,16 +180,12 @@ export default function setByArticleSku(provider) {
|
||||
}
|
||||
|
||||
// Write history if attribute values changed
|
||||
const fmtAttr = (a) => `${a.attributeName}: ${a.value}`;
|
||||
const oldStr = oldAttrs.map(fmtAttr).join(', ');
|
||||
const newStr = validated.map(fmtAttr).join(', ');
|
||||
if (oldStr !== newStr) {
|
||||
await runner.query(insertHistorySql, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
text: `Attributwerte geändert von [${oldStr}] auf [${newStr}]`,
|
||||
});
|
||||
}
|
||||
await recordAttributeChangeHistory(runner, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
oldAttrs,
|
||||
newAttrs: validated,
|
||||
});
|
||||
|
||||
return inserted;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user