Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product Configurable and README #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions magento/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'Country', 'Region',
'Category', 'CategoryAttribute', 'Product', 'ProductAttribute',
'ProductAttributeSet', 'ProductTypes', 'ProductImages',
'ProductTierPrice', 'ProductLinks', 'Inventory',
'ProductTierPrice', 'ProductLinks', 'ProductConfigurable', 'Inventory',
'Order', 'Shipment', 'Invoice',
]

Expand All @@ -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
52 changes: 52 additions & 0 deletions magento/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion magento/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down