Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-12359

ProductFacility on ecommerce listing product issue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Trunk, 17.12.08, 18.12.01, 22.01.01, Upcoming Branch
    • 18.12.06, 22.01.01
    • ecommerce, product/catalog
    • OS: Linux/Ubuntu 18.04 LTS

      Java 8

      Apache OFBiz r17.12.06

      Also affects older versions like r.13.07.03

    Description

      Possible issue in the ecommerce listing of products related to the ProductFacility entity and the filtering of out of stock products.
       
      Here's the context:

      • an ecommerce site where products are configured as a virtual-variant relationship.
      • a virtual product (parent) has color and size features associated as selectable, and its variants are all the combinations of colors and sizes.
      • in such a configuration InventoryItem records are registered for variant products (the actual sold products) and not for virtual products.
      • the product store is configured to not show out of stock products.
      • a record of ProductFacility is created for each product variant where its lastInventoryCount is automatically updated as soon as availability are imported/created (through PHYSICAL INVENTORY);
      • virtual products are associated to some ProductCategories;
         
        Issue:
        Products are not shown in listing also if they have stock availability.
         
        Issue details:
        Listing of products is done through the screen "CatalogScreens.xml#categorydetail" and the CategoryDetail.groovy script is used to retrieve the list of products to show.
         
        In the groovy script the service responsible to get the product category members to show is getProductCategoryAndLimitedMembers, which checks and filters out of stock products (if ProductStore is configured to do so).
         
        Filtering out of stock products is done using ProductWorker.java#filterOutOfStockProducts method, that sums up all the lastInventoryCount (in all the facilities) of each category member and if sum is GT 0 the (virtual) product is kept and shown in listing.
         
        The lastInventoryCount field in the table ProductFacility is updated through the eeca service setLastInventoryCount on create/update on entity InventoryItemDetail.
        This service works only on the product on which a stock move is committed (in my case a specific product variant): it's (virtual) parent is never considered.
         
        That behaviour, in addition to the fact that filterOutOfStock method works on the category members that are the virtual parents, leads to products to not be shown in listing also if they have stock availability.
         
        Possible solutions:
        From my point of view there are two ways to fix this.
         
        1) add the handling of lastInventoryCount on virtual parents to the service setLastInventoryCount; the lastInventoryCount of the parent should be the sum of all its variant in the same facility, and each time a variant is modified, the related parent should be modified too.
         
        2) add the handling of virtual products in the ProductWorker.java#filterOutOfStockProducts: here when a vritual product category member is processed, all its variant should be retrieved and their lastInventoryCount added up through all (store enabled) facilities.
        Only if the sum of all the variants in all the facilities is GT 0, then we can keep and show the virtual product.
         
        Considerations:
        After a bit of research within whole OFBiz project (R17.12.06) the lastInventoryCount field has a quite limited direct usage (basically only for ecommerce scopes).
        I think solution 2) is better, because I think that the ProductFacility entity should not contain record for "virtual" products (products that physically won't be sold, since you will sell a variant of it; for the same reason virtual products should not have InventoryItem records associated).
         
        I think that solution 1) instead is not so clean and force to adopt inventory item concepts also for virtual products, that in my opinion it does not make too much sense.

      Attachments

        Activity

          People

            Giulio_MpStyle Giulio Speri
            Giulio_MpStyle Giulio Speri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: