u
This commit is contained in:
@@ -3,12 +3,13 @@ import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'article');
|
||||
export const {
|
||||
ADD_CATEGORY, ADD_EAN, ARTICLE_LIST_COLUMNS, CREATE,
|
||||
ADD_CATEGORY, ADD_EAN, ARTICLE_LIST_COLUMNS, CREATE, CREATE_CHILD,
|
||||
DELETE_CATEGORIES_BY_ARTICLE, DELETE_EANS_BY_ARTICLE, EAN_EXISTS,
|
||||
GET_BRAND_BY_COMPANY_AND_ID,
|
||||
GET_CATEGORY_ID_BY_SKU, GET_CATEGORY_TREE_FLAT, GET_ID_BY_SKU,
|
||||
LIST_CHILDREN_BY_FATHER_ID,
|
||||
SET_FATHER_SORT,
|
||||
SET_IS_FATHER, UPDATE_BRAND, UPDATE_FATHER_BY_SKU, UPDATE_TRACK_STOCK, UPDATE_UNIT,
|
||||
SET_IS_FATHER, TOGGLE_FATHER, UNLINK_CHILD, UPDATE_BRAND, UPDATE_FATHER_BY_SKU, UPDATE_TRACK_STOCK, UPDATE_UNIT,
|
||||
UPDATE_UNITAMOUNT, UPDATE_UNIT_AND_AMOUNT, UPDATE_WEIGHT,
|
||||
} = queries;
|
||||
|
||||
@@ -133,7 +134,24 @@ SELECT auth.*,
|
||||
'optionsCount', (SELECT COUNT(*) FROM optionslistarticle WHERE optionslist_id = a.optionslist_id),
|
||||
'articleListCount', (SELECT COUNT(*) FROM articlelistarticle WHERE articlelist_id = a.articlelist_id),
|
||||
'childCount', (SELECT COUNT(*) FROM article WHERE fatherarticle_id = a.id),
|
||||
'isFather', a.is_father,
|
||||
'fatherAttributeNameId', a.fatherattributename_id,
|
||||
'fatherAttributeName', fan.name,
|
||||
'fatherAttributeExclusive', fan.exclusive,
|
||||
'fatherArticleId', a.fatherarticle_id, 'fatherSku', father.sku,
|
||||
'childrenJson', json((SELECT COALESCE(json_group_array(json_object(
|
||||
'id', child.id,
|
||||
'sku', child.sku,
|
||||
'fathersort', child.fathersort,
|
||||
'name', at_child.name,
|
||||
'attributeValueId', av.id,
|
||||
'attributeValue', av.value
|
||||
)), '[]') FROM article child
|
||||
LEFT JOIN articletext at_child ON at_child.article_id = child.id AND at_child.language_id = auth.languageId
|
||||
LEFT JOIN articleattributevalue aav ON aav.article_id = child.id
|
||||
LEFT JOIN attributevalue av ON av.id = aav.attributevalue_id AND av.attribute_id = a.fatherattributename_id
|
||||
WHERE child.fatherarticle_id = a.id
|
||||
ORDER BY child.fathersort ASC, child.id ASC)),
|
||||
'categoryIdsJson', json(${JSON_CATEGORIES}),
|
||||
'photosJson', json((SELECT COALESCE(json_group_array(json_object(
|
||||
'sort', sort, 'fullHash', hash, 'fullW', w, 'fullH', h,
|
||||
@@ -197,4 +215,5 @@ LEFT JOIN pic bp ON bp.id = (
|
||||
SELECT pic_id FROM brandpic WHERE brand_id = b.id ORDER BY sort, id LIMIT 1
|
||||
)
|
||||
LEFT JOIN article father ON father.id = a.fatherarticle_id
|
||||
LEFT JOIN attributename fan ON fan.id = a.fatherattributename_id
|
||||
`;
|
||||
Reference in New Issue
Block a user