-- Recreate v_esales_product_categories as a regular view

-- Below is output of \d+ v_esales_product_categories
CREATE VIEW v_esales_product_categories_unmaterialized AS
SELECT DISTINCT tree.id,
                tree.locale_id,
                getsafexmlpath(tree.path::character varying, 2) AS path,
                category_texts.name,
                product_category.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;
