ofbiz-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rishi Solanki (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (OFBIZ-7139) Product Name
Date Fri, 03 Jun 2016 11:34:59 GMT

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

Rishi Solanki edited comment on OFBIZ-7139 at 6/3/16 11:34 AM:
---------------------------------------------------------------

[~jacques.le.roux] [~pfm.smits]:

We have further look into the issue and found that ProductContentWrapper.getProductContentAsText()
line 173-205 is responsible for showing productName instead of Product Content of type Product
Name. You can see that after getting value from Product.productName it return from the method.
Ideally it should look for content first if found then return and if not found then go for
Product.productName.

I would say, add productName on edit product and fix this method will solve all purpose. If
no objection then we would provide patch for the same. Content will override the field value
in this case.

Here is code for quick reference;

{code}
        if (productModel.isField(candidateFieldName)) {
                String candidateValue = product.getString(candidateFieldName);
                if (UtilValidate.isNotEmpty(candidateValue)) {
                    outWriter.write(candidateValue);
                    return;
                } else if ("Y".equals(product.getString("isVariant"))) {
                    // look up the virtual product
                    GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
                    if (parent != null) {
                        candidateValue = parent.getString(candidateFieldName);
                        if (UtilValidate.isNotEmpty(candidateValue)) {
                            outWriter.write(candidateValue);
                            return;
                        }
                    }
                }
        }

        List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId",
productId, "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
        if (UtilValidate.isEmpty(productContentList) && ("Y".equals(product.getString("isVariant"))))
{
            GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
            if (UtilValidate.isNotEmpty(parent)) {
                productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId",
parent.get("productId"), "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
            }
        }
        GenericValue productContent = EntityUtil.getFirst(productContentList);
        if (productContent != null) {
            // when rendering the product content, always include the Product and ProductContent
records that this comes from
            Map<String, Object> inContext = new HashMap<String, Object>();
            inContext.put("product", product);
            inContext.put("productContent", productContent);
            ContentWorker.renderContentAsText(dispatcher, delegator, productContent.getString("contentId"),
outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
        }

{code}


was (Author: rishisolankii):
[~jacques.le.roux] [~pfm.smits]:

We have further look into the issue and found that ProductContentWrapper.getProductContentAsText()
line 173-205 is responsible for showing productName instead of Product Content of type Product
Name. You can see that after getting value from Product.productName it return from the method.
Ideally it should look for content first if found then return and if not found then go for
Product.productName.

I would say, add productName on edit product and fix this method will solve all purpose. If
no objection then we would provide patch for the same.

Here is code for quick reference;

{code}
        if (productModel.isField(candidateFieldName)) {
                String candidateValue = product.getString(candidateFieldName);
                if (UtilValidate.isNotEmpty(candidateValue)) {
                    outWriter.write(candidateValue);
                    return;
                } else if ("Y".equals(product.getString("isVariant"))) {
                    // look up the virtual product
                    GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
                    if (parent != null) {
                        candidateValue = parent.getString(candidateFieldName);
                        if (UtilValidate.isNotEmpty(candidateValue)) {
                            outWriter.write(candidateValue);
                            return;
                        }
                    }
                }
        }

        List<GenericValue> productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId",
productId, "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
        if (UtilValidate.isEmpty(productContentList) && ("Y".equals(product.getString("isVariant"))))
{
            GenericValue parent = ProductWorker.getParentProduct(productId, delegator);
            if (UtilValidate.isNotEmpty(parent)) {
                productContentList = EntityQuery.use(delegator).from("ProductContent").where("productId",
parent.get("productId"), "productContentTypeId", productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
            }
        }
        GenericValue productContent = EntityUtil.getFirst(productContentList);
        if (productContent != null) {
            // when rendering the product content, always include the Product and ProductContent
records that this comes from
            Map<String, Object> inContext = new HashMap<String, Object>();
            inContext.put("product", product);
            inContext.put("productContent", productContent);
            ContentWorker.renderContentAsText(dispatcher, delegator, productContent.getString("contentId"),
outWriter, inContext, locale, mimeTypeId, partyId, roleTypeId, cache);
        }

{code}

> Product Name
> ------------
>
>                 Key: OFBIZ-7139
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-7139
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: product
>    Affects Versions: Trunk
>            Reporter: Rishi Solanki
>            Assignee: Rishi Solanki
>            Priority: Minor
>
> As per the discussion over user list (subject: "Product Name"), user should be able to
add product name in product creation process.
> On Catalog >> Products >> New Product section, user won't see any input field
to add product name. Same applies to Edit product screen.
> - Add field on the create and edit form.
> - Check for the support in the services used, if not then add support for it.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message