u
This commit is contained in:
@@ -242,6 +242,8 @@ export function sortArticlesByRelevance(articles, query) {
|
||||
export function searchArticlesIndex(query, options = {}) {
|
||||
const {
|
||||
excludeSkus = [],
|
||||
includeSkus = null,
|
||||
extraArticles = [],
|
||||
allowParent = false,
|
||||
categories = [],
|
||||
offset = 0,
|
||||
@@ -253,7 +255,15 @@ export function searchArticlesIndex(query, options = {}) {
|
||||
void articleIndexAutomat.actions.ensureLoaded().catch(() => {});
|
||||
}
|
||||
|
||||
const articles = articleIndexAutomat.state.items ?? [];
|
||||
let articles = articleIndexAutomat.state.items ?? [];
|
||||
if (Array.isArray(extraArticles) && extraArticles.length > 0) {
|
||||
const existingSkus = new Set(articles.map((a) => String(a.sku || '').toLowerCase()));
|
||||
const missing = extraArticles.filter((a) => a.sku && !existingSkus.has(String(a.sku).toLowerCase()));
|
||||
if (missing.length > 0) {
|
||||
articles = [...articles, ...missing];
|
||||
}
|
||||
}
|
||||
|
||||
const q = String(query ?? '').trim();
|
||||
|
||||
const rawMatches = q ? queryFlexSearch(q, articles) : articles;
|
||||
@@ -266,6 +276,10 @@ export function searchArticlesIndex(query, options = {}) {
|
||||
if (excludedSet.size > 0) {
|
||||
pool = pool.filter((a) => a.sku && !excludedSet.has(String(a.sku).toLowerCase()));
|
||||
}
|
||||
if (includeSkus != null) {
|
||||
const includedSet = new Set((includeSkus ?? []).map((s) => String(s).toLowerCase()));
|
||||
pool = pool.filter((a) => a.sku && includedSet.has(String(a.sku).toLowerCase()));
|
||||
}
|
||||
|
||||
let matchesList = pool;
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ export function createDeliveryEditorAutomat(options = {}) {
|
||||
});
|
||||
|
||||
try {
|
||||
const res = await supplierApi.getArticles(entityId, skus);
|
||||
const res = await supplierApi.getArticles(entityId);
|
||||
const articles = Array.isArray(res?.articles) ? res.articles : [];
|
||||
|
||||
const map = buildSupplierArticlesMap(articles);
|
||||
|
||||
Reference in New Issue
Block a user