u
This commit is contained in:
@@ -6,11 +6,10 @@ import {
|
||||
ADD_CATEGORY as SQLITE_ADD_CATEGORY,
|
||||
DELETE_CATEGORIES_BY_ARTICLE as SQLITE_DELETE_CATEGORIES,
|
||||
} from '../../providers/sqlite3/queries/article.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 resolveCategoryAccess from '../category/resolveCategoryAccess.js';
|
||||
import queryBySku from './queryBySku.js';
|
||||
import resolveArticleBySku from './resolveArticleBySku.js';
|
||||
import { recordCategoryChangeHistory } from '../articlehistory/record.js';
|
||||
import makeRunner from '../runner.js';
|
||||
|
||||
export default function setCategoryIdsBySku(provider) {
|
||||
@@ -21,7 +20,6 @@ export default function setCategoryIdsBySku(provider) {
|
||||
|
||||
const addCategorySql = isSqlite ? SQLITE_ADD_CATEGORY : MSSQL_ADD_CATEGORY;
|
||||
const deleteCategoriesSql = isSqlite ? SQLITE_DELETE_CATEGORIES : MSSQL_DELETE_CATEGORIES;
|
||||
const insertHistorySql = isSqlite ? SQLITE_INSERT_HISTORY : MSSQL_INSERT_HISTORY;
|
||||
|
||||
/**
|
||||
* Replaces the category membership of an article by its SKU.
|
||||
@@ -86,15 +84,12 @@ export default function setCategoryIdsBySku(provider) {
|
||||
}
|
||||
|
||||
// Write history if categories changed
|
||||
const oldStr = oldCategoryIds.join(', ');
|
||||
const newStr = [...normalized].sort((a, b) => a - b).join(', ');
|
||||
if (oldStr !== newStr) {
|
||||
await runner.query(insertHistorySql, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
text: `Kategorien geändert von [${oldStr}] auf [${newStr}]`,
|
||||
});
|
||||
}
|
||||
await recordCategoryChangeHistory(runner, {
|
||||
articleId,
|
||||
companyuserId,
|
||||
oldCategoryIds,
|
||||
newCategoryIds: normalized,
|
||||
});
|
||||
|
||||
const article = await load(articleId, languageId, runner);
|
||||
if (!article) {
|
||||
|
||||
Reference in New Issue
Block a user