[jira] Created: (OFBIZ-1217) mis-committed code in productdetail.bsh?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (OFBIZ-1217) mis-committed code in productdetail.bsh?

Nicolas Malin (Jira)
mis-committed code in productdetail.bsh?
----------------------------------------

                 Key: OFBIZ-1217
                 URL: https://issues.apache.org/jira/browse/OFBIZ-1217
             Project: OFBiz
          Issue Type: Bug
          Components: order
            Reporter: Si Chen
            Priority: Minor


I just noticed this in productdetail.bsh which looked suspicious:

1.  Why is SYMPTOM hardcoded?
2.  Why does this block not use getAssociatedProducts like the section above it?

Does anybody need this code?  If not can I remove it and clean this up?

    // get other cross-sell information: product with a common feature
    commonProductFeatureId = "SYMPTOM";
    // does this product have that feature?
    commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", commonProductFeatureId), UtilMisc.toList("sequenceNum", "defaultSequenceNum"));
    if (commonProductFeatureAndAppls.size() > 0) {
        commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(commonProductFeatureAndAppls, "productFeatureId", true);
       
        // now search for other products that have this feature
        visitId = VisitHandler.getVisitId(session);
       
        productSearchConstraintList = new LinkedList();
        productSearchConstraintList.add(new ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
        // make sure the view allow category is included
        productSearchConstraintList = ProductSearchSession.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator);

        // don't care about the sort on this one
        resultSortOrder = null;

        commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
        commonFeatureResultIds = new LinkedList();
        commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator();
        while (commonFeatureResultIdIter.hasNext()) {
            commonFeatureResultId = commonFeatureResultIdIter.next();
            // filter out the current product
            if (commonFeatureResultId.equals(productId)) {
                continue;
            }
            // filter out all variants
            commonProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", commonFeatureResultId));
            if (commonProduct == null || ("Y".equals(commonProduct.getString("isVariant")))) {
                continue;
            }
            commonFeatureResultIds.add(commonFeatureResultId);
        }
        if (commonFeatureResultIds.size() > 0) {
            context.put("commonFeatureResultIds", commonFeatureResultIds);
        }
    }


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1217) mis-committed code in productdetail.bsh?

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-1217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523413 ]

David E. Jones commented on OFBIZ-1217:
---------------------------------------

Have you looked up when this was committed?

I'm not sure, but my foggy memory tells me this is really old code (like years ago) and was meant to be an example of this stuff.

> mis-committed code in productdetail.bsh?
> ----------------------------------------
>
>                 Key: OFBIZ-1217
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1217
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>            Reporter: Si Chen
>            Priority: Minor
>
> I just noticed this in productdetail.bsh which looked suspicious:
> 1.  Why is SYMPTOM hardcoded?
> 2.  Why does this block not use getAssociatedProducts like the section above it?
> Does anybody need this code?  If not can I remove it and clean this up?
>     // get other cross-sell information: product with a common feature
>     commonProductFeatureId = "SYMPTOM";
>     // does this product have that feature?
>     commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", commonProductFeatureId), UtilMisc.toList("sequenceNum", "defaultSequenceNum"));
>     if (commonProductFeatureAndAppls.size() > 0) {
>         commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(commonProductFeatureAndAppls, "productFeatureId", true);
>        
>         // now search for other products that have this feature
>         visitId = VisitHandler.getVisitId(session);
>        
>         productSearchConstraintList = new LinkedList();
>         productSearchConstraintList.add(new ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>         // make sure the view allow category is included
>         productSearchConstraintList = ProductSearchSession.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator);
>         // don't care about the sort on this one
>         resultSortOrder = null;
>         commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
>         commonFeatureResultIds = new LinkedList();
>         commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator();
>         while (commonFeatureResultIdIter.hasNext()) {
>             commonFeatureResultId = commonFeatureResultIdIter.next();
>             // filter out the current product
>             if (commonFeatureResultId.equals(productId)) {
>                 continue;
>             }
>             // filter out all variants
>             commonProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", commonFeatureResultId));
>             if (commonProduct == null || ("Y".equals(commonProduct.getString("isVariant")))) {
>                 continue;
>             }
>             commonFeatureResultIds.add(commonFeatureResultId);
>         }
>         if (commonFeatureResultIds.size() > 0) {
>             context.put("commonFeatureResultIds", commonFeatureResultIds);
>         }
>     }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (OFBIZ-1217) mis-committed code in productdetail.bsh?

Nicolas Malin (Jira)
In reply to this post by Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-1217?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12523418 ]

Si Chen commented on OFBIZ-1217:
--------------------------------

Do we still need it?

> mis-committed code in productdetail.bsh?
> ----------------------------------------
>
>                 Key: OFBIZ-1217
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1217
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>            Reporter: Si Chen
>            Priority: Minor
>
> I just noticed this in productdetail.bsh which looked suspicious:
> 1.  Why is SYMPTOM hardcoded?
> 2.  Why does this block not use getAssociatedProducts like the section above it?
> Does anybody need this code?  If not can I remove it and clean this up?
>     // get other cross-sell information: product with a common feature
>     commonProductFeatureId = "SYMPTOM";
>     // does this product have that feature?
>     commonProductFeatureAndAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", commonProductFeatureId), UtilMisc.toList("sequenceNum", "defaultSequenceNum"));
>     if (commonProductFeatureAndAppls.size() > 0) {
>         commonProductFeatureIds = EntityUtil.getFieldListFromEntityList(commonProductFeatureAndAppls, "productFeatureId", true);
>        
>         // now search for other products that have this feature
>         visitId = VisitHandler.getVisitId(session);
>        
>         productSearchConstraintList = new LinkedList();
>         productSearchConstraintList.add(new ProductSearch.FeatureSetConstraint(commonProductFeatureIds));
>         // make sure the view allow category is included
>         productSearchConstraintList = ProductSearchSession.ensureViewAllowConstraint(productSearchConstraintList, currentCatalogId, delegator);
>         // don't care about the sort on this one
>         resultSortOrder = null;
>         commonFeatureResultIdsOrig = ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
>         commonFeatureResultIds = new LinkedList();
>         commonFeatureResultIdIter = commonFeatureResultIdsOrig.iterator();
>         while (commonFeatureResultIdIter.hasNext()) {
>             commonFeatureResultId = commonFeatureResultIdIter.next();
>             // filter out the current product
>             if (commonFeatureResultId.equals(productId)) {
>                 continue;
>             }
>             // filter out all variants
>             commonProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", commonFeatureResultId));
>             if (commonProduct == null || ("Y".equals(commonProduct.getString("isVariant")))) {
>                 continue;
>             }
>             commonFeatureResultIds.add(commonFeatureResultId);
>         }
>         if (commonFeatureResultIds.size() > 0) {
>             context.put("commonFeatureResultIds", commonFeatureResultIds);
>         }
>     }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.