diff --git a/README b/README new file mode 100644 index 0000000..18cdb3c --- /dev/null +++ b/README @@ -0,0 +1,38 @@ +Magento Python +************** + +Python library to connect Magento Webservices + +Check documentation source code + +Examples: + +from magento import * + +url = 'http://domain.com/' +apiuser = 'user' +apipass = 'password' + +"""Product""" +with Product(url, apiuser, apipass) as product_api: + ofilter = {'created_at':{'from':'2011-09-15 00:00:00'}} + products = product_api.list(ofilter) + +with ProductTypes(url, apiuser, apipass) as product_type_api: + product_type = product_type_api.list() + +with Product(url, apiuser, apipass) as product_api: + sku = 'prod1' + product = product_api.info(sku) + +"""Websites""" +with API(url, apiuser, apipass) as magento_api: + websites = magento_api.call('ol_websites.list', []) + store_group = magento_api.call('ol_groups.list', []) + store_views = magento_api.call('ol_storeviews.list', []) + +"""Order""" +with Order(url, apiuser, apipass) as order_api: + order_increment_id = '100000001 ' + status = 'canceled' + order_api.addcomment(order_increment_id, status) diff --git a/magento/__init__.py b/magento/__init__.py index 533ae23..5aab63c 100644 --- a/magento/__init__.py +++ b/magento/__init__.py @@ -14,7 +14,7 @@ 'Country', 'Region', 'Category', 'CategoryAttribute', 'Product', 'ProductAttribute', 'ProductAttributeSet', 'ProductTypes', 'ProductImages', - 'ProductTierPrice', 'ProductLinks', 'Inventory', + 'ProductTierPrice', 'ProductLinks', 'ProductConfigurable', 'Inventory', 'Order', 'Shipment', 'Invoice', ] @@ -24,5 +24,5 @@ from catalog import Category, CategoryAttribute from catalog import Product, ProductAttribute, ProductAttributeSet from catalog import ProductTypes, ProductImages, ProductTierPrice -from catalog import ProductLinks, Inventory +from catalog import ProductLinks, ProductConfigurable, Inventory from sales import Order, Shipment, Invoice diff --git a/magento/catalog.py b/magento/catalog.py index ff8749a..ca8a8ef 100644 --- a/magento/catalog.py +++ b/magento/catalog.py @@ -363,6 +363,15 @@ def list(self, attribute_set_id): """ return self.call('catalog_product_attribute.list', [attribute_set_id]) + def info(self, attribute): + """ + Retrieve product attribute info + + :param attribute: ID or Code of the attribute + :return: `list` of `dict` + """ + return self.call('ol_catalog_product_attribute.info', [attribute]) + def options(self, attribute, store_view=None): """ Retrieve product attribute options @@ -635,6 +644,49 @@ def attributes(self, link_type): """ return self.call('catalog_product_link.attributes', [link_type]) +class ProductConfigurable(API): + """ + Product Configurable API for magento + """ + __slots__ = ( ) + + def info(self, product): + """ + Configurable product Info + + :param product: ID or SKU of product + :return: List + """ + return self.call('ol_catalog_product_link.list', [product]) + + def getSuperAttributes(self, product): + """ + Configurable Attributes product + + :param product: ID or SKU of product + :return: List + """ + return self.call('ol_catalog_product_link.listSuperAttributes', [product]) + + def update(self, product, linked_products, attributes): + """ + Configurable Update product + + :param product: ID or SKU of product + :param linked_products: List ID or SKU of linked product to link + :param attributes: dicc + :return: True/False + """ + return bool(self.call('ol_catalog_product_link.assign', [product, linked_products, attributes])) + + def remove(self, product, linked_products): + """ + Remove a product link configurable + + :param product: ID or SKU of product + :param linked_products: List ID or SKU of linked product to unlink + """ + return bool(self.call('ol_catalog_product_link.remove', [product, linked_products])) class Inventory(API): """ diff --git a/magento/customer.py b/magento/customer.py index 0e36873..a7cd68a 100644 --- a/magento/customer.py +++ b/magento/customer.py @@ -36,7 +36,7 @@ def list(self, filters=None): Example: `{'firstname':{'ilike':'sharoon'}}` :return: List of dictionaries of matching records """ - return self.call('customer.list', filters and [filters] or []) + return self.call('customer.list', filters and [filters] or [{}]) def create(self, data): """