u
This commit is contained in:
@@ -54,6 +54,7 @@ export default function createUnderParent(provider) {
|
||||
let article;
|
||||
try {
|
||||
article = await runner.query(createArticleSql, {
|
||||
companyId,
|
||||
sku,
|
||||
unitId,
|
||||
unitamount: 1,
|
||||
|
||||
@@ -157,7 +157,7 @@ export default function importRows(provider) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const existing = await baseRunner.query(articleQueries.GET_ID_BY_SKU, { sku });
|
||||
const existing = await baseRunner.query(articleQueries.GET_ID_BY_SKU, { sku, companyId });
|
||||
if (existing.rows[0]) {
|
||||
skipped.push({ sku, name, reason: 'duplicate sku' });
|
||||
continue;
|
||||
@@ -169,6 +169,7 @@ export default function importRows(provider) {
|
||||
const slug = slugify(name);
|
||||
|
||||
const article = await runner.query(articleQueries.CREATE, {
|
||||
companyId,
|
||||
sku,
|
||||
unitId,
|
||||
unitamount: 1,
|
||||
@@ -277,10 +278,10 @@ export default function importRows(provider) {
|
||||
|
||||
try {
|
||||
await runInTx(async (runner) => {
|
||||
const child = await runner.query(articleQueries.GET_ID_BY_SKU, { sku });
|
||||
const child = await runner.query(articleQueries.GET_ID_BY_SKU, { sku, companyId });
|
||||
const childId = child.rows[0]?.articleId;
|
||||
if (childId) {
|
||||
const father = await runner.query(articleQueries.GET_ID_BY_SKU, { sku: fatherSku });
|
||||
const father = await runner.query(articleQueries.GET_ID_BY_SKU, { sku: fatherSku, companyId });
|
||||
const fatherId = father.rows[0]?.articleId;
|
||||
if (fatherId && fatherId !== childId) {
|
||||
const childCount = await runner.query(getChildCountSql, {
|
||||
@@ -289,6 +290,7 @@ export default function importRows(provider) {
|
||||
const count = childCount.rows[0].count;
|
||||
await runner.query(articleQueries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
companyId,
|
||||
fatherArticleId: fatherId,
|
||||
fathersort: count,
|
||||
});
|
||||
|
||||
@@ -30,11 +30,12 @@ export default function setFatherBySku(provider) {
|
||||
*/
|
||||
return async (googleAuthId, sku, fatherSku, tx) => {
|
||||
const runSet = async (runner) => {
|
||||
const { articleId, languageId } = await resolve(googleAuthId, sku, runner);
|
||||
const { articleId, languageId, companyId } = await resolve(googleAuthId, sku, runner);
|
||||
|
||||
if (fatherSku == null || fatherSku === '') {
|
||||
await runner.query(queries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
companyId,
|
||||
fatherArticleId: null,
|
||||
});
|
||||
const unlinked = await load(articleId, languageId, runner);
|
||||
@@ -44,7 +45,7 @@ export default function setFatherBySku(provider) {
|
||||
return unlinked;
|
||||
}
|
||||
|
||||
const father = await runner.query(queries.GET_ID_BY_SKU, { sku: fatherSku });
|
||||
const father = await runner.query(queries.GET_ID_BY_SKU, { sku: fatherSku, companyId });
|
||||
const fatherId = father.rows[0]?.articleId;
|
||||
if (!fatherId) {
|
||||
throw new Error('Father not found');
|
||||
@@ -60,6 +61,7 @@ export default function setFatherBySku(provider) {
|
||||
|
||||
await runner.query(queries.UPDATE_FATHER_BY_SKU, {
|
||||
sku,
|
||||
companyId,
|
||||
fatherArticleId: fatherId,
|
||||
fathersort: count,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user