This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new bb3a69ee1a Fixed: Error in ProductServicesScript.groovy]:(Cannot 
execute null+1) (OFBIZ-13079)
bb3a69ee1a is described below

commit bb3a69ee1a75befc28a6a46ca2568e7a75b46184
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Fri May 3 15:57:04 2024 +0200

    Fixed: Error in ProductServicesScript.groovy]:(Cannot execute null+1) 
(OFBIZ-13079)
    
    Fixes an error in countProductView service.
    
    There is still an error reproducible in 18.12 (summarised)
    
    Error running Groovy method ProductServicesScript::countProductView :
    org.apache.ofbiz.entity.GenericEntityException: Error while inserting:
    [GenericEntity:ProductCalculatedInfo](INSERT on table 
'PRODUCT_CALCULATED_INFO'
    caused a violation of foreign key constraint 'PRODCI_PROD' for key 
(GS-1000).
    The statement has been rolled back.
    
    So another Jira is needed.
---
 .../ofbiz/product/product/product/ProductServicesScript.groovy    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/product/ProductServicesScript.groovy
 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/product/ProductServicesScript.groovy
index a99534fb78..fac76d9bb0 100644
--- 
a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/product/ProductServicesScript.groovy
+++ 
b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/product/ProductServicesScript.groovy
@@ -18,18 +18,18 @@
 */
 package org.apache.ofbiz.product.product.product
 
+import java.sql.Timestamp
+
 import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.base.util.UtilProperties
 import org.apache.ofbiz.base.util.UtilValidate
-import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.condition.EntityConditionBuilder
 import org.apache.ofbiz.entity.serialize.XmlSerializer
 import org.apache.ofbiz.product.product.KeywordIndex
 import org.apache.ofbiz.product.product.ProductWorker
 import org.apache.ofbiz.service.ServiceUtil
 
-import java.sql.Timestamp
-
 /**
  * Create a Product
  */
@@ -369,7 +369,7 @@ Map countProductView() {
     long weight = parameters.weight ?: 1L
 
     GenericValue productCalculatedInfo = 
from('ProductCalculatedInfo').where(parameters).queryOne()
-    if (productCalculatedInfo) {
+    if (productCalculatedInfo?.totalTimesViewed) {
         productCalculatedInfo.totalTimesViewed += weight
         productCalculatedInfo.store()
     } else {

Reply via email to