You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/08/01 22:43:39 UTC
svn commit: r561942 - in /ofbiz/trunk/applications:
order/config/OrderUiLabels.properties
order/config/OrderUiLabels_it.properties
order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
product/src/org/ofbiz/product/product/ProductsExportToEbay.java
Author: jacopoc
Date: Wed Aug 1 13:43:31 2007
New Revision: 561942
URL: http://svn.apache.org/viewvc?view=rev&rev=561942
Log:
Applied patch by Marco Risaliti (OFBIZ-1159) with misc improvements for the integration with eBay.
Modified:
ofbiz/trunk/applications/order/config/OrderUiLabels.properties
ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java
Modified: ofbiz/trunk/applications/order/config/OrderUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels.properties?view=diff&rev=561942&r1=561941&r2=561942
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels.properties Wed Aug 1 13:43:31 2007
@@ -1001,6 +1001,7 @@
ordersImportFromEbay.noOrdersFound=No Orders Found
ordersImportFromEbay.orderIdOrExternalIdAreMandatory=OrderId Or ExternalId Are Mandatory
ordersImportFromEbay.paymentIsStillNotReceived=Before Import the order from eBay you have to receive the payment from the buyer
+ordersImportFromEbay.productIdDoesNotExist=ProductId Does Not Exist
ordersImportFromEbay.productIdNotAvailable=ProductId Not Available
ordersImportFromEbay.productStoreIdIsMandatory=ProductStoreId Is Mandatory
Modified: ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties?view=diff&rev=561942&r1=561941&r2=561942
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties (original)
+++ ofbiz/trunk/applications/order/config/OrderUiLabels_it.properties Wed Aug 1 13:43:31 2007
@@ -864,6 +864,7 @@
ordersImportFromEbay.noOrdersFound=Nessun Ordine Trovato
ordersImportFromEbay.orderIdOrExternalIdAreMandatory=OrderId O ExternalId Sono Obbligatori
ordersImportFromEbay.paymentIsStillNotReceived=Prima di Importare l'ordine da eBay tu devi ricevere il pagamento dal compratore
+ordersImportFromEbay.productIdDoesNotExist=Codice Prodotto Non Esiste
ordersImportFromEbay.productIdNotAvailable=Codice Prodotto Non Disponibile
ordersImportFromEbay.productStoreIdIsMandatory=Codice Negozio \u00e8 Obbligatorio
@@ -991,4 +992,4 @@
FormFieldTitle_completeStatus=Pagamento Inviato dal Compratore
FormFieldTitle_buyerName=Nome Compratore
FormFieldTitle_emailBuyer=Email Compratore
-FormFieldTitle_productName=Nome Prodotto
\ No newline at end of file
+FormFieldTitle_productName=Nome Prodotto
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java?view=diff&rev=561942&r1=561941&r2=561942
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/ImportOrdersFromEbay.java Wed Aug 1 13:43:31 2007
@@ -570,10 +570,15 @@
itemId = UtilXml.childElementValue(itemElement, "ItemID", "");
order.put("paymentMethods", UtilXml.childElementValue(itemElement, "PaymentMethods", ""));
order.put("quantity", UtilXml.childElementValue(itemElement, "Quantity", "0"));
- order.put("productId", UtilXml.childElementValue(itemElement, "SKU", ""));
order.put("startPrice", UtilXml.childElementValue(itemElement, "StartPrice", "0"));
order.put("title", UtilXml.childElementValue(itemElement, "Title", ""));
+ String productId = UtilXml.childElementValue(itemElement, "SKU", "");
+ if (UtilValidate.isEmpty(productId)) {
+ productId = retrieveProductIdFromTitle(delegator, (String)order.get("title"));
+ }
+ order.put("productId", productId);
+
// retrieve selling status
List sellingStatus = UtilXml.childElementList(itemElement, "SellingStatus");
Iterator sellingStatusitemElemIter = sellingStatus.iterator();
@@ -759,11 +764,16 @@
// create the shipment group item
cart.addItemGroup("00001", null);
- // create the order item
+ // check if the producId exists and it is valid
String productId = (String) parameters.get("productId");
if (UtilValidate.isEmpty(productId)) {
return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdNotAvailable", locale));
- }
+ } else {
+ GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
+ if (UtilValidate.isEmpty(product)) {
+ return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdDoesNotExist", locale));
+ }
+ }
// Before import the order from eBay to OFBiz is mandatory that the payment has be received
String paidTime = (String) parameters.get("paidTime");
@@ -1167,7 +1177,7 @@
String partyId = "_NA_";
String shipmentMethodTypeId = "NO_SHIPPING";
- if (shippingService != null) {
+ /* if (shippingService != null) {
if ("USPSPriority".equals(shippingService)) {
partyId = "USPS";
shipmentMethodTypeId = "PRIORITY";
@@ -1202,7 +1212,7 @@
partyId = "_NA_";
shipmentMethodTypeId = "PICK_UP";
}
- }
+ } */
cart.setCarrierPartyId(partyId);
cart.setShipmentMethodTypeId(shipmentMethodTypeId);
@@ -1301,5 +1311,19 @@
// none of the existing contact mechs/email addresses match (or none were found). Create a new one and return the related contact mech id.
Debug.logInfo("Unable to find matching postal address for partyId " + partyId + ". Creating a new one.", module);
return createPartyPhone(dispatcher, partyId, (String) parameters.get("shippingAddressPhone"), userLogin);
- }
+ }
+
+ private static String retrieveProductIdFromTitle(GenericDelegator delegator, String title) {
+ String productId = "";
+
+ try {
+ List product = delegator.findByAnd("Product", UtilMisc.toMap("internalName", title));
+ if (UtilValidate.isNotEmpty(product) && product.size() == 1) {
+ productId = (String) ((GenericValue)product.get(0)).get("productId");
+ }
+ } catch (GenericEntityException e) {
+ productId = "";
+ }
+ return productId;
+ }
}
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java?view=diff&rev=561942&r1=561941&r2=561942
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductsExportToEbay.java Wed Aug 1 13:43:31 2007
@@ -89,10 +89,7 @@
if (!ServiceUtil.isFailure(buildDataItemsXml(dctx, context, dataItemsXml, token))) {
Map result = postItem(xmlGatewayUri, dataItemsXml, devID, appID, certID, "AddItem", compatibilityLevel, siteID);
if (ServiceUtil.isFailure(result)) {
- return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(result));
- } else {
- Debug.logError("Error during authentication to eBay Account", module);
- return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.errorDuringAuthenticationToEbay", locale));
+ return ServiceUtil.returnFailure(ServiceUtil.getErrorMessage(result));
}
}
} catch (Exception e) {
@@ -184,8 +181,8 @@
Iterator productsListItr = productsList.iterator();
while(productsListItr.hasNext()) {
GenericValue prod = (GenericValue)productsListItr.next();
- String title = parseText(prod.getString("productName"));
- String description = parseText(prod.getString("description"));
+ String title = parseText(prod.getString("internalName"));
+ String description = parseText(prod.getString("internalName"));
Element itemElem = UtilXml.addChildElement(itemRequestElem, "Item", itemDocument);
UtilXml.addChildElementValue(itemElem, "Country", (String)context.get("country"), itemDocument);
@@ -343,4 +340,4 @@
}
return text;
}
-}
\ No newline at end of file
+}