Skip to content

Commit eb68982

Browse files
author
Priyanka Rani
committed
Store View API and Magento API #1736
This patch has extended magento api to return information about store views and current magento installation. Task ID: project-1735/task-1736 Review ID: 196001
1 parent 6be59e2 commit eb68982

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

README.rst

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ Usage
3939
status = 'canceled'
4040
order_api.addcomment(order_increment_id, status)
4141
42+
with magento.Store(url, apiuser, apipass) as store_api:
43+
store_id = '1'
44+
store_view_info = store_api.info(store_id)
45+
store_views = store_api.list()
46+
47+
with magento.Magento(url, apiuser, apipass) as magento_api:
48+
magento_info = magento_api.info()
49+
4250
4351
License
4452
-------

magento/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:license: AGPLv3, see LICENSE for more details
88
'''
99
__all__ = [
10-
'API',
10+
'API', 'Store', 'Magento',
1111
'Customer', 'CustomerGroup', 'CustomerAddress',
1212
'Country', 'Region',
1313
'Category', 'CategoryAttribute', 'Product', 'ProductAttribute',
@@ -17,6 +17,7 @@
1717
]
1818

1919
from .api import API
20+
from .miscellaneous import Store, Magento
2021
from .customer import Customer, CustomerGroup, CustomerAddress
2122
from .directory import Country, Region
2223
from .catalog import Category, CategoryAttribute

magento/miscellaneous.py

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
miscellaneous
4+
5+
This API allows to access additional magento information
6+
7+
:copyright: (c) 2013 by Openlabs Technologies & Consulting (P) Limited
8+
:license: AGPLv3, see LICENSE for more details.
9+
"""
10+
from magento.api import API
11+
12+
13+
class Store(API):
14+
"""
15+
This API allows to retrieve information about store views
16+
"""
17+
18+
__slots__ = ()
19+
20+
def info(self, store_id):
21+
"""
22+
Returns information for store view
23+
24+
:param store_id: ID of store view
25+
:return: Dictionary containing information about store view
26+
"""
27+
return self.call('store.info', [store_id])
28+
29+
def list(self, filters=None):
30+
"""
31+
Returns list of store views
32+
33+
:param filters: Dictionary of filters.
34+
35+
Format :
36+
{<attribute>:{<operator>:<value>}}
37+
Example :
38+
{'store_id':{'=':'1'}}
39+
:return: List of Dictionaries
40+
"""
41+
return self.call('store.list', [filters])
42+
43+
44+
class Magento(API):
45+
"""
46+
This API returns information about current magento installation
47+
"""
48+
49+
__slots__ = ()
50+
51+
def info(self):
52+
"""
53+
Returns information about current magento
54+
"""
55+
return self.call('core_magento.info', [])

0 commit comments

Comments
 (0)