Error add Category



  • Can you help me ? error adding category

    81945538-b913-496f-8915-f7d0715cd61f-image.png



  • Hi @maullana,

    Just change the definer and import the below SQL,

    DELIMITER $$
    CREATE DEFINER=`root`@`localhost` FUNCTION `get_url_path_of_category`(
                    categoryId INT,
                    localeCode VARCHAR(255)
                ) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_unicode_ci
        DETERMINISTIC
    BEGIN
    
                    DECLARE urlPath VARCHAR(255);
    
                    IF NOT EXISTS (
                        SELECT id
                        FROM categories
                        WHERE
                            id = categoryId
                            AND parent_id IS NULL
                    )
                    THEN
                        SELECT
                            GROUP_CONCAT(parent_translations.slug SEPARATOR '/') INTO urlPath
                        FROM
                            categories AS node,
                            categories AS parent
                            JOIN category_translations AS parent_translations ON parent.id = parent_translations.category_id
                        WHERE
                            node._lft >= parent._lft
                            AND node._rgt <= parent._rgt
                            AND node.id = categoryId
                            AND node.parent_id IS NOT NULL
                            AND parent.parent_id IS NOT NULL
                            AND parent_translations.locale = localeCode
                        GROUP BY
                            node.id;
    
                        IF urlPath IS NULL
                        THEN
                            SET urlPath = (SELECT slug FROM category_translations WHERE category_translations.category_id = categoryId);
                        END IF;
                     ELSE
                        SET urlPath = '';
                     END IF;
    
                     RETURN urlPath;
                END$$
    DELIMITER ;
    


  • What will be the Definer for me, I am using windows 11 and xampp server.



  • Check your database credentials.


Log in to reply