From a44fb2d121be9f10f02bebb957d19dfcb7fe3f74 Mon Sep 17 00:00:00 2001 From: Martin Carlsson Date: Mon, 2 Nov 2020 11:21:42 +0100 Subject: [PATCH] P5-6165 add datastudio view for product categories --- migrations/000.258.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 migrations/000.258.sql diff --git a/migrations/000.258.sql b/migrations/000.258.sql new file mode 100644 index 0000000..d3fe1cb --- /dev/null +++ b/migrations/000.258.sql @@ -0,0 +1,18 @@ +-- P5-6165: create datastudio view for product categories + +drop view if exists v_analytics_product_categories; + +create view v_analytics_product_categories as + select distinct + tree.id as category_id, + getsafexmlpath(tree.path::character varying, 2) as category_path, + category_texts.name as category_name, + product_category.product_id as product_id + from product_category + join categories on product_category.category_id = categories.id + join categories hidden_category on hidden_category.name::text = 'hidden'::text + join v_esales_categorytree_i18n tree on (tree.lft < categories.lft and tree.rgt > categories.rgt or categories.id = tree.id) and tree.id <> 1 and (tree.lft < hidden_category.lft or tree.lft > hidden_category.rgt) + join category_texts on tree.id = category_texts.category_id and tree.locale_id = category_texts.locale_id + where tree.locale_id = 3; + +grant select on v_analytics_product_categories to datastudio;