P5-6165 add datastudio view for product categories

This commit is contained in:
Martin Carlsson
2020-11-02 11:21:42 +01:00
committed by GitHub
parent 11f309941b
commit a44fb2d121
+18
View File
@@ -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;