OFBiz
  1. OFBiz
  2. OFBIZ-3563

Creating a category with an ID (manually or automatically) that matches an existing productID will show the unrelated product when enter into the category on the 'Browse category' of the Ecommerce application.

    Details

    • Sprint:
      Bug Crush Event - 21/2/2015

      Description

      Steps to reproduce it:

      • Create a new category and set the ID manually that corresponds with an existing productID.
      • Go to the Ecommerce app and enter in the category has been created.
      • The product with the same ID will be show but it isn't really related to this category.

      As Jacques noted on the ML, it could be related to an URL improvement (SEO)

        Issue Links

          Activity

          Hide
          Jacques Le Roux added a comment -

          Thanks!

          Show
          Jacques Le Roux added a comment - Thanks!
          Hide
          Deepak Dixit added a comment -

          Changes has been backported to R13.07 at r#1668198 and R12.04 at r#1668199

          Show
          Deepak Dixit added a comment - Changes has been backported to R13.07 at r#1668198 and R12.04 at r#1668199
          Hide
          Jacques Le Roux added a comment -

          Also R12.04 is not yet fixed. Don't forget to report in OFBIZ-2361 when fixed, thanks!

          Show
          Jacques Le Roux added a comment - Also R12.04 is not yet fixed. Don't forget to report in OFBIZ-2361 when fixed, thanks!
          Hide
          Pranay Pandey added a comment -

          Thanks for the patch Divesh.

          I have committed it to trunk revision 1652624 and branch 14.12 revision 1652625.

          As EntityQuery support is not available in release13.07 need to create a separate patch for the same.

          Show
          Pranay Pandey added a comment - Thanks for the patch Divesh. I have committed it to trunk revision 1652624 and branch 14.12 revision 1652625. As EntityQuery support is not available in release13.07 need to create a separate patch for the same.
          Hide
          Divesh Dutta added a comment -

          Algorithm snippet of doGet method of CatalogUrlServlet.java where modification is done.

          Current algorithm:
          ...
          ...
          Check: Is last path element starts with 'p_'
          Yes?-
          set ProductId after removing prepended 'p_'
          So, that it will be directed to Product Detail page.
          No?-
          Check: Do we have any product with productId = pathElement
          yes?- set productId. So, that it will be redirected to Product detail page.
          ...
          ...

          So, if we have a categoryId same as productId then it don't check for category it first sets productId.

          Algorithm used to fix the issue:

          As per Scott's first solution:

          ...
          ...
          Check: Is last path element starts with 'p_' ?
          Yes?-
          set ProductId after removing prepended 'p_'
          So, that it will be directed to Product Detail page.
          No?-
          Check: Do we have any category with categoryId = pathElement
          yes?- set categoryId. So, that it will be redirected to Category detail page. Product List will be shown on Category detail page.

          Show
          Divesh Dutta added a comment - Algorithm snippet of doGet method of CatalogUrlServlet.java where modification is done. Current algorithm: ... ... Check: Is last path element starts with 'p_' Yes?- set ProductId after removing prepended 'p_' So, that it will be directed to Product Detail page. No?- Check: Do we have any product with productId = pathElement yes?- set productId. So, that it will be redirected to Product detail page. ... ... So, if we have a categoryId same as productId then it don't check for category it first sets productId. Algorithm used to fix the issue: As per Scott's first solution: ... ... Check: Is last path element starts with 'p_' ? Yes?- set ProductId after removing prepended 'p_' So, that it will be directed to Product Detail page. No?- Check: Do we have any category with categoryId = pathElement yes?- set categoryId. So, that it will be redirected to Category detail page. Product List will be shown on Category detail page.
          Hide
          Divesh Dutta added a comment -

          Attaching the patch to fix this issue. Solution is designed as per the first solution given by Scott.

          Tested the patch and its working as expected.

          Though in latest trunk catalog url servlet may not be used to prepare URL of products and categories. In latest trunk content management of OFBiz is used to prepare URLs .

          Show
          Divesh Dutta added a comment - Attaching the patch to fix this issue. Solution is designed as per the first solution given by Scott. Tested the patch and its working as expected. Though in latest trunk catalog url servlet may not be used to prepare URL of products and categories. In latest trunk content management of OFBiz is used to prepare URLs .
          Hide
          Jacques Le Roux added a comment -

          Of course I prefer the second solution

          Show
          Jacques Le Roux added a comment - Of course I prefer the second solution
          Hide
          Scott Gray added a comment -

          product ids are always prepended with a p_ when generated by the servlet so I'm not sure why the it is treating the last path element as a possible product id when p_ is missing from it.

          We should be able to fix this easily enough by always treating the last path element as a category id if it isn't prepended with p_ (let's hope no one ever creates a category starting with p_). If p_ is missing and the id doesn't resolve to a category then we could allow it through as a product id.

          An alternative solution could be to have two mount points for the servlet: products for products and categories for categories, that way there will never be any ambiguity.
          Examples:
          http://domain/ecommerce/products/productId
          http://domain/ecommerce/categories/categoryId

          For backwards SEO compatibility we could redirect any /products/categoryId urls to the new categories url.

          Show
          Scott Gray added a comment - product ids are always prepended with a p_ when generated by the servlet so I'm not sure why the it is treating the last path element as a possible product id when p_ is missing from it. We should be able to fix this easily enough by always treating the last path element as a category id if it isn't prepended with p_ (let's hope no one ever creates a category starting with p_). If p_ is missing and the id doesn't resolve to a category then we could allow it through as a product id. An alternative solution could be to have two mount points for the servlet: products for products and categories for categories, that way there will never be any ambiguity. Examples: http://domain/ecommerce/products/productId http://domain/ecommerce/categories/categoryId For backwards SEO compatibility we could redirect any /products/categoryId urls to the new categories url.

            People

            • Assignee:
              Deepak Dixit
              Reporter:
              Jonatan Soto
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development

                  Agile