ranjan1101 / magento-openerp-smile-synchro

Automatically exported from code.google.com/p/magento-openerp-smile-synchro
0 stars 0 forks source link

product synchronization fails (in multi-stores environment specifically) #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hey,
when i try to synchronize the products i get the following error. the first
product is created in magento, but i guess, when the script tries to update
the openerp table it dies with the following error message:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/tinyerp-server/netsvc.py", line
200, in _dispatch
    r=m(*params)
  File
"/usr/lib/python2.4/site-packages/tinyerp-server/service/web_services.py",
line 422, in execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File
"/usr/lib/python2.4/site-packages/tinyerp-server/service/web_services.py",
line 402, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File
"/usr/lib/python2.4/site-packages/tinyerp-server/wizard/__init__.py", line
160, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File
"/usr/lib/python2.4/site-packages/tinyerp-server/wizard/__init__.py", line
75, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File
"/usr/lib/python2.4/site-packages/tinyerp-server/addons/magento_openerp_smile/wi
zard/magento_product_synchronize.py",
line 127, in _do_export
KeyError: 'product_id'

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by gunter.k...@gmail.com on 25 Aug 2008 at 9:46

GoogleCodeExporter commented 9 years ago
Hi Gunter,
So far this log gives us little clue. 

First of all, can you please make sure you are running a version 0.95 or 0.9.6 
of the
connector? Are you on OpenERP4.2.2 and Magento 1.1 at least (Magento 1.3 or 
OpenERP
4.2.3 better)?
If not, are you sure you dropped all your databases before upgrading OpenERP, 
Magento
or the version of the connector?

Second, our logging line, line 127 of magento_product_synchronize.py was indeed 
not
correct, so we just corrected it on the SVN. Now it will at least report the 
error
better without raising such an exception. You can update on SVN or download the 
two
modified files here and restart the OpenERP server:
http://code.google.com/p/magento-openerp-smile-synchro/source/browse/magento_ope
nerp_smile/wizard/?r=52
 files are: magento_category_synchronize.py and magento_product_synchronize.py . We
will soon push a new corrected version.

Still, what you were reporting here is not the root of the problem but only a 
logging
artifact as I said. So, to find out the root of the problem, you have to 
understand
why Magento didn't create or update the product properly. What can help you 
here is
the PHP logging file of our connector you can generally find inside your
/var/www/magento/app/code/community/Smile_OpenERP_Synchro/ directory (update to 
your
Apache and Magento install).
Clear that file and reproduce the error, what is it written inside it? This 
should
give you clues about what is happening.

Thanks for the feedback, we will definitely help you to have it working 
properly and
you are already helping us improving the quality of the connector. How is it 
going now?

Raphaël Valyi.

Original comment by rva...@gmail.com on 26 Aug 2008 at 8:49

GoogleCodeExporter commented 9 years ago
hey Raphaël,
I'm working with openerp 4.2.2 and have started with the 0.95 version, now i 
have
upgraded to 0.96.
i haven't droped the database befor the upgrade to 0.96.  i will now try it 
with the
modified files, if i can get them out of your svn server. i will report you my
experiences.
bye, gunter

Original comment by gunter.k...@gmail.com on 26 Aug 2008 at 11:53

GoogleCodeExporter commented 9 years ago
Gunter, upgrading from 0.9.5 to 0.9.6 requires no database clean up unless you 
screw
it up specifically for some reason. 0.9.6 only adds easier categories export. 
That
should be independent from your problem. Still, I'm very curious about what is 
in the
PHP log (we will also think about passing back such Magento PHP error stacks 
back to
the OpenERP log in the future).

Raphaël

Original comment by rva...@gmail.com on 26 Aug 2008 at 12:19

GoogleCodeExporter commented 9 years ago
hey Raphaël,

here is the output of the magento side:

Mage says:
exception 'Mage_Core_Exception' with message 'Invalid website id requested.' in
/var/www/localhost/htdocs/magento/app/Mage.php:367
Stack trace:
#0 /var/www/localhost/htdocs/magento/app/code/core/Mage/Core/Model/App.php(664):
Mage::exception('Mage_Core', 'Invalid website...')
#1
/var/www/localhost/htdocs/magento/app/code/core/Mage/Catalog/Model/Product.php(2
42):
Mage_Core_Model_App->getWebsite('5')
#2
/var/www/localhost/htdocs/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/
Mysql4/Product.php(294):
Mage_Catalog_Model_Product->getStoreIds()
#3
/var/www/localhost/htdocs/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/
Mysql4/Product.php(245):
Mage_Catalog_Model_Resource_Eav_Mysql4_Prod\
uct->refreshEnabledIndex(NULL, Object(Mage_Catalog_Model_Product))
#4
/var/www/localhost/htdocs/magento/app/code/core/Mage/Catalog/Model/Resource/Eav/
Mysql4/Product.php(112):
Mage_Catalog_Model_Resource_Eav_Mysql4_Prod\
uct->refreshIndex(Object(Mage_Catalog_Model_Product))
#5
/var/www/localhost/htdocs/magento/app/code/core/Mage/Eav/Model/Entity/Abstract.p
hp(873):
Mage_Catalog_Model_Resource_Eav_Mysql4_Product->_afterSave(\
Object(Mage_Catalog_Model_Product))
#6 
/var/www/localhost/htdocs/magento/app/code/core/Mage/Core/Model/Abstract.php(235
):
Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Pr\
oduct))
#7
/var/www/localhost/htdocs/magento/app/code/community/Smile_OpenERP_Synchro/opene
rp-synchro.php(282):
Mage_Core_Model_Abstract->save()
#8 [internal function]: OpenERPConnector->product_sync(Array)
#9 [internal function]: ReflectionMethod->invokeArgs(Object(OpenERPConnector), 
Array)
#10
/var/www/localhost/htdocs/magento/lib/Zend/Server/Reflection/Function/Abstract.p
hp(366):
call_user_func_array(Array, Array)
#11 [internal function]:
Zend_Server_Reflection_Function_Abstract->__call('invokeArgs', Array)
#12 /var/www/localhost/htdocs/magento/lib/Zend/XmlRpc/Server.php(538):
Zend_Server_Reflection_Method->invokeArgs(Object(OpenERPConnector), Array)
#13 /var/www/localhost/htdocs/magento/lib/Zend/XmlRpc/Server.php(569):
Zend_XmlRpc_Server->_handle(Object(Zend_XmlRpc_Request_Http))
#14
/var/www/localhost/htdocs/magento/app/code/community/Smile_OpenERP_Synchro/opene
rp-synchro.php(384):
Zend_XmlRpc_Server->handle()
#15
/var/www/localhost/htdocs/magento/app/code/community/Smile_OpenERP_Synchro/opene
rp-synchro.php(372):
initRPCServer()
#16 {main}

Original comment by gunter.k...@gmail.com on 26 Aug 2008 at 12:30

GoogleCodeExporter commented 9 years ago
Hi Gunter,

so it looks like Magento fails to save the product on line 283 of the connector 
PHP
file here:
http://code.google.com/p/magento-openerp-smile-synchro/source/browse/magento_ope
nerp_smile/Magento_extension/Smile_OpenERP_Synchro/openerp-synchro.php

After the log, it looks like the website id we set to the product on line 252 
of that
file previously was not correct. Since the
$openerp_product['product_data']['websites'] key is not filled currently by the
Python part, the command we were doing was:
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getId()));

This usually works and always worked for us but doesn't seem to work in your 
case.
This is also the way it works in the regular Magento Product Controller, see for
instance around line 420 of this file (your equivalent):
/var/www/magento/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductControl
ler.php

Are you working in with mutiple Magento stores? Indeed the original Magento 
code is
exaclty:
        if (Mage::app()->isSingleStoreMode()) {
            $product->setWebsiteIds(array(Mage::app()->getStore(true)->getId()));
        }

And in our controller we don't do such a a test like
Mage::app()->isSingleStoreMode(). But may be we should.
Could you please replace the line 252 of your PHP file the 3 lines I just 
quoted?
(Don't forget the closing bracket at the end of line 252). Can your retry? Same 
error?

Alternatively, this might be something else, for some reason the web site id 
would be
incorrect. Could you eventually try to replace line 252 by:
$product->setWebsiteIds(array($my_hard_coded_id);}
and then try $my_hard_coded_id to set manually before the line from 1 let's say 
to
10, trying to export each time you try some new value?

So I think you need to discover why the website id is incorrect, trying in 
those two
directions. Please provide feedback. Can you also make sure you can add product
manually in the back office of Magento?

Hope this help, stay tuned and continue making updates about your advances 
please.

Raphaël.

Original comment by rva...@gmail.com on 26 Aug 2008 at 1:55

GoogleCodeExporter commented 9 years ago
hey Raphaël,
im working in a magento multistore environment. adding products in the magento
backoffice is no problem. i'll try your tips this evening and will report about 
the
result.
thanks, gunter

Original comment by gunter.k...@gmail.com on 26 Aug 2008 at 2:29

GoogleCodeExporter commented 9 years ago
hey Raphael,

after replacing the code to this it works.

if (Mage::app()->isSingleStoreMode()) {
   $product->setWebsiteIds(array(Mage::app()->getStore(true)->getId()));
}

thanks, gunter

thanks, gunter

Original comment by gunter.k...@gmail.com on 27 Aug 2008 at 2:59

GoogleCodeExporter commented 9 years ago
hey raphael,
the next problem is, that the products aren't visible in the magento backoffice
product grid. Now I'm searching for the missing data.
bye, gunter

Original comment by gunter.k...@gmail.com on 27 Aug 2008 at 3:35

GoogleCodeExporter commented 9 years ago
Hi Gunter,
My take is that you don't see the products in the backoffice because the product
website ids are missing since you changed that code. Indeed, we had such missing
trouble when the website id was not set or not set properly.

So I think we need to find out how we find what are the website ids array that 
should
be set to the products there. A good way to find out is to look at the regular
Magento product controller code that get hit when you manually add products in 
the
back office. May be we can give a hand to you to work out this issue. Send your
feedback and findings anyway and may be we could then Google chat to work this 
issue
more closely.

Tell us what is your commitment and confidence about fixing that multi-site 
trouble.
We are currently not focused on that issue at Smile, but I think the fix should 
be a
very simple thing and we are quite willing to work it out with you as you do 
have
such a multi-site real case. You could always speed up the whole thing buy 
buying
support from Smile.fr. But as I said, we will spend some time on the issue 
anyway
because we want to fix that one.

Regards,

Raphaël

Original comment by rva...@gmail.com on 27 Aug 2008 at 9:03

GoogleCodeExporter commented 9 years ago

Original comment by rva...@gmail.com on 27 Aug 2008 at 10:46

GoogleCodeExporter commented 9 years ago

Original comment by rva...@gmail.com on 27 Aug 2008 at 10:46

GoogleCodeExporter commented 9 years ago
Hey Raphaël,
at the end it was a configuration problem of the category, wich was the cause 
for the
invisibility of the product in the magento backend. 

I guess we are 100% comitted to the system. the basic syncronization of the 
products
and orders with your code  is working and that is a good basis. i will figure 
out all
existing problems next week and maybe we will buy support from you. at the 
moment i
have no budget, but this may change.

thanks for your support.

bye, gunter

Original comment by gunter.k...@gmail.com on 28 Aug 2008 at 11:45

GoogleCodeExporter commented 9 years ago
Hi Gunter,

nice to hear it looks OK for you so far. But please can you confirm which 
version is
working: does it require this piece of code to work?
if (Mage::app()->isSingleStoreMode()) {
   $product->setWebsiteIds(array(Mage::app()->getStore(true)->getId()));
}

I guess yes, but can you confirm so we commit the change? Regards,

Raphaël.

Original comment by rva...@gmail.com on 28 Aug 2008 at 3:59

GoogleCodeExporter commented 9 years ago
Hey Raphaël,
I'm using the 0.9.6 plus your code snippet:

if (Mage::app()->isSingleStoreMode()) {
   $product->setWebsiteIds(array(Mage::app()->getStore(true)->getId()));
}

gunter

Original comment by gunter.k...@gmail.com on 28 Aug 2008 at 4:03

GoogleCodeExporter commented 9 years ago
Hi there

This thread leads me to believe that you have made changes beyond 0.9.6, but 
they are
not checked in. Is this correct, and if so, when will they be checked in? I 
have made
some bug fixes myself and don't want to work on something thats old.

Original comment by nip...@gmail.com on 11 Sep 2008 at 2:08

GoogleCodeExporter commented 9 years ago
Hi all, this is supposed to be fixed in version 0.9.7 we just released. We 
completely
rewored the PHP code, dropping most of it and replacing it by native Magento
webservice who are supposed t be fine.

Original comment by rva...@gmail.com on 16 Sep 2008 at 10:21

GoogleCodeExporter commented 9 years ago

Original comment by rva...@gmail.com on 16 Sep 2008 at 10:21