Giulio Speri created OFBIZ-12359:
------------------------------------
Summary: ProductFacility on ecommerce listing product issue
Key: OFBIZ-12359
URL: https://issues.apache.org/jira/browse/OFBIZ-12359
Project: OFBiz
Issue Type: Bug
Components: ecommerce, product/catalog
Affects Versions: 18.12.01, 17.12.08, Trunk
Environment: OS: Linux/Ubuntu 18.04 LTS
Java 8
Apache OFBiz r17.12.06
Also affects older versions like r.13.07.03
Reporter: Giulio Speri
Assignee: Giulio Speri
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 facilities.
Only is 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)