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 2009/08/28 19:59:39 UTC

svn commit: r808972 - in /ofbiz/trunk/specialpurpose/ebay: data/EbayTypeData.xml servicedef/services.xml src/org/ofbiz/ebay/ProductsExportToEbay.java webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy webapp/ebay/find/productsExportToEbay.ftl

Author: jacopoc
Date: Fri Aug 28 17:59:39 2009
New Revision: 808972

URL: http://svn.apache.org/viewvc?rev=808972&view=rev
Log:
Enhancements to the way eBay categories are set:
* improved ui to better handle manual selection of the ebay category
* added support for automatic export of category based on the ProductCategory set (for eBay) for the product

Modified:
    ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml
    ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml
    ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
    ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy
    ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl

Modified: ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml?rev=808972&r1=808971&r2=808972&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/data/EbayTypeData.xml Fri Aug 28 17:59:39 2009
@@ -20,4 +20,5 @@
 
 <entity-engine-xml>
     <ProductPricePurpose productPricePurposeId="EBAY" description="eBay Auction"/>
+    <ProductCategoryType productCategoryTypeId="EBAY_CATEGORY" description="eBay" hasTable="N" parentTypeId=""/>
 </entity-engine-xml>

Modified: ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml?rev=808972&r1=808971&r2=808972&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/ebay/servicedef/services.xml Fri Aug 28 17:59:39 2009
@@ -31,7 +31,7 @@
         <attribute type="List" mode="IN" name="selectResult" optional="false"/>
         <attribute type="String" mode="IN" name="country" optional="false"/>
         <attribute type="String" mode="IN" name="location" optional="false"/>
-        <attribute type="String" mode="IN" name="ebayCategory" optional="false"/>
+        <attribute type="String" mode="IN" name="ebayCategory" optional="true"/>
         <attribute type="String" mode="IN" name="paymentPayPal" optional="true"/>
         <attribute type="String" mode="IN" name="paymentVisaMC" optional="true"/>
         <attribute type="String" mode="IN" name="paymentAmEx" optional="true"/>

Modified: ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java?rev=808972&r1=808971&r2=808972&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java (original)
+++ ofbiz/trunk/specialpurpose/ebay/src/org/ofbiz/ebay/ProductsExportToEbay.java Fri Aug 28 17:59:39 2009
@@ -226,21 +226,25 @@
                     setPaymentMethodAccepted(itemDocument, itemElem, context);
                     setMiscDetails(itemDocument, itemElem, context);
 
+                    String primaryCategoryId = "";
                     String categoryCode = (String)context.get("ebayCategory");
-                    String categoryParent = "";
-
                     if (categoryCode != null) {
                         String[] params = categoryCode.split("_");
 
                         if (params == null || params.length != 3) {
                             ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "productsExportToEbay.parametersNotCorrectInGetEbayCategories", locale));
                         } else {
-                            categoryParent = params[1];
+                            primaryCategoryId = params[1];
+                        }
+                    } else {
+                        GenericValue productCategoryValue = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("ProductCategoryAndMember", UtilMisc.toMap("productCategoryTypeId", "EBAY_CATEGORY", "productId", prod.getString("productId")))));
+                        if (UtilValidate.isNotEmpty(productCategoryValue)) {
+                            primaryCategoryId = productCategoryValue.getString("categoryName");
                         }
                     }
 
                     Element primaryCatElem = UtilXml.addChildElement(itemElem, "PrimaryCategory", itemDocument);
-                    UtilXml.addChildElementValue(primaryCatElem, "CategoryID", categoryParent, itemDocument);
+                    UtilXml.addChildElementValue(primaryCatElem, "CategoryID", primaryCategoryId, itemDocument);
 
                     Element startPriceElem = UtilXml.addChildElementValue(itemElem, "StartPrice", startPrice, itemDocument);
                     startPriceElem.setAttribute("currencyID", "USD");

Modified: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy?rev=808972&r1=808971&r2=808972&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy (original)
+++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/WEB-INF/actions/find/ProductsExportToEbay.groovy Fri Aug 28 17:59:39 2009
@@ -18,6 +18,7 @@
  */
 
 categoryCode = parameters.categoryCode;
+context.categoryCode = categoryCode; 
 userLogin = parameters.userLogin;
 
 results = dispatcher.runSync("getEbayCategories", [categoryCode : categoryCode, userLogin : userLogin]);
@@ -26,8 +27,13 @@
     context.categories = results.categories;
 }
 
-if (!categoryCode || !"Y".equals(categoryCode.substring(0, 1))) {
-    context.hideExportOptions = "Y";
+if (categoryCode) {
+    if (!"Y".equals(categoryCode.substring(0, 1)) && !"".equals(categoryCode)) {
+        context.hideExportOptions = "Y";
+    } else {
+        context.hideExportOptions = "N";
+    }
 } else {
     context.hideExportOptions = "N";
 }
+

Modified: ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl?rev=808972&r1=808971&r2=808972&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl (original)
+++ ofbiz/trunk/specialpurpose/ebay/webapp/ebay/find/productsExportToEbay.ftl Fri Aug 28 17:59:39 2009
@@ -17,14 +17,14 @@
 under the License.
 -->
 <script language="JavaScript" type="text/javascript">
-     function changeEbayCategory(categ, cat_desc) {
+     function changeEbayCategory(categ) {
          document.forms["ProductsExportToEbay"].action = "<@o...@ofbizUrl>";
          document.forms["ProductsExportToEbay"].submit();
      }
 
      function activateSubmitButton() {
          categ = document.forms["ProductsExportToEbay"].ebayCategory.value;
-         if (categ != null && categ.substring(0, 1) == 'Y') {
+         if (categ != null && (categ.substring(0, 1) == 'Y' || categ == '')) {
              document.forms["ProductsExportToEbay"].submitButton.disabled = false;
          } else {
              document.forms["ProductsExportToEbay"].submitButton.disabled = true;
@@ -40,10 +40,11 @@
                 <td>&nbsp;</td>
                 <td>
                     <input type="hidden" name="selectResult" value="${selectResult}"/>
-                    <select name="ebayCategory" onchange="changeEbayCategory(this.value, this.options[this.selectedIndex].text)">
+                    <select name="ebayCategory" onchange="changeEbayCategory(this.value)">
+                        <option value=""> </option>
                         <#if categories?exists>
                             <#list categories as category>
-                                <option value="${category.CategoryCode}">${category.CategoryName}</option>
+                                <option value="${category.CategoryCode}" <#if categoryCode?exists && categoryCode == category.CategoryCode>selected</#if>>${category.CategoryName}</option>
                             </#list>
                         </#if>
                     </select>