From 69ff764fdf27a2f7acb693a00f335763d40612d3 Mon Sep 17 00:00:00 2001 From: Rikard Bartholf Date: Thu, 5 Jan 2017 14:00:03 +0100 Subject: [PATCH] PW-602 Add col: listprice to product-printproducts --- migrations/000.026.sql | 63 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 migrations/000.026.sql diff --git a/migrations/000.026.sql b/migrations/000.026.sql new file mode 100644 index 0000000..60c5501 --- /dev/null +++ b/migrations/000.026.sql @@ -0,0 +1,63 @@ +-- PW-602 +DROP MATERIALIZED VIEW IF EXISTS v_esales_printproduct; +-- REFRESH MATERIALIZED VIEW v_esales_printproduct; +CREATE MATERIALIZED VIEW v_esales_printproduct AS +SELECT main.id, + main.product_id, + main.path, + main.article_number, + main.title, + main.group_id, + main.group_name, + main.type_id, + main.type_name, + main.listprice, + main.image, + main.thumbnail, + main.width, + main.height, + CASE + WHEN main.width::integer > main.height::integer THEN 'landscape'::text + WHEN main.width::integer < main.height::integer THEN 'portrait'::text + ELSE 'square'::text + END AS orientation + FROM ( + SELECT pp.printid AS id, + pp.productid AS product_id, + (SELECT path FROM "product-products" WHERE productid = pp.productid LIMIT 1) AS path, + ( + SELECT value FROM "product-products_fields" WHERE productid = pp.productid + AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = 'artNo' LIMIT 1) + ) AS article_number, + ( + SELECT value FROM "product-products_fields" WHERE productid = pp.productid + AND fieldid = (SELECT fieldid FROM "product-fields" WHERE field = 'name' LIMIT 1) + ) AS title, + pp.groupid AS group_id, + ( + SELECT "group" + FROM "product-groups" + WHERE groupid = pp.groupid + LIMIT 1 + ) AS group_name, + pp.typeid AS type_id, + ( + SELECT type + FROM "product-types" + WHERE typeid = pp.typeid + LIMIT 1 + ) AS type_name, + listprice, + ('//images.photowall.com/products/' || pp.productid) || '.jpg' AS image, + ('//images.photowall.com/products/' || pp.productid) || '.jpg?w=80' AS thumbnail, + (SELECT value FROM "product-products_fields" WHERE productid = pp.productid AND fieldid = 5 LIMIT 1) AS width, + (SELECT value FROM "product-products_fields" WHERE productid = pp.productid AND fieldid = 3 LIMIT 1) AS height + FROM "product-printproducts" pp + ) main; + +-- DROP INDEX v_categorytree_i18n_id_locale_id; +CREATE UNIQUE INDEX v_esales_printproduct_id + ON v_esales_printproduct (id); + +CREATE INDEX v_esales_printproduct_product_id + ON v_esales_printproduct (product_id);