Using this for fetching data from My Magento website. The catalog product API is working fine. It returns all the products. But when I try to fetch attribute using the following command it returns an empty list.
>>> magento = MagentoAPI("magentohost,com","80","**","**","/api/xmlrpc")
>>> products = magento.catalog_product.list()
>>> len(products)
3345
>>> attrs = magento.catalog_product_attribute.list()
>>> attrs
[]
I have lot of products attributes in my catalog. Why does it return empty then?
P.S: Is the JSON Magento API better than XML API ?
1 Answer 1
I am using Python xmlrpc to manage my magento store this two days, Very good but there are little document about python+xmlrpc. I do not use MagentoAPI or Other third-party lib, I am worry that the library do not update.
import timeit
import xmlrpclib
import datetime
from pyexcel_ods import get_data
import json
client = None
session = None
user = 'username'
password = 'password'
def setup():
global client, session
# your domain here
client = xmlrpclib.ServerProxy("http://www.magentohost.com.hk/index.php/api/xmlrpc?type=xmlrpc")
# your credentials here
session = client.login('username', 'password')
setup()
attribute_sets = client.call(session, 'catalog_product_attribute_set.list')
print attribute_sets
print "\n\n"
# show list all attribute of frist one set
attributes = client.call(session, 'catalog_product_attribute.list',[attribute_sets[0]['set_id']])
print attributes
This is my frist time to answer stackexchange question.