[
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 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 inContext = new HashMap();
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 productContentList =
EntityQuery.use(delegator).from("ProductContent").where("productId", productId,
"productContentTypeId",
productContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
if (UtilValidate.isEmpty(productContentList) &&
("Y"