Merge branch 'main' of ssh://git.ma-al.com:8822/goc_daniel/b2b into product-procedures

This commit is contained in:
2026-03-30 15:17:53 +02:00
444 changed files with 10123 additions and 3830 deletions

View File

@@ -253,6 +253,97 @@ ON b2b_specific_price_customer (b2b_specific_price_id, b2b_id_customer);
CREATE INDEX idx_bsp_country
ON b2b_specific_price_country (b2b_specific_price_id, b2b_id_country);
DELIMITER //
CREATE FUNCTION IF NOT EXISTS slugify_eu(input TEXT)
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE s TEXT;
SET s = LOWER(input);
-- spaces
SET s = REPLACE(s,' ','_');
-- Polish
SET s = REPLACE(s,'ą','a');
SET s = REPLACE(s,'ć','c');
SET s = REPLACE(s,'ę','e');
SET s = REPLACE(s,'ł','l');
SET s = REPLACE(s,'ń','n');
SET s = REPLACE(s,'ó','o');
SET s = REPLACE(s,'ś','s');
SET s = REPLACE(s,'ż','z');
SET s = REPLACE(s,'ź','z');
-- German
SET s = REPLACE(s,'ä','a');
SET s = REPLACE(s,'ö','o');
SET s = REPLACE(s,'ü','u');
SET s = REPLACE(s,'ß','ss');
-- French
SET s = REPLACE(s,'à','a');
SET s = REPLACE(s,'â','a');
SET s = REPLACE(s,'æ','ae');
SET s = REPLACE(s,'ç','c');
SET s = REPLACE(s,'è','e');
SET s = REPLACE(s,'é','e');
SET s = REPLACE(s,'ê','e');
SET s = REPLACE(s,'ë','e');
SET s = REPLACE(s,'î','i');
SET s = REPLACE(s,'ï','i');
SET s = REPLACE(s,'ô','o');
SET s = REPLACE(s,'ù','u');
SET s = REPLACE(s,'û','u');
SET s = REPLACE(s,'ü','u');
SET s = REPLACE(s,'ÿ','y');
-- Spanish / Portuguese
SET s = REPLACE(s,'á','a');
SET s = REPLACE(s,'í','i');
SET s = REPLACE(s,'ñ','n');
-- Scandinavian
SET s = REPLACE(s,'å','a');
SET s = REPLACE(s,'ø','o');
RETURN s;
END //
DELIMITER ;
DELIMITER $$
CREATE FUNCTION IF NOT EXISTS get_subcategories(startCategory INT)
RETURNS TEXT
DETERMINISTIC
BEGIN
DECLARE result TEXT;
-- Use GROUP_CONCAT to aggregate all IDs into a single string
WITH RECURSIVE subcategories AS (
SELECT c.id_category
FROM ps_category c
WHERE c.id_category = startCategory
UNION ALL
SELECT c.id_category
FROM ps_category c
INNER JOIN subcategories sc ON c.id_parent = sc.id_category
)
SELECT GROUP_CONCAT(id_category) INTO result
FROM subcategories;
RETURN result;
END$$
DELIMITER ;
-- +goose Down
DROP TABLE IF EXISTS b2b_countries;