← Back to team overview

openerp-connector-community team mailing list archive

my patch to Catalog/Api.php to import product categories, but you may know a better way

 

 

Greetings to those in this forum. This is my first post.
I am impressed by the new job model in 7.0. Very nice. 

My first product category import took some extra coaxing. 

At first I consistently had xml responses like this: 

<methodResponse><fault><value><struct><member><name>faultCode</name><value><int>1</int></value></member><member><name>faultString</name><value><string>Internal
Error. Please see log for
details.</string></value></member></struct></value></fault></methodResponse>


To xml requests like this: 

<methodCall>
<methodName>call</methodName>
<params>
<param>
<value><string>6f1ba3c8071c9ea351b5e2f0ab52bbf8</string></value>
</param>
<param>
<value><string>catalog_category.tree</string></value>
</param>
<param>
<value><array><data>
<value><nil/></value><value><nil/></value></data></array></value>
</param>
</params>
</methodCall> 

With find and grep, I located: 

openerp-connector-magento/magentoerpconnect/product_category.py
class ProductCategoryAdapter
def tree 

Then I found, on the Magento side, giving gratitude to
http://alanstorm.com/debugging_magento_api_method_calls 

app/code/core/Mage/Catalog/Model/Category/Api.php
class Mage_Catalog_Model_Category_Api
public function tree($parentId = null, $store = null) 

Then my really sophisticated technique was to stick in lots of
fopen/fprint/fclose until I saw what was going on. So I ended up adding
these two lines to the top of the the tree() function: 

 {
 if($parentId == '') $parentId = null;
 if($store == '') $store = null; 

And I requeued the OpenERP Connector job and it finished, and then the
products imported fine also. Excellent. 

I felt a duty in a way to share what I did with this list, so I joined,
and I am also hereby placing myself open to suggestions.... 

Really, my whole team and I sincerely appreciate the master
craftsmanship of this entire team, so thank you. 
 

Follow ups