Author: ashish
Date: Thu Aug 27 09:04:55 2009 New Revision: 808331 URL: http://svn.apache.org/viewvc?rev=808331&view=rev Log: Done following things on Google Base in this pass: 1) Added the priority tag so Product should be published in 15 - 30 minutes on Google Base instead of waiting for 24 hours. 2) Added ProductType default values - I have put a TODO in code and will work on that thing soon. The correct product type selection is very important - This helps to enlist product in the resultant list easily or we can say fast. 3) Batch tag was not being created right in the generated string. Fixed that issue. So the final sring looks like as shown below (Only for single product export): <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://purl.org/atom/app#" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:g="http://base.google.com/ns/1.0" xmlns:gm="http://base.google.com/ns-metadata/1.0" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"> <entry> <batch:operation type="insert"/> <app:control> <gm:publishing_priority>high</gm:publishing_priority> </app:control> <title>Round Gizmo</title> <content type="xhtml">Round Gizmo</content> <g:id>http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-2644</g:id> <link href="http://demo.ofbiz.org/ecommerce/control/product/~product_id=GZ-2644" rel="alternate" type="text/html"/> <g:item_type>products</g:item_type> <g:product_type>Electronics</g:product_type> <g:product_type>Business & Industrial</g:product_type> <g:price>38.40000000000</g:price> <g:currency>USD</g:currency> <g:target_country>US</g:target_country> <g:condition>new</g:condition> <g:image_link>http://demo.ofbiz.org/images/products/large/web_browser.png</g:image_link> </entry> </feed> Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Modified: ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java?rev=808331&r1=808330&r2=808331&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java (original) +++ ofbiz/trunk/specialpurpose/googlebase/src/org/ofbiz/googlebase/ProductsExportToGoogle.java Thu Aug 27 09:04:55 2009 @@ -60,6 +60,7 @@ private static final String resource = "GoogleBaseUiLabels"; private static final String module = ProductsExportToGoogle.class.getName(); private static final String googleBaseNSUrl = "http://base.google.com/ns/1.0"; + private static final String googleBaseBatchUrl = "http://schemas.google.com/gdata/batch"; private static final String googleBaseMetadataUrl = "http://base.google.com/ns-metadata/1.0"; private static final String googleBaseAppUrl = "http://purl.org/atom/app#"; @@ -416,12 +417,18 @@ itemActionType = "insert"; } Element entryElem = UtilXml.addChildElement(feedElem, "entry", feedDocument); - Element batchElem = UtilXml.addChildElement(entryElem, "batch:operation", feedDocument); - batchElem.setAttribute("type", itemActionType); + Element batchElem = UtilXml.addChildElementNSElement(entryElem, "batch:operation", feedDocument, googleBaseBatchUrl); + Element batchOperationElem = UtilXml.firstChildElement(batchElem, "batch:operation"); + batchOperationElem.setAttribute("type", itemActionType); + + Element appControlElem = UtilXml.addChildElementNSElement(entryElem, "app:control", feedDocument, googleBaseAppUrl); + Element appControlChildElem = UtilXml.firstChildElement(appControlElem, "app:control"); + // Add the publishing priority for the product. By default it takes about 24 hours to publish your product if you submit data from Data Feed. By adding publishing priority your data + // can be published in 15 - 30 minutes. + UtilXml.addChildElementNSValue(appControlChildElem, "gm:publishing_priority", "high", feedDocument, googleBaseMetadataUrl); // status is draft or deactivate if (statusId != null && ("draft".equals(statusId) || "deactivate".equals(statusId))) { - Element appControlElem = UtilXml.addChildElementNSElement(entryElem, "app:control", feedDocument, googleBaseAppUrl); UtilXml.addChildElementNSValue(appControlElem, "app:draft", "yes", feedDocument, googleBaseAppUrl); // status is deactivate @@ -445,8 +452,16 @@ linkElem.setAttribute("rel", "alternate"); linkElem.setAttribute("type", "text/html"); linkElem.setAttribute("href", link); - + + // item_type is the categories in which your product should belong. UtilXml.addChildElementNSValue(entryElem, "g:item_type", "products", feedDocument, googleBaseNSUrl); + + // adding the default values for products types. + // TODO: Figure out how best we can use the product_type along with OOTB ProductType associated with Product. + // Google base support big list of product type and here is the link (Refer title "Browse the taxonomy"): http://base.google.com/support/bin/answer.py?hl=en&answer=66818 + UtilXml.addChildElementNSValue(entryElem, "g:product_type", "Electronics", feedDocument, googleBaseNSUrl); + UtilXml.addChildElementNSValue(entryElem, "g:product_type", "Business & Industrial", feedDocument, googleBaseNSUrl); + UtilXml.addChildElementNSValue(entryElem, "g:price", price, feedDocument, googleBaseNSUrl); // Might be nicer to load this from the product but for now we'll set it based on the country destination |
Free forum by Nabble | Edit this page |