Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Error add Category

    General Discussion
    3
    4
    420
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      maullana last edited by

      Can you help me ? error adding category

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

      1 Reply Last reply Reply Quote 0
      • devansh-webkul
        devansh-webkul last edited by

        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 ;
        
        1 Reply Last reply Reply Quote 0
        • M
          manojbharti last edited by

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

          1 Reply Last reply Reply Quote 0
          • devansh-webkul
            devansh-webkul last edited by

            Check your database credentials.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post