文件
xionggeshop/addons/shopro/fix_menu_home.sql

43 行
1.3 KiB
SQL

-- 修复首页分类宫格 menu.list 为空
-- 根因:装修表里 menu 组件存在,但 content.list 为 [],首页 sh-grid-swiper 不渲染
-- 执行后清除 Shopro 缓存,重新进入小程序即可
SET @root_id = (
SELECT id FROM `fa_shopro_category`
WHERE `pid` = 0 AND `status` = 'normal'
ORDER BY `weigh` DESC, `id` DESC
LIMIT 1
);
SET @menu_json = (
SELECT CONCAT(
'{"name":"","style":5,"list":[',
IFNULL(GROUP_CONCAT(
JSON_OBJECT(
'name', `name`,
'image', `image`,
'path', CONCAT('/pages/goods/list?id=', `id`),
'path_name', `name`,
'path_type', 1
)
ORDER BY `weigh` DESC, `id` ASC
SEPARATOR ','
), ''),
']}'
)
FROM `fa_shopro_category`
WHERE `pid` = @root_id AND `type` = 'shop' AND `status` = 'normal'
);
UPDATE `fa_shopro_decorate_content`
SET `content` = @menu_json
WHERE `category` = 'home'
AND `type` = 'menu'
AND @root_id IS NOT NULL
AND @menu_json IS NOT NULL
AND @menu_json LIKE '%"list":[{%';
-- 验证(应返回 list 含 10 项):
-- SELECT id, type, JSON_LENGTH(JSON_EXTRACT(content, '$.list')) AS cnt, LEFT(content, 200)
-- FROM fa_shopro_decorate_content WHERE category='home' AND type='menu';