EmizenTech_Mobile - Version 1.0.0

Version Notes

Using this module you can sell your products on mobiles gadgets. Install this module and download app from iTune store, create an api user name and password to configure both.

Your catalog will be appear on mobile.

Download this release

Release Info

Developer Emizen Tech Private Limited
Extension EmizenTech_Mobile
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/EmizenTech/MagentoApi/Block/Index.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Block_Index extends Mage_Core_Block_Template{
3
+
4
+
5
+
6
+
7
+
8
+ }
app/code/local/EmizenTech/MagentoApi/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
5
+
app/code/local/EmizenTech/MagentoApi/Model/Api.php ADDED
@@ -0,0 +1,586 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Api extends Mage_Api_Model_Resource_Abstract
3
+ {
4
+ /*
5
+ * @ Get Home Slides Images
6
+ * @ When You will use this api, you Get All Home Slider Images
7
+ * @ Call Method Like This: magentoapi_api.homeslides'
8
+ * @ If not showing images OR home slider on home page please check you have images in promo-cards folder or not which locate is /media/wysiwyg/home-slide/ , If you have images in this folder after that you have to select folder path in the static block in backend, locate is: CMS > Pages, edit home-slider identifer and modify.
9
+ */
10
+ public function HomeSlides(){
11
+
12
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
13
+ return;
14
+
15
+ preg_match_all('/<img[^>]+>/i',Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('home-slider')->toHtml(),$imgsrc);
16
+
17
+ foreach ($imgsrc[0] as $value) {
18
+ $doc = new DOMDocument();
19
+ $doc->loadHTML($value);
20
+ $xpath = new DOMXPath($doc);
21
+ $src['slides'][] = $xpath->evaluate("string(//img/@src)");
22
+ }
23
+
24
+ return $src;
25
+ }
26
+
27
+ /*
28
+ * @ Get Home Banner Images
29
+ * @ When You will use this api you Get All Home Banner
30
+ * @ Call Method Like This: magentoapi_api.homebanner'
31
+ * @ If not showing images OR home banner on home page please check you have images in promo-cards folder or not which locate is /media/wysiwyg/promo-cards/ , If you have images in this folder after that you have to select folder path in the static block in backend, locate is: CMS > Static Blocks, edit home-banner identifer and modify.
32
+ */
33
+ public function HomeBanner(){
34
+
35
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
36
+ return;
37
+
38
+ preg_match_all('/<img[^>]+>/i',Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('home-banner')->toHtml(),$imgsrc);
39
+
40
+ foreach ($imgsrc[0] as $value) {
41
+ $doc = new DOMDocument();
42
+ $doc->loadHTML($value);
43
+ $xpath = new DOMXPath($doc);
44
+ $src['banners'][] = $xpath->evaluate("string(//img/@src)");
45
+ }
46
+
47
+ return $src;
48
+ }
49
+
50
+ /*
51
+ * @ Get New Products
52
+ * @ When You will use this api you Get All New Products Which all you save according to date in the backend.
53
+ * @ Call Method Like This: magentoapi_api.newproducts'
54
+ */
55
+ public function NewProducts(){
56
+
57
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
58
+ return;
59
+
60
+ $todayStartOfDayDate = Mage::app()->getLocale()->date()
61
+ ->setTime('00:00:00')
62
+ ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
63
+
64
+ $todayEndOfDayDate = Mage::app()->getLocale()->date()
65
+ ->setTime('23:59:59')
66
+ ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
67
+
68
+ $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
69
+ $collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
70
+
71
+ $collection->addStoreFilter(1)
72
+ ->addAttributeToFilter('news_from_date', array('or'=> array(
73
+ 0 => array('date' => true, 'to' => $todayEndOfDayDate),
74
+ 1 => array('is' => new Zend_Db_Expr('null')))
75
+ ), 'left')
76
+ ->addAttributeToFilter('news_to_date', array('or'=> array(
77
+ 0 => array('date' => true, 'from' => $todayStartOfDayDate),
78
+ 1 => array('is' => new Zend_Db_Expr('null')))
79
+ ), 'left')
80
+ ->addAttributeToFilter(
81
+ array(
82
+ array('attribute' => 'news_from_date', 'is'=>new Zend_Db_Expr('not null')),
83
+ array('attribute' => 'news_to_date', 'is'=>new Zend_Db_Expr('not null'))
84
+ )
85
+ )
86
+ ->addAttributeToSort('news_from_date', 'desc')
87
+ ->setPageSize(6)
88
+ ->setCurPage(1)
89
+ ;
90
+
91
+ $options = array();
92
+ foreach ($collection->getData() as $key=>$value) {
93
+ $product = Mage::getModel('catalog/product')->load($value['entity_id']);
94
+ $cat_ids = implode(",", $product->getCategoryIds());
95
+ $cropped_image_url = (string)Mage::helper('catalog/image')->init($product, 'image')->resize(150);
96
+ $options[$key]['name'] = $product->getData('name');
97
+ $options[$key]['image_url'] = $cropped_image_url;
98
+ $options[$key]['price'] = $product->getData('price');
99
+ $options[$key]['sku'] = $value['sku'];
100
+ $options[$key]['is_in_stock'] = $product->stock_item->is_in_stock;
101
+ $options[$key]['category_ids'] = $cat_ids;
102
+ $options[$key]['product_id'] = $product->getId();
103
+ }
104
+
105
+ return $options;
106
+ }
107
+
108
+ /*
109
+ * @ Get Product Detail By Product Id
110
+ * @ When You will use this api you must have pass productId. Call Method Like This: magentoapi_api.productdetailbyid', array('productId')
111
+ */
112
+ public function ProductDetailById($productId = null){
113
+
114
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
115
+ return;
116
+
117
+ $product = array(); // Making array of products collection custom which all items we need to use
118
+
119
+ $collection = Mage::getModel('catalog/product')->load($productId); // Load product collection using product id
120
+
121
+ $resized_image_url = (string)Mage::helper('catalog/image')->init($collection, 'image')->resize(250); // Resized image according to iphone app
122
+
123
+ $product['name'] = $collection->getData('name');
124
+ $product['sku'] = $collection->getData('sku');
125
+ $product['is_in_stock'] = $collection->stock_item->is_in_stock;
126
+ $product['type_id'] = $collection->getData('type_id');
127
+ $product['meta_description'] = $collection->getData('meta_description');
128
+ $product['price'] = $collection->getData('price');
129
+ $product['description'] = $collection->getData('description');
130
+ $product['short_description'] = $collection->getData('short_description');
131
+ $product['meta_keyword'] = $collection->getData('meta_keyword');
132
+ $product['image_url'] = $resized_image_url;
133
+ $product['product_id'] = $collection->getId();
134
+
135
+ if($collection->getData('type_id') == 'bundle') // check if product type is bundle or not
136
+ {
137
+ $selectionCollection = $collection->getTypeInstance(true)->getSelectionsCollection(
138
+ $collection->getTypeInstance(true)->getOptionsIds($collection), $collection
139
+ );
140
+
141
+ $i = 0;
142
+ foreach($selectionCollection as $option)
143
+ {
144
+ $formattedPrice = Mage::helper('core')->currency($option->getSelectionPriceValue(), true, false);
145
+
146
+ if($option->getSelectionPriceType() == 0)
147
+ {
148
+ $price_type = "fixed";
149
+ }
150
+ else
151
+ {
152
+ $price_type = "percent";
153
+ }
154
+
155
+ $product['bundle_options']['items_'.$i]['title'] = $option->getName();
156
+ $product['bundle_options']['items_'.$i]['selection_id'] = $option->getSelectionId();
157
+ $product['bundle_options']['items_'.$i]['price'] = $formattedPrice;
158
+ $product['bundle_options']['items_'.$i]['option_id'] = $option->getOptionId();
159
+ $product['bundle_options']['items_'.$i]['price_type'] = $price_type;
160
+ $product['bundle_options']['items_'.$i]['sku'] = $option->getSku();
161
+ $i++;
162
+ }
163
+ }
164
+
165
+ if($collection->getData('type_id') == 'configurable') // check if product type is configurable or not
166
+ {
167
+ $productAttributeOptions = $collection->getTypeInstance(true)->getConfigurableAttributesAsArray($collection);
168
+ foreach($productAttributeOptions as $_attribute)
169
+ {
170
+ foreach($_attribute['values'] as $attribute)
171
+ {
172
+ $product['configurable'][$_attribute['label']]['attribute_id'] = $_attribute['attribute_id'];
173
+ $product['configurable'][$_attribute['label']][$attribute['value_index']] = $attribute['store_label'];
174
+ }
175
+ }
176
+ }
177
+
178
+ foreach($collection->getTypeInstance(true)->getEditableAttributes($collection) as $attribute)
179
+ {
180
+ $product[$attribute->getAttributeCode()] = $collection->getData($attribute->getAttributeCode());
181
+ }
182
+
183
+ return $product;
184
+ }
185
+
186
+ /*
187
+ * @ Get Products Detail By Category Id.
188
+ * @ When You will use this api to Get Category Products, you must have pass categoryId inside the parameter
189
+ * @ Call Method Like This: magentoapi_api.productsbycategoryid', array('categoryId','sort order', 'direction like desc OR asc');
190
+ */
191
+ public function ProductsByCategoryId($categoryId, $sortOrder, $direction){
192
+
193
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
194
+ return;
195
+
196
+ $options = array();
197
+
198
+ $_category = Mage::getModel('catalog/category')->load($categoryId);
199
+ $collection = $_category
200
+ ->getProductCollection()
201
+ ->addAttributeToSelect('*');
202
+ $collection->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
203
+
204
+
205
+ // If you need to use showing products using pagination use this commented code
206
+
207
+ //$before_coll = count($_category->getProductCollection()->addAttributeToSelect('*'));
208
+
209
+ /*if(isset($_GET['page']) && $_GET['page_size']){
210
+ $collection->setPage($_GET['page'],$_GET['page_size']);
211
+ $collection->setPageSize($_GET['page_size']);
212
+ }*/
213
+
214
+ //$totl_rocrd = round($before_coll/$_GET['page_size']);
215
+ //$options['total_record'] = $totl_rocrd;
216
+
217
+ $options['sort_order'] = $_category->getAvailableSortByOptions();
218
+
219
+ /*if you should sort order list then use this code */
220
+ if(in_array($sortOrder, array_keys($options['sort_order']))){
221
+ if($direction == 'DESC')
222
+ $collection->setOrder($sortOrder , 'DESC');
223
+ else
224
+ $collection->setOrder($sortOrder , 'ASC');
225
+ }
226
+
227
+ $i = 0;
228
+ foreach ($collection as $product) {
229
+
230
+ $load = Mage::getModel('catalog/product')->load($product->getId());
231
+
232
+ $media_catalog_URL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."catalog/product";
233
+
234
+ $cropped_image_url = (string)Mage::helper('catalog/image')->init($load, 'image')->resize(150);
235
+
236
+ $options['product_'.$i]['entity_id'] = $product->getData('entity_id');
237
+ $options['product_'.$i]['type_id'] = $product->getData('type_id');
238
+ $options['product_'.$i]['sku'] = $product->getData('sku');
239
+ $options['product_'.$i]['is_in_stock'] = $load->stock_item->is_in_stock;
240
+ $options['product_'.$i]['meta_keyword'] = $product->getData('meta_keyword');
241
+ $options['product_'.$i]['description'] = $product->getData('description');
242
+ $options['product_'.$i]['short_description'] = $product->getData('short_description');
243
+ $options['product_'.$i]['name'] = $product->getData('name');
244
+ $options['product_'.$i]['meta_description'] = $product->getData('meta_description');
245
+ $options['product_'.$i]['price'] = $product->getData('price');
246
+ //$options['product_'.$i]['is_saleable'] = $product->isSaleable();
247
+ $options['product_'.$i]['image_url'] = $cropped_image_url;
248
+ $options['product_'.$i]['add_cart_url'] = Mage::helper('checkout/cart')->getAddUrl($product);
249
+ $options['product_'.$i]['product_id'] = $product->getId();
250
+ $i++;
251
+ }
252
+
253
+ return $options;
254
+ }
255
+
256
+ /*
257
+ * @ Get Customer Detail with particular parameter.
258
+ * @ When You will use this api to Get Customer Details, you must have pass useremail, pass inside the parameter
259
+ * @ Call Method Like This: magentoapi_api.getcustomerid', array('useremail','pass');
260
+ */
261
+ public function GetCustomerId($useremail = null, $pass = null, $store = 1)
262
+ {
263
+
264
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
265
+ return;
266
+
267
+ $websiteId = Mage::getModel('core/store')->load($store)->getWebsiteId(); // load store to get website id
268
+ $result = array();
269
+ $result["useremail"] = $useremail;
270
+ $result["pass"] = $pass;
271
+ $status = 1; // for checking customer email and password is valid or not so we set the status
272
+ try{
273
+ $customer_result = Mage::getModel('customer/customer')->setWebsiteId($websiteId)->authenticate($useremail,$pass); // authenticate customer with email and pass
274
+ $customers = Mage::getModel('customer/customer')->setWebsiteId($websiteId);
275
+ $customers->loadByEmail($useremail);
276
+ $result["firstname"] = $customers->firstname;
277
+ $result["lastname"] = $customers->lastname;
278
+ $result["customerId"] = $customers->getId();
279
+ $result["website"] = $websiteId;
280
+ //$result["password"]
281
+ //$result["password"]
282
+ }
283
+ catch( Exception $e ){
284
+ $result["status"] = 0;
285
+ $result['error_msg'] = "Invalid login or password";
286
+ }
287
+
288
+ return $result;
289
+ }
290
+
291
+ /*
292
+ * @ Get Related Products Using Product Id.
293
+ * @ When You will use this api to Get Related Products According To Product Id, you must have pass ProductId
294
+ * @ Call Method Like This: magentoapi_api.relatedproducts', array('ProductId');
295
+ */
296
+ public function RelatedProducts($productId = null)
297
+ {
298
+
299
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
300
+ return;
301
+
302
+ $result = array();
303
+ $model = Mage::getModel('catalog/product');
304
+ $product = $model->load($productId);
305
+
306
+ // Get all related product ids of $product.
307
+ $allRelatedProductIds = $product->getRelatedProductIds();
308
+
309
+ $j = 0;
310
+ foreach ($allRelatedProductIds as $id)
311
+ {
312
+ $relatedProduct = $model->load($id);
313
+ $resized_image_url = (string)Mage::helper('catalog/image')->init($relatedProduct, 'image')->resize(200);
314
+ $formattedPrice = Mage::helper('core')->currency($relatedProduct->getData('price'), true, false);
315
+ $result['productItems_'.$j]['name'] = $relatedProduct->getData('name');
316
+ $result['productItems_'.$j]['sku'] = $relatedProduct->getData('sku');
317
+ $result['productItems_'.$j]['is_in_stock'] = $relatedProduct->stock_item->is_in_stock;
318
+ $result['productItems_'.$j]['type_id'] = $relatedProduct->getData('type_id');
319
+ $result['productItems_'.$j]['meta_description'] = $relatedProduct->getData('meta_description');
320
+ $result['productItems_'.$j]['price'] = $formattedPrice;
321
+ $result['productItems_'.$j]['description'] = $relatedProduct->getData('description');
322
+ $result['productItems_'.$j]['short_description'] = $relatedProduct->getData('short_description');
323
+ $result['productItems_'.$j]['meta_keyword'] = $relatedProduct->getData('meta_keyword');
324
+ $result['productItems_'.$j]['image_url'] = $resized_image_url;
325
+ $result['productItems_'.$j]['product_id'] = $relatedProduct->getId();
326
+ $j++;
327
+ }
328
+ return $result;
329
+ }
330
+
331
+
332
+ /*
333
+ * @ Get CMS Page Content Using this Api.
334
+ * @ When You will use this api to Get CMS Page Content, you must have pass Page Identifier From The End Of The URL like this: Suppose you have a URL: YOUR_MAGENTO_PATH/about-us, you need to pass only this about-us to get content.
335
+ * @ Call Method Like This: magentoapi_api.getcmspagecontent', array('Page Identifier');
336
+ */
337
+ public function GetCmsPageContent($page = null)
338
+ {
339
+
340
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
341
+ return;
342
+
343
+ if($page)
344
+ {
345
+ $PageData = Mage::getModel('cms/page')->load($page,'identifier');
346
+ $html = array();
347
+
348
+ $helper = Mage::helper('cms');
349
+ $processor = $helper->getPageTemplateProcessor();
350
+
351
+ $html['title'] = $PageData->getTitle();
352
+ $html['html'] = $processor->filter($PageData->getContent());
353
+ }
354
+ else
355
+ {
356
+ die('Error: Must be pass page identifier to get page data.');
357
+ }
358
+
359
+ return $html;
360
+ }
361
+
362
+ /*
363
+ * @ Newsletter Api.
364
+ * @ When You will use this api to Send Newsletter, you must have pass email,CustomerId(if exists : optional)
365
+ * @ Call Method Like This: magentoapi_api.newsletter', array('email','CustomerId:optional');
366
+ */
367
+ public function Newsletter($email, $customerId = null, $store = 1)
368
+ {
369
+
370
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
371
+ return;
372
+
373
+ try
374
+ {
375
+ $websiteId = Mage::getModel('core/store')->load($store)->getWebsiteId(); // load store to get website id
376
+
377
+ if(Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 && !$customerId)
378
+ {
379
+ return json_encode(array('error' => 'Sorry, but administrator denied subscription for guests. Please register first.'));
380
+ }
381
+
382
+ $Id = Mage::getModel('customer/customer')
383
+ ->setWebsiteId($websiteId)
384
+ ->loadByEmail($email)
385
+ ->getId(); // get id according to website id and email
386
+
387
+ if ($Id !== null && $Id != $customerId) // check if customer logged in to another system
388
+ {
389
+ return json_encode(array('error' => "This email address is already assigned to another user."));
390
+ }
391
+
392
+ //$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
393
+
394
+ $status = Mage::getModel('newsletter/subscriber')->subscribe($email);
395
+
396
+ if ($status == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE)
397
+ {
398
+ return json_encode(array('success' => "Confirmation request has been sent."));
399
+ }
400
+ else
401
+ {
402
+ return json_encode(array('success' => "Thank you for your subscription."));
403
+ }
404
+ }
405
+ catch(Exception $e)
406
+ {
407
+ return json_encode(array('There was a problem with the subscription: %s', $e->getMessage())); // return error using exception
408
+ }
409
+ }
410
+
411
+ /*
412
+ * @ Contact Us Api.
413
+ * @ When You will use this api to Contact Us, you must have pass name,email,telephone,comment
414
+ * @ Call Method Like This: magentoapi_api.contact', array('name','email','telephone','comment');
415
+ */
416
+ public function Contact($name, $email, $telephone, $comment, $blank = null)
417
+ {
418
+
419
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
420
+ return;
421
+
422
+ // get data in array format
423
+ $postarr = array('name' => $name, 'email' => $email, 'telephone' => $telephone, 'comment' => $comment, 'hideit' => $blank);
424
+
425
+ if ($postarr)
426
+ {
427
+ $translateIn = Mage::getSingleton('core/translate');
428
+ $translateIn->setTranslateInline(false); // set inline translation
429
+ try
430
+ {
431
+ $postObj = new Varien_Object(); // set data to object
432
+ $postObj->setData($postarr);
433
+
434
+ $emailTem = Mage::getModel('core/email_template'); // template email model
435
+
436
+ $emailTem->setDesignConfig(array('area' => 'frontend'))
437
+ ->setReplyTo($postarr['email'])
438
+ ->sendTransactional(
439
+ Mage::getStoreConfig('contacts/email/email_template'),
440
+ Mage::getStoreConfig('contacts/email/sender_email_identity'),
441
+ Mage::getStoreConfig('contacts/email/recipient_email'),
442
+ null,
443
+ array('data' => $postObj)
444
+ );
445
+
446
+ if (!$emailTem->getSentSuccess()) {
447
+ return json_encode(array('Error' => "Email not sent")); // return error using exception
448
+ }
449
+
450
+ $translateIn->setTranslateInline(true);
451
+
452
+ // return in json format success message if mail is sent
453
+ return json_encode(array('Success' => "Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.")); // return error using exception
454
+
455
+ }
456
+ catch (Exception $e)
457
+ {
458
+ $translateIn->setTranslateInline(true);
459
+ return json_encode(array('Success' => 'Unable to submit your request. Please, try again later'));
460
+ }
461
+ }
462
+ }
463
+
464
+ /*
465
+ * @ Add To Products Wishlist Api.
466
+ * @ When You will use this api to Add Product In Wishlist, you must have pass CustomerId,ProductId,
467
+ * @ Call Method Like This: magentoapi_api.wishlistadd', array('CustomerId','ProductId');
468
+ */
469
+ public function WishlistAdd($customerId , $productId , $store = 1)
470
+ {
471
+
472
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
473
+ return;
474
+
475
+ //Mage::log("cust:".$customerId . " ~ prod:".$productId ." store:".$store, null , 'myapi.log'); // create log for check responce
476
+
477
+ $websiteId = Mage::getModel('core/store')->load($store)->getWebsiteId();
478
+
479
+ $customer = Mage::getModel('customer/customer')->setWebsiteId($websiteId);
480
+
481
+ $wishlist = Mage::getModel('wishlist/wishlist'); // load wishlist model
482
+
483
+ //$product = Mage::getModel('catalog/product')->load($productId);
484
+ $product = Mage::getModel('catalog/product')->setStoreId($store)->load($productId);
485
+
486
+ if(!$product)
487
+ return array('error' => "Product Not Found");
488
+ $customer->load($customerId); // load customer according to customer id
489
+
490
+ $wishlist->loadByCustomer($customer);
491
+
492
+ // using try and catch method
493
+ try
494
+ {
495
+ $res = $wishlist->addNewItem($product);
496
+ $res->setStore($store);
497
+ $res->save();
498
+ $wishlist->save();
499
+ Mage::dispatchEvent(
500
+ 'wishlist_add_product',
501
+ array(
502
+ 'wishlist' => $wishlist,
503
+ 'product' => $product,
504
+ 'item' => $res
505
+ )
506
+ );
507
+
508
+ if($res)
509
+ return json_encode(array('success' => "Added"));
510
+ else
511
+ return json_encode(array('error' => "Error in adding product to wishlist"));
512
+ }
513
+ catch(Exception $e )
514
+ {
515
+ return json_encode(array('error' => "Error:".$e->getMessage())); // return error using exception
516
+ }
517
+ }
518
+
519
+ /*
520
+ * @ Delete Items In Customer Wishlist
521
+ * @ When You will use this api to Delete Product In Wishlist, you must have pass CustomerId,ItemId,
522
+ * @ Call Method Like This: magentoapi_api.wishlistdelete', array('CustomerId','itemId');
523
+ */
524
+ public function WishlistDelete($customerId , $itemId)
525
+ {
526
+
527
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
528
+ return;
529
+
530
+ $item = Mage::getModel('wishlist/item')->load($itemId); // load wishlist model using item id
531
+ if (!$item->getId()) {
532
+ return array('error' => "Error:Item Not Found");
533
+ }
534
+ $wishlist = Mage::getModel('wishlist/wishlist')->load($item->getWishlistId());
535
+ if (!$wishlist) {
536
+ return array('error' => "Error:Wishlist Not Found");
537
+ }
538
+ try {
539
+ $item->delete(); // delete items in wishlist
540
+ $wishlist->save(); // save wishlist model after delete items
541
+ Mage::helper('wishlist')->calculate();
542
+ return array('success' => "Item:".$itemId." Deleted");
543
+ }
544
+ catch(Exception $e )
545
+ {
546
+ return array('error' => "Error:".$e->getMessage());
547
+ }
548
+ }
549
+
550
+ /*
551
+ * @ Get All Items From Customer Wishlist.
552
+ * @ When You will use this api to Get All Items From Customer Wishlist, you must have pass CustomerId
553
+ * @ Call Method Like This: magentoapi_api.wishlistview', array('CustomerId');
554
+ */
555
+ public function WishlistView($customerId)
556
+ {
557
+
558
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
559
+ return;
560
+
561
+ try
562
+ {
563
+ $itemCollection = Mage::getResourceModel('wishlist/item_collection'); // Items Collection
564
+ $itemCollection->addCustomerIdFilter($customerId); // filter according to customer id which is logged in
565
+
566
+ $data = array();
567
+ foreach($itemCollection as $item) {
568
+ $product = $item->getProduct();
569
+ $data[] = array('item_id' => $item->getId(),
570
+ 'product_id' => $item->getProductId(),
571
+ 'name' => $product->getName(),
572
+ 'price' => $product->getPrice(),
573
+ 'small_image' => "".Mage::helper('catalog/image')->init($product, 'small_image')->resize(113, 113)
574
+ );
575
+ }
576
+ }
577
+ catch(Exception $e )
578
+ {
579
+ return array('error' => "Error:".$e->getMessage());
580
+ }
581
+ return $data; // return product items fields with product attributes in json format
582
+ }
583
+
584
+
585
+
586
+ }
app/code/local/EmizenTech/MagentoApi/Model/Catalog/Product/Api.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api
3
+ {
4
+ /**
5
+ * Retrieve list of products with basic info (id, sku, type, set, name)
6
+ *
7
+ * @param null|object|array $filters
8
+ * @param string|int $store
9
+ * @return array
10
+ */
11
+ public function items($filters = null, $store = null)
12
+ {
13
+ $collection = Mage::getModel('catalog/product')->getCollection()
14
+ ->addStoreFilter($this->_getStoreId($store))
15
+ ->addAttributeToSort('name', 'desc')
16
+ ->addAttributeToSelect('name');
17
+
18
+ $collection_send = Mage::getModel('catalog/product')->getCollection()
19
+ ->addStoreFilter($this->_getStoreId($store))
20
+ ->addAttributeToSort('name', 'desc')
21
+ ->addAttributeToSelect('name');
22
+
23
+ /** @var $apiHelper Mage_Api_Helper_Data */
24
+ $apiHelper = Mage::helper('api');
25
+ $filters = $apiHelper->parseFilters($filters, $this->_filtersMap);
26
+ try {
27
+ foreach ($filters as $field => $value) {
28
+ $collection->addFieldToFilter($field, $value);
29
+ if(count($collection)==0)
30
+ {
31
+ $collection_send->addFieldToFilter('sku', $value);
32
+ $collection = $collection_send;
33
+ }
34
+ }
35
+ } catch (Mage_Core_Exception $e) {
36
+ $this->_fault('filters_invalid', $e->getMessage());
37
+ }
38
+ $result = array();
39
+ foreach ($collection as $product) {
40
+ $load = Mage::getModel('catalog/product')->load($product->getId());
41
+ $formattedPrice = Mage::helper('core')->currency($load->getPrice(), true, false);
42
+ $cropped_image_url = (string)Mage::helper('catalog/image')->init($load, 'image')->resize(100);
43
+
44
+ $result[] = array(
45
+ 'product_id' => $product->getId(),
46
+ 'sku' => $product->getSku(),
47
+ 'image' => $cropped_image_url,
48
+ 'price' => $formattedPrice,
49
+ 'name' => $product->getName(),
50
+ 'set' => $product->getAttributeSetId(),
51
+ 'type' => $product->getTypeId(),
52
+ 'category_ids' => $product->getCategoryIds(),
53
+ 'website_ids' => $product->getWebsiteIds()
54
+ );
55
+ }
56
+ return $result;
57
+ }
58
+ }
59
+
app/code/local/EmizenTech/MagentoApi/Model/Checkout/Cart/Api.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Checkout_Cart_Api extends Mage_Checkout_Model_Cart_Api
3
+ {
4
+ /**
5
+ * Create new quote for shopping cart
6
+ *
7
+ * @param int|string $store
8
+ * @return int
9
+ */
10
+ public function create($store = null)
11
+ {
12
+ $storeId = $this->_getStoreId($store);
13
+
14
+ try {
15
+ /*@var $quote Mage_Sales_Model_Quote*/
16
+ $quote = Mage::getModel('sales/quote');
17
+ $quote->setStoreId($storeId)
18
+ ->setIsActive(false)
19
+ ->setIsMultiShipping(false);
20
+ $quote->getBillingAddress();
21
+ $quote->getShippingAddress();
22
+ $quote->save();
23
+ } catch (Mage_Core_Exception $e) {
24
+ $this->_fault('create_quote_fault', $e->getMessage());
25
+ }
26
+ return (int) $quote->getId();
27
+ }
28
+
29
+ /**
30
+ * Retrieve full information about quote
31
+ *
32
+ * @param $quoteId
33
+ * @param $store
34
+ * @return array
35
+ */
36
+ public function info($quoteId, $store = null)
37
+ {
38
+ $quote = $this->_getQuote($quoteId, $store);
39
+
40
+ if ($quote->getGiftMessageId() > 0) {
41
+ $quote->setGiftMessage(
42
+ Mage::getSingleton('giftmessage/message')->load($quote->getGiftMessageId())->getMessage()
43
+ );
44
+ }
45
+
46
+ $result = $this->_getAttributes($quote, 'quote');
47
+ $result['shipping_address'] = $this->_getAttributes($quote->getShippingAddress(), 'quote_address');
48
+ $result['billing_address'] = $this->_getAttributes($quote->getBillingAddress(), 'quote_address');
49
+ $result['items'] = array();
50
+
51
+ foreach ($quote->getAllItems() as $item) {
52
+ if ($item->getGiftMessageId() > 0) {
53
+ $item->setGiftMessage(
54
+ Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
55
+ );
56
+ }
57
+
58
+ $result['items'][] = $this->_getAttributes($item, 'quote_item');
59
+ }
60
+
61
+ $result['payment'] = $this->_getAttributes($quote->getPayment(), 'quote_payment');
62
+
63
+ return $result;
64
+ }
65
+
66
+ /**
67
+ * @param $quoteId
68
+ * @param $store
69
+ * @return void
70
+ */
71
+ public function totals($quoteId, $store = null)
72
+ {
73
+ $quote = $this->_getQuote($quoteId, $store);
74
+
75
+ $totals = $quote->getTotals();
76
+
77
+ $totalsResult = array();
78
+ foreach ($totals as $total) {
79
+ $totalsResult[] = array(
80
+ "title" => $total->getTitle(),
81
+ "amount" => $total->getValue()
82
+ );
83
+ }
84
+ return $totalsResult;
85
+ }
86
+
87
+ /**
88
+ * Create an order from the shopping cart (quote)
89
+ *
90
+ * @param $quoteId
91
+ * @param $store
92
+ * @param $agreements array
93
+ * @return string
94
+ */
95
+ public function createOrder($quoteId, $store = null, $agreements = null)
96
+ {
97
+ $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();
98
+ if (!empty($requiredAgreements)) {
99
+ $diff = array_diff($agreements, $requiredAgreements);
100
+ if (!empty($diff)) {
101
+ $this->_fault('required_agreements_are_not_all');
102
+ }
103
+ }
104
+
105
+ $quote = $this->_getQuote($quoteId, $store);
106
+ if ($quote->getIsMultiShipping()) {
107
+ $this->_fault('invalid_checkout_type');
108
+ }
109
+ if ($quote->getCheckoutMethod() == Mage_Checkout_Model_Api_Resource_Customer::MODE_GUEST
110
+ && !Mage::helper('checkout')->isAllowedGuestCheckout($quote, $quote->getStoreId())) {
111
+ $this->_fault('guest_checkout_is_not_enabled');
112
+ }
113
+
114
+ /** @var $customerResource Mage_Checkout_Model_Api_Resource_Customer */
115
+ $customerResource = Mage::getModel("checkout/api_resource_customer");
116
+ $isNewCustomer = $customerResource->prepareCustomerForQuote($quote);
117
+
118
+ try {
119
+ $quote->collectTotals();
120
+ /** @var $service Mage_Sales_Model_Service_Quote */
121
+ $service = Mage::getModel('sales/service_quote', $quote);
122
+ $service->submitAll();
123
+
124
+ if ($isNewCustomer) {
125
+ try {
126
+ $customerResource->involveNewCustomer($quote);
127
+ } catch (Exception $e) {
128
+ Mage::logException($e);
129
+ }
130
+ }
131
+
132
+ $order = $service->getOrder();
133
+ if ($order) {
134
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after',
135
+ array('order' => $order, 'quote' => $quote));
136
+
137
+ try {
138
+ $order->sendNewOrderEmail();
139
+ } catch (Exception $e) {
140
+ Mage::logException($e);
141
+ }
142
+ }
143
+
144
+ Mage::dispatchEvent(
145
+ 'checkout_submit_all_after',
146
+ array('order' => $order, 'quote' => $quote)
147
+ );
148
+ } catch (Mage_Core_Exception $e) {
149
+ $this->_fault('create_order_fault', $e->getMessage());
150
+ }
151
+
152
+ return $order->getIncrementId();
153
+ }
154
+
155
+ /**
156
+ * @param $quoteId
157
+ * @param $store
158
+ * @return array
159
+ */
160
+ public function licenseAgreement($quoteId, $store = null)
161
+ {
162
+ $quote = $this->_getQuote($quoteId, $store);
163
+ $storeId = $quote->getStoreId();
164
+
165
+ $agreements = array();
166
+ if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
167
+ $agreementsCollection = Mage::getModel('checkout/agreement')->getCollection()
168
+ ->addStoreFilter($storeId)
169
+ ->addFieldToFilter('is_active', 1);
170
+
171
+ foreach ($agreementsCollection as $_a) {
172
+ /** @var $_a Mage_Checkout_Model_Agreement */
173
+ $agreements[] = $this->_getAttributes($_a, "quote_agreement");
174
+ }
175
+ }
176
+
177
+ return $agreements;
178
+ }
179
+ }
180
+
app/code/local/EmizenTech/MagentoApi/Model/Checkout/Cart/Customer/Api.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Checkout_Cart_Customer_Api extends Mage_Checkout_Model_Cart_Customer_Api
3
+ {
4
+ /**
5
+ * Set customer for shopping cart
6
+ *
7
+ * @param int $quoteId
8
+ * @param array|object $customerData
9
+ * @param int | string $store
10
+ * @return int
11
+ */
12
+ public function set($quoteId, $customerData, $store = null)
13
+ {
14
+ $quote = $this->_getQuote($quoteId, $store);
15
+
16
+ $customerData = $this->_prepareCustomerData($customerData);
17
+ if (!isset($customerData['mode'])) {
18
+ $this->_fault('customer_mode_is_unknown');
19
+ }
20
+
21
+ switch($customerData['mode']) {
22
+ case self::MODE_CUSTOMER:
23
+ /** @var $customer Mage_Customer_Model_Customer */
24
+ $customer = $this->_getCustomer($customerData['entity_id']);
25
+ $customer->setMode(self::MODE_CUSTOMER);
26
+ break;
27
+
28
+ case self::MODE_REGISTER:
29
+ case self::MODE_GUEST:
30
+ /** @var $customer Mage_Customer_Model_Customer */
31
+ $customer = Mage::getModel('customer/customer')
32
+ ->setData($customerData);
33
+
34
+ if ($customer->getMode() == self::MODE_GUEST) {
35
+ $password = $customer->generatePassword();
36
+
37
+ $customer
38
+ ->setPassword($password)
39
+ ->setConfirmation($password);
40
+ }
41
+
42
+ $isCustomerValid = $customer->validate();
43
+ if ($isCustomerValid !== true && is_array($isCustomerValid)) {
44
+ $this->_fault('customer_data_invalid', implode(PHP_EOL, $isCustomerValid));
45
+ }
46
+ break;
47
+ }
48
+
49
+ try {
50
+ $quote
51
+ ->setCustomer($customer)
52
+ ->setCheckoutMethod($customer->getMode())
53
+ ->setPasswordHash($customer->encryptPassword($customer->getPassword()))
54
+ ->save();
55
+ } catch (Mage_Core_Exception $e) {
56
+ $this->_fault('customer_not_set', $e->getMessage());
57
+ }
58
+
59
+ return true;
60
+ }
61
+
62
+ /**
63
+ * @param int $quoteId
64
+ * @param array of array|object $customerAddressData
65
+ * @param int|string $store
66
+ * @return int
67
+ */
68
+ public function setAddresses($quoteId, $customerAddressData, $store = null)
69
+ {
70
+ Mage::log(var_export($quoteId , true), null , "api_address.log");
71
+ Mage::log(var_export($customerAddressData , true), null , "api_address.log");
72
+ $quote = $this->_getQuote($quoteId, $store);
73
+
74
+ $customerAddressData = $this->_prepareCustomerAddressData($customerAddressData);
75
+ if (is_null($customerAddressData)) {
76
+ $this->_fault('customer_address_data_empty');
77
+ }
78
+
79
+ foreach ($customerAddressData as $addressItem) {
80
+ // switch($addressItem['mode']) {
81
+ // case self::ADDRESS_BILLING:
82
+ /** @var $address Mage_Sales_Model_Quote_Address */
83
+ $address = Mage::getModel("sales/quote_address");
84
+ // break;
85
+ // case self::ADDRESS_SHIPPING:
86
+ // /** @var $address Mage_Sales_Model_Quote_Address */
87
+ // $address = Mage::getModel("sales/quote_address");
88
+ // break;
89
+ // }
90
+ $addressMode = $addressItem['mode'];
91
+ unset($addressItem['mode']);
92
+
93
+ if (!empty($addressItem['entity_id'])) {
94
+ $customerAddress = $this->_getCustomerAddress($addressItem['entity_id']);
95
+ if ($customerAddress->getCustomerId() != $quote->getCustomerId()) {
96
+ $this->_fault('address_not_belong_customer');
97
+ }
98
+ $address->importCustomerAddress($customerAddress);
99
+
100
+ } else {
101
+ $address->setData($addressItem);
102
+ }
103
+
104
+ if(!empty($addressItem['region_id'])){
105
+ $address->setRegionId($addressItem['region_id']);
106
+ }
107
+
108
+ Mage::log(var_export($addressItem , true), null , "api_address.log");
109
+ Mage::log(var_export($address->debug() , true), null , "api_address.log");
110
+ $address->implodeStreetAddress();
111
+
112
+ if (($validateRes = $address->validate())!==true) {
113
+ $this->_fault('customer_address_invalid', implode(PHP_EOL, $validateRes));
114
+ }
115
+
116
+ switch($addressMode) {
117
+ case self::ADDRESS_BILLING:
118
+ $address->setEmail($quote->getCustomer()->getEmail());
119
+
120
+ if (!$quote->isVirtual()) {
121
+ $usingCase = isset($addressItem['use_for_shipping']) ? (int)$addressItem['use_for_shipping'] : 0;
122
+ switch($usingCase) {
123
+ case 0:
124
+ $shippingAddress = $quote->getShippingAddress();
125
+ $shippingAddress->setSameAsBilling(0);
126
+ break;
127
+ case 1:
128
+ $billingAddress = clone $address;
129
+ $billingAddress->unsAddressId()->unsAddressType();
130
+
131
+ $shippingAddress = $quote->getShippingAddress();
132
+ $shippingMethod = $shippingAddress->getShippingMethod();
133
+ $shippingAddress->addData($billingAddress->getData())
134
+ ->setSameAsBilling(1)
135
+ ->setShippingMethod($shippingMethod)
136
+ ->setCollectShippingRates(true);
137
+ break;
138
+ }
139
+ }
140
+ $quote->setBillingAddress($address);
141
+ break;
142
+
143
+ case self::ADDRESS_SHIPPING:
144
+ $address->setCollectShippingRates(true)
145
+ ->setSameAsBilling(0);
146
+ $quote->setShippingAddress($address);
147
+ break;
148
+ }
149
+
150
+ }
151
+
152
+ try {
153
+ $quote
154
+ ->collectTotals()
155
+ ->save();
156
+ } catch (Exception $e) {
157
+ $this->_fault('address_is_not_set', $e->getMessage());
158
+ }
159
+
160
+ return true;
161
+ }
162
+
163
+ /**
164
+ * Prepare customer entered data for implementing
165
+ *
166
+ * @param array $customerData
167
+ * @return array
168
+ */
169
+ protected function _prepareCustomerData($data)
170
+ {
171
+ foreach ($this->_attributesMap['quote_customer'] as $attributeAlias=>$attributeCode) {
172
+ if(isset($data[$attributeAlias]))
173
+ {
174
+ $data[$attributeCode] = $data[$attributeAlias];
175
+ unset($data[$attributeAlias]);
176
+ }
177
+ }
178
+ return $data;
179
+ }
180
+
181
+ /**
182
+ * Prepare customer entered data for implementing
183
+ *
184
+ * @param array $data
185
+ * @return array
186
+ */
187
+ protected function _prepareCustomerAddressData($data)
188
+ {
189
+ if (!is_array($data) || !is_array($data[0])) {
190
+ return null;
191
+ }
192
+
193
+ $dataAddresses = array();
194
+ foreach($data as $addressItem) {
195
+ foreach ($this->_attributesMap['quote_address'] as $attributeAlias=>$attributeCode) {
196
+ if(isset($addressItem[$attributeAlias]))
197
+ {
198
+ $addressItem[$attributeCode] = $addressItem[$attributeAlias];
199
+ unset($addressItem[$attributeAlias]);
200
+ }
201
+ }
202
+ $dataAddresses[] = $addressItem;
203
+ }
204
+ return $dataAddresses;
205
+ }
206
+ }
207
+ ?>
app/code/local/EmizenTech/MagentoApi/Model/Checkout/Cart/Product/Api.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Checkout_Cart_Product_Api extends Mage_Checkout_Model_Cart_Product_Api
3
+ {
4
+ /**
5
+ * @param $quoteId
6
+ * @param $store
7
+ * @return array
8
+ */
9
+ public function items($quoteId, $store = null)
10
+ {
11
+ $quote = $this->_getQuote($quoteId, $store);
12
+ if (empty($store)) {
13
+ $store = $quote->getStoreId();
14
+ }
15
+
16
+ if (!$quote->getItemsCount()) {
17
+ return array();
18
+ }
19
+
20
+ $productsResult = array();
21
+
22
+ foreach ($quote->getAllItems() as $item) {
23
+ /** @var $item Mage_Sales_Model_Quote_Item */
24
+ //return get_class_methods($item); die;
25
+ $product = $item->getProduct();
26
+
27
+ $load = Mage::getModel('catalog/product')->load($product->getId());
28
+
29
+ $cropped_image_url = (string)Mage::helper('catalog/image')->init($load, 'image')->resize(110);
30
+
31
+ if($product->getTypeId() == 'simple')
32
+ {
33
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
34
+
35
+ if($parentIds)
36
+ {
37
+ continue;
38
+ }
39
+ }
40
+
41
+ if($product->getTypeId() == 'bundle')
42
+ {
43
+ $BundleProductsResult = array();
44
+ $selectionCollection = $load->getTypeInstance(true)->getSelectionsCollection(
45
+ $load->getTypeInstance(true)->getOptionsIds($load), $load
46
+ );
47
+
48
+ foreach($selectionCollection as $option)
49
+ {
50
+ //$product['bundle'][] = $option->product_id;
51
+ $formattedPrice = Mage::helper('core')->currency($option->getSelectionPriceValue(), true, false);
52
+ //$product['bundle'][$option->getSelectionId()] = $option->getName()." +".$formattedPrice;
53
+
54
+ if($option->getSelectionPriceType() == 0)
55
+ {
56
+ $price_type = "fixed";
57
+ }
58
+ else
59
+ {
60
+ $price_type = "percent";
61
+ }
62
+ $BundleProductsResult[] = array(
63
+ 'title' => $option->getName(),
64
+ 'selection_id' => $option->getSelectionId(),
65
+ 'price' => $formattedPrice,
66
+ 'option_id' => $option->getOptionId(),
67
+ 'price_type' => $price_type,
68
+ 'sku' => $option->getSku()
69
+ );
70
+ }
71
+ $productsResult[] = array( // Basic product data
72
+ 'product_id' => $product->getId(),
73
+ 'sku' => $product->getSku(),
74
+ 'name' => $product->getName(),
75
+ 'set' => $product->getAttributeSetId(),
76
+ 'type' => $product->getTypeId(),
77
+ 'buldle' => $BundleProductsResult,
78
+ 'category_ids' => $product->getCategoryIds(),
79
+ 'website_ids' => $product->getWebsiteIds(),
80
+ 'image_url' => $cropped_image_url,
81
+ 'price' => Mage::helper('core')->currency($product->getPrice()*$item->getQty(), true, false),
82
+ 'orginal_price' => Mage::helper('core')->currency($product->getPrice(), true, false),
83
+ 'qty' => $item->getQty(),
84
+ 'parent_id' => $parentIds
85
+ );
86
+ }
87
+ elseif($product->getTypeId() == 'configurable')
88
+ {
89
+ //$ConfigurableProductsResult = array();
90
+
91
+ /* $productAttributeOptions = $load->getTypeInstance(true)->getConfigurableAttributesAsArray($load);
92
+ foreach($productAttributeOptions as $_attribute)
93
+ {
94
+ foreach($_attribute['values'] as $attribute)
95
+ {
96
+ $ConfigurableProductsResult[$_attribute['label']]['attribute_id'] = $_attribute['attribute_id'];
97
+ $ConfigurableProductsResult[$_attribute['label']][$attribute['value_index']] = $attribute['store_label'];
98
+ }
99
+ }*/
100
+
101
+ $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
102
+ $productsResult[] = array( // Basic product data
103
+ 'item_id' => $item->getId(),
104
+ 'product_id' => $product->getId(),
105
+ 'sku' => $product->getSku(),
106
+ 'name' => $product->getName(),
107
+ 'set' => $product->getAttributeSetId(),
108
+ 'type' => $product->getTypeId(),
109
+ 'configurable' => $options['attributes_info'],
110
+ 'super_attribute' => $options['info_buyRequest']['super_attribute'],
111
+ 'category_ids' => $product->getCategoryIds(),
112
+ 'website_ids' => $product->getWebsiteIds(),
113
+ 'image_url' => $cropped_image_url,
114
+ 'price' => Mage::helper('core')->currency($product->getPrice()*$item->getQty(), true, false),
115
+ 'orginal_price' => Mage::helper('core')->currency($product->getPrice(), true, false),
116
+ 'qty' => $item->getQty(),
117
+ 'parent_id' => $parentIds
118
+ );
119
+ }
120
+ elseif($product->getTypeId() == 'grouped')
121
+ {
122
+ $GroupedProductsResult = array();
123
+ $simpleProducts = $load->getTypeInstance(true)->getAssociatedProducts($load);
124
+ foreach ($simpleProducts as $item)
125
+ {
126
+ $GroupedProductsResult['grouped'][$item->getId()] = $item->getQty();
127
+ }
128
+ $productsResult[] = array( // Basic product data
129
+ 'product_id' => $product->getId(),
130
+ 'sku' => $product->getSku(),
131
+ 'name' => $product->getName(),
132
+ 'set' => $product->getAttributeSetId(),
133
+ 'type' => $product->getTypeId(),
134
+ 'grouped' => $GroupedProductsResult,
135
+ 'category_ids' => $product->getCategoryIds(),
136
+ 'website_ids' => $product->getWebsiteIds(),
137
+ 'image_url' => $cropped_image_url,
138
+ 'price' => Mage::helper('core')->currency($product->getPrice()*$item->getQty(), true, false),
139
+ 'orginal_price' => Mage::helper('core')->currency($product->getPrice(), true, false),
140
+ 'qty' => $item->getQty(),
141
+ 'parent_id' => $parentIds
142
+ );
143
+ }
144
+ else
145
+ {
146
+ $productsResult[] = array( // Basic product data
147
+ 'product_id' => $product->getId(),
148
+ 'sku' => $product->getSku(),
149
+ 'name' => $product->getName(),
150
+ 'set' => $product->getAttributeSetId(),
151
+ 'type' => $product->getTypeId(),
152
+ 'category_ids' => $product->getCategoryIds(),
153
+ 'website_ids' => $product->getWebsiteIds(),
154
+ 'image_url' => $cropped_image_url,
155
+ 'price' => Mage::helper('core')->currency($product->getPrice()*$item->getQty(), true, false),
156
+ 'orginal_price' => Mage::helper('core')->currency($product->getPrice(), true, false),
157
+ 'qty' => $item->getQty(),
158
+ 'parent_id' => $parentIds
159
+ );
160
+ }
161
+ }
162
+
163
+ return $productsResult;
164
+ }
165
+ }
166
+
app/code/local/EmizenTech/MagentoApi/Model/Observer.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Observer
3
+ {
4
+
5
+ public function RunWizard(Varien_Event_Observer $observer)
6
+ {
7
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api'))
8
+ return;
9
+
10
+ $cmsModelBanner = Mage::getModel('cms/block')->load('home-banner');
11
+
12
+ if(!$cmsModelBanner->getId()) //Returns true if does not exist.
13
+ {
14
+ $block = Mage::getModel('cms/block');
15
+ $block->setTitle('Home Banner');
16
+ $block->setIdentifier('home-banner');
17
+ $block->setStores(0);
18
+ $block->setIsActive(1);
19
+ $block->setContent('<ul class="promos"><li><a href="{{config path="web/secure/base_url"}}home-decor.html"><img src="{{media url="wysiwyg/homepage-three-column-promo-01B.png"}}" alt="Physical &amp; Virtual Gift Cards" /></a></li><li><a href="{{config path="web/secure/base_url"}}vip.html"><img src="{{media url="wysiwyg/homepage-three-column-promo-02.png"}}" alt="Shop Private Sales - Members Only" /></a></li><li><a href="{{config path="web/secure/base_url"}}accessories/bags-luggage.html"><img src="{{media url="wysiwyg/homepage-three-column-promo-03.png"}}" alt="Travel Gear for Every Occasion" /></a></li></ul>');
20
+ $block->save();
21
+
22
+ // check and create directory
23
+ /*$folder_obj = new Varien_Io_File();
24
+ $check_exits = Mage::getBaseDir('media').'/wysiwyg/promo-cards';
25
+ if(!is_dir($check_exits))
26
+ {
27
+ $folder_obj->mkdir(Mage::getBaseDir('media').'/wysiwyg/promo-cards');
28
+ }
29
+ else
30
+ {
31
+ die('Error: Directory already exists');
32
+ }*/
33
+ }
34
+
35
+ $cmsModelSlider = Mage::getModel('cms/block')->load('home-slider');
36
+
37
+ if(!$cmsModelSlider->getId()) //Returns true if does not exist.
38
+ {
39
+ // check and create static block
40
+ $block_slider = Mage::getModel('cms/block');
41
+ $block_slider->setTitle('Home Slider');
42
+ $block_slider->setIdentifier('home-slider');
43
+ $block_slider->setStores(0);
44
+ $block_slider->setIsActive(1);
45
+ $block_slider->setContent('<ul class="slideshow"><li><a href="{{config path="web/secure/base_url"}}accessories/eyewear.html"><img src="{{media url="wysiwyg/slide-1.jpg"}}" alt="An eye for detail - Click to Shop Eye Wear" /></a></li><li><a href="{{config path="web/secure/base_url"}}women.html"><img src="{{media url="wysiwyg/slide-2.jpg"}}" alt="Style solutions - covet-worthy styles in travel-friendly fabrics - Click to Shop Woman" /></a></li><li><a href="{{config path="web/secure/base_url"}}men.html"><img src="{{media url="wysiwyg/slide-3.jpg"}}" alt="Wing man - hit the runway in stylish separates and casuals - Click to Shop Man" /></a></li></ul>');
46
+ $block_slider->save();
47
+
48
+ // check and create directory
49
+ /*$folder_obj = new Varien_Io_File();
50
+ $check_exits = Mage::getBaseDir('media').'/wysiwyg/home-slide';
51
+ if(!is_dir($check_exits))
52
+ {
53
+ $folder_obj->mkdir(Mage::getBaseDir('media').'/wysiwyg/home-slide');
54
+ }
55
+ else
56
+ {
57
+ die('Error: Directory already exists');
58
+ }*/
59
+
60
+ // check if home cms page exists then will be modify from this content because above creating static block and directory
61
+ $cms_page = Mage::getModel('cms/page');
62
+ $cms_page->load('home', 'identifier');
63
+ $cms_page->setContent('<div class="slideshow-container">{{block type="cms/block" block_id="home-slider"}}<div class="slideshow-pager">&nbsp;</div><span class="slideshow-prev">&nbsp;</span> <span class="slideshow-next">&nbsp;</span></div> {{block type="cms/block" block_id="home-banner"}}');
64
+ $cms_page->save();
65
+ }
66
+ }
67
+
68
+ }
app/code/local/EmizenTech/MagentoApi/Model/Sales/Order/Api.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api
3
+ {
4
+ /**
5
+ * Retrieve full order information
6
+ *
7
+ * @param string $orderIncrementId
8
+ * @return array
9
+ */
10
+ public function info($orderIncrementId)
11
+ {
12
+ $order = $this->_initOrder($orderIncrementId);
13
+
14
+ if ($order->getGiftMessageId() > 0) {
15
+ $order->setGiftMessage(
16
+ Mage::getSingleton('giftmessage/message')->load($order->getGiftMessageId())->getMessage()
17
+ );
18
+ }
19
+
20
+ $result = $this->_getAttributes($order, 'order');
21
+
22
+ $result['shipping_address'] = $this->_getAttributes($order->getShippingAddress(), 'order_address');
23
+ $result['billing_address'] = $this->_getAttributes($order->getBillingAddress(), 'order_address');
24
+ $result['items'] = array();
25
+
26
+ foreach ($order->getAllItems() as $item) {
27
+ if ($item->getGiftMessageId() > 0) {
28
+ $item->setGiftMessage(
29
+ Mage::getSingleton('giftmessage/message')->load($item->getGiftMessageId())->getMessage()
30
+ );
31
+ }
32
+
33
+ $loadCollection = Mage::getModel('catalog/product')->load($item->getProductId());
34
+ $cropped_image_url = (string)Mage::helper('catalog/image')->init($loadCollection, 'image')->resize(100);
35
+
36
+ $item['image'] = $cropped_image_url;
37
+
38
+ $result['items'][] = $this->_getAttributes($item, 'order_item');
39
+ }
40
+
41
+
42
+ $result['payment'] = $this->_getAttributes($order->getPayment(), 'order_payment');
43
+
44
+ $result['status_history'] = array();
45
+
46
+ foreach ($order->getAllStatusHistory() as $history) {
47
+ $result['status_history'][] = $this->_getAttributes($history, 'order_status_history');
48
+ }
49
+
50
+ return $result;
51
+ }
52
+ }
53
+
app/code/local/EmizenTech/MagentoApi/controllers/IndexController.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EmizenTech_MagentoApi_IndexController extends Mage_Core_Controller_Front_Action{
3
+
4
+ protected $login_user = "emizentech"; //In the backend create user then put here. :go to Admin System > Web Services > SOAP/XML-RPC - Users
5
+ protected $login_password = "123456"; //Put here API Key of particular user when you will create user above.
6
+
7
+ /*
8
+ * Important: While you creating user dont forget to assign the user role.
9
+ * User role: go to Admin System > Web Services > SOAP/XML-RPC - Roles
10
+ * In the role section you have to also assign role users
11
+ */
12
+
13
+ /*public function IndexAction() {
14
+
15
+ $this->loadLayout();
16
+ $this->getLayout()->getBlock("head")->setTitle($this->__("Magento Api"));
17
+ $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
18
+ $breadcrumbs->addCrumb("home", array(
19
+ "label" => $this->__("Home Page"),
20
+ "title" => $this->__("Home Page"),
21
+ "link" => Mage::getBaseUrl()
22
+ ));
23
+
24
+ $breadcrumbs->addCrumb("magento api", array(
25
+ "label" => $this->__("Magento Api"),
26
+ "title" => $this->__("Magento Api")
27
+ ));
28
+
29
+ $this->renderLayout();
30
+
31
+ }*/
32
+
33
+ /*
34
+ * @ For checking we have make test function, you can direct hit: YOUR_MAGENTO_URL/emizenstore/magentoapi/index/test then check output of your created api's
35
+ */
36
+ public function testAction() {
37
+
38
+ if(!Mage::getStoreConfig('emizen_api/emizen_api/emizen_api')) // if not enable extension return false
39
+ return;
40
+
41
+ try
42
+ {
43
+ $client = new SoapClient(Mage::getBaseUrl().'api/soap/?wsdl'); // shop api class with magento root URL
44
+ $session = $client->login($this->login_user, $this->login_password); // login api with user and password to get session id
45
+
46
+ // Edit and modufy default home cms page
47
+ //$date = $client->call($session, 'magentoapi_api.run');
48
+
49
+ // Home Slider Images Api
50
+ //$date = $client->call($session, 'magentoapi_api.homeslides');
51
+
52
+ // Home Banner Images Api
53
+ //$date = $client->call($session, 'magentoapi_api.homebanner');
54
+
55
+ // Home Page New Products Api
56
+ //$date = $client->call($session, 'magentoapi_api.newproducts');
57
+
58
+ // Get Footer Links
59
+ //$date = $client->call($session, 'magentoapi_api.footercmsmenu', array('company'));
60
+
61
+ // Get Product According To Category Id
62
+ //$date = $client->call($session, 'magentoapi_api.productsbycategoryid', array('catId'=>'15','sort_order'=>'name','dir'=>'DESC'));
63
+
64
+ // Get Product According To Product Id
65
+ //$date = $client->call($session, 'magentoapi_api.productdetailbyid', array('421'));
66
+
67
+ /*$collection = Mage::getModel('catalog/product')->load('883');
68
+
69
+ // showing configurable products attributes like size,color,shoe size etc.
70
+ if($collection->getData('type_id') == 'configurable') // check if product type is configurable or not
71
+ {
72
+ $productAttributeOptions = $collection->getTypeInstance(true)->getConfigurableAttributesAsArray($collection);
73
+ foreach($productAttributeOptions as $_attribute)
74
+ {
75
+ foreach($_attribute['values'] as $attribute)
76
+ {
77
+ $product['configurable'][$_attribute['label']][$attribute['value_index']] = $attribute['store_label'];
78
+ echo "<pre>"; print_r($attribute);
79
+ }
80
+ }
81
+ }*/
82
+
83
+ // Add To Product In Wishlist
84
+ //$date = $client->call($session, 'magentoapi_api.wishlistadd', array('138','399'));
85
+
86
+ // Newsletter
87
+ //$date = $client->call($session, 'magentoapi_api.newsletter', array('kk@kk.com'));
88
+
89
+ // Contact Form Api
90
+ //$date = $client->call($session, 'magentoapi_api.contact', array('dfsdfs','navneetsharma748@gmail.com','23423','asdasdas'));
91
+
92
+ // Create cart
93
+ //$cart_id = $client->call($session, 'cart.create',array('1'));
94
+
95
+ // add to cart: array configurable products parameter
96
+ /*$arrProducts = array(
97
+ array(
98
+ "product_id" =>"421",
99
+ "qty" => 1,
100
+ "super_attribute" => array(
101
+ 180 => 79,
102
+ 92 => 22, // 92 is option id and 22 is option value
103
+ )
104
+ )
105
+ );*/
106
+
107
+ // add to cart: array grouped products parameter
108
+ /*$arrProducts = array(
109
+ array(
110
+ "product_id" =>"555",
111
+ "qty" => 1,
112
+ "super_group" => array(
113
+ 92 => 1, // 92 is product id and 1 is quantity
114
+
115
+ )
116
+ )
117
+ );*/
118
+
119
+ /*$arrProducts = array(
120
+ array(
121
+ "product_id" =>"554",
122
+ "qty" => 1,
123
+ )
124
+ );*/
125
+
126
+ // add product in the cart(quote)
127
+ //$date6 = $client->call($session, 'cart_product.add', array('749',$arrProducts,'1'));
128
+
129
+ //Product remove to cart(quote)
130
+ //$date1 = $client->call($session, 'cart_product.remove', array('749',$arrProducts,'1'));
131
+
132
+ // cart(quote) number of product lists
133
+ //$date = $client->call($session, 'cart_product.list', array('749','1'));
134
+
135
+ // add to wishlist
136
+ //$date = $client->call($session, 'magentoapi_api.wishlistadd', array('140','553'));
137
+
138
+
139
+
140
+ echo "<pre>"; print_r($date); die;
141
+ //echo $date;
142
+ //echo $cart_id;
143
+
144
+ }
145
+ catch(Exception $e)
146
+ {
147
+ echo '<pre>'; print_r($e);
148
+ }
149
+
150
+ }
151
+ }
app/code/local/EmizenTech/MagentoApi/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <emizen_api translate="title" module="magentoapi">
12
+ <title>Api Section</title>
13
+ <sort_order>0</sort_order>
14
+ </emizen_api>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/local/EmizenTech/MagentoApi/etc/api.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <api>
4
+ <resources>
5
+ <magentoapi_api translate="title" module="magentoapi">
6
+ <title>Myapi</title>
7
+ <acl>magentoapi/api</acl>
8
+ <model>magentoapi/api</model>
9
+ <methods>
10
+ <homeslides translate="title" module="magentoapi">
11
+ <title>Home Slides</title>
12
+ <acl>magentoapi/homeslides</acl>
13
+ </homeslides>
14
+ <homebanner translate="title" module="magentoapi">
15
+ <title>Home Banner</title>
16
+ <acl>magentoapi/homebanner</acl>
17
+ </homebanner>
18
+ <newproducts translate="title" module="magentoapi">
19
+ <title>New Products</title>
20
+ <acl>magentoapi/newproducts</acl>
21
+ </newproducts>
22
+ <productdetailbyid translate="title" module="magentoapi">
23
+ <title>Product Detail By Id</title>
24
+ <acl>magentoapi/productdetailbyid</acl>
25
+ </productdetailbyid>
26
+ <productsbycategoryid translate="title" module="magentoapi">
27
+ <title>Product Detail By Category Id</title>
28
+ <acl>magentoapi/productsbycategoryid</acl>
29
+ </productsbycategoryid>
30
+ <getcustomerid translate="title" module="magentoapi">
31
+ <title>Get Customer Id</title>
32
+ <acl>magentoapi/getcustomerid</acl>
33
+ </getcustomerid>
34
+ <relatedproducts translate="title" module="magentoapi">
35
+ <title>Related Products</title>
36
+ <acl>magentoapi/relatedproducts</acl>
37
+ </relatedproducts>
38
+ <getcmspagecontent translate="title" module="magentoapi">
39
+ <title>Get CMS Page Content</title>
40
+ <acl>magentoapi/getcmspagecontent</acl>
41
+ </getcmspagecontent>
42
+ <newsletter translate="title" module="magentoapi">
43
+ <title>Newsletter</title>
44
+ <acl>magentoapi/newsletter</acl>
45
+ </newsletter>
46
+ <contact translate="title" module="magentoapi">
47
+ <title>Contact</title>
48
+ <acl>magentoapi/contact</acl>
49
+ </contact>
50
+ <wishlistadd translate="title" module="magentoapi">
51
+ <title>WishList Add</title>
52
+ <acl>magentoapi/wishlistadd</acl>
53
+ </wishlistadd>
54
+ <wishlistdelete translate="title" module="magentoapi">
55
+ <title>WishList Delete</title>
56
+ <acl>magentoapi/wishlistdelete</acl>
57
+ </wishlistdelete>
58
+ <wishlistview translate="title" module="magentoapi">
59
+ <title>WishList Delete</title>
60
+ <acl>magentoapi/wishlistview</acl>
61
+ </wishlistview>
62
+ </methods>
63
+ </magentoapi_api>
64
+ </resources>
65
+ <acl>
66
+ <resources>
67
+ <magentoapi translate="title" module="magentoapi">
68
+ <title>MagentoApi</title>
69
+ <sort_order>2000</sort_order>
70
+ <homeslides translate="title" module="magentoapi">
71
+ <title>Home Slides</title>
72
+ </homeslides>
73
+ <homebanner translate="title" module="magentoapi">
74
+ <title>Home Banner</title>
75
+ </homebanner>
76
+ <newproducts translate="title" module="magentoapi">
77
+ <title>New Products</title>
78
+ </newproducts>
79
+ <productdetailbyid translate="title" module="magentoapi">
80
+ <title>Product Detail By Id</title>
81
+ </productdetailbyid>
82
+ <productsbycategoryid translate="title" module="magentoapi">
83
+ <title>Product Detail By Category Id</title>
84
+ </productsbycategoryid>
85
+ <getcustomerid translate="title" module="magentoapi">
86
+ <title>Get Customer Id</title>
87
+ </getcustomerid>
88
+ <relatedproducts translate="title" module="magentoapi">
89
+ <title>Related Products</title>
90
+ </relatedproducts>
91
+ <getcmspagecontent translate="title" module="magentoapi">
92
+ <title>Get CMS Page Content</title>
93
+ </getcmspagecontent>
94
+ <newsletter translate="title" module="magentoapi">
95
+ <title>Newsletter</title>
96
+ </newsletter>
97
+ <contact translate="title" module="magentoapi">
98
+ <title>Contact</title>
99
+ </contact>
100
+ <wishlistadd translate="title" module="magentoapi">
101
+ <title>WishList Add</title>
102
+ </wishlistadd>
103
+ <wishlistdelete translate="title" module="magentoapi">
104
+ <title>WishList Delete</title>
105
+ </wishlistdelete>
106
+ <wishlistview translate="title" module="magentoapi">
107
+ <title>WishList Delete</title>
108
+ </wishlistview>
109
+ </magentoapi>
110
+ </resources>
111
+ </acl>
112
+ </api>
113
+ </config>
app/code/local/EmizenTech/MagentoApi/etc/config.xml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <EmizenTech_MagentoApi>
5
+ <version>0.1.0</version>
6
+ </EmizenTech_MagentoApi>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <magentoapi>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>EmizenTech_MagentoApi</module>
14
+ <frontName>magentoapi</frontName>
15
+ </args>
16
+ </magentoapi>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <magentoapi>
21
+ <file>magentoapi.xml</file>
22
+ </magentoapi>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <helpers>
28
+ <magentoapi>
29
+ <class>EmizenTech_MagentoApi_Helper</class>
30
+ </magentoapi>
31
+ </helpers>
32
+ <blocks>
33
+ <magentoapi>
34
+ <class>EmizenTech_MagentoApi_Block</class>
35
+ </magentoapi>
36
+ </blocks>
37
+ <models>
38
+ <magentoapi>
39
+ <class>EmizenTech_MagentoApi_Model</class>
40
+ <resourceModel>magentoapi_mysql4</resourceModel>
41
+ </magentoapi>
42
+ <checkout>
43
+ <rewrite>
44
+ <cart_product_api>EmizenTech_MagentoApi_Model_Checkout_Cart_Product_Api</cart_product_api>
45
+ <cart_api>EmizenTech_MagentoApi_Model_Checkout_Cart_Api</cart_api>
46
+ <cart_customer_api>EmizenTech_MagentoApi_Model_Checkout_Cart_Customer_Api</cart_customer_api>
47
+ </rewrite>
48
+ </checkout>
49
+ <catalog>
50
+ <rewrite>
51
+ <product_api>EmizenTech_MagentoApi_Model_Catalog_Product_Api</product_api>
52
+ <!-- <category_api>EmizenTech_MagentoApi_Model_Catalog_Category_Api</category_api> -->
53
+ </rewrite>
54
+ </catalog>
55
+ <sales>
56
+ <rewrite>
57
+ <order_api>EmizenTech_MagentoApi_Model_Sales_Order_Api</order_api>
58
+ </rewrite>
59
+ </sales>
60
+ </models>
61
+ <events>
62
+ <controller_action_layout_generate_blocks_after> <!-- identifier of the event we want to catch -->
63
+ <observers>
64
+ <controller_action_layout_generate_blocks_after_handler> <!-- identifier of the event handler -->
65
+ <type>model</type> <!-- class method call type; valid are model, object and singleton -->
66
+ <class>magentoapi/observer</class> <!-- observers class alias -->
67
+ <method>RunWizard</method> <!-- observer's method to be called -->
68
+ <args></args> <!-- additional arguments passed to observer -->
69
+ </controller_action_layout_generate_blocks_after_handler>
70
+ </observers>
71
+ </controller_action_layout_generate_blocks_after>
72
+ </events>
73
+ </global>
74
+ </config>
app/code/local/EmizenTech/MagentoApi/etc/system.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <emizen_api translate="label" module="magentoapi">
5
+ <label>Magento Api</label>
6
+ <sort_order>0</sort_order>
7
+ </emizen_api>
8
+ </tabs>
9
+ <sections>
10
+ <emizen_api translate="label" module="magentoapi">
11
+ <label>Api</label>
12
+ <tab>emizen_api</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>0</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <emizen_api translate="label">
20
+ <label>Magento Api</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>0</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <emizen_api translate="label">
28
+ <label>Enable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </emizen_api>
36
+ </fields>
37
+ </emizen_api>
38
+ </groups>
39
+ </emizen_api>
40
+ </sections>
41
+ </config>
app/etc/modules/EmizenTech_MagentoApi.xml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <EmizenTech_MagentoApi>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Api />
9
+ </depends>
10
+ <version>0.1.0</version>
11
+ </EmizenTech_MagentoApi>
12
+ </modules>
13
+ </config>
package.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EmizenTech_Mobile</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This module will make your catalog available for mobile app</summary>
10
+ <description>Using this module you can sell your products on mobiles gadgets. Install this module and download app from iTune store, create an api user name and password to configure both. &#xD;
11
+ &#xD;
12
+ Your catalog will be appear on mobile. </description>
13
+ <notes>Using this module you can sell your products on mobiles gadgets. Install this module and download app from iTune store, create an api user name and password to configure both. &#xD;
14
+ &#xD;
15
+ Your catalog will be appear on mobile. </notes>
16
+ <authors><author><name>Emizen Tech Private Limited</name><user>emizen</user><email>info@emizentech.com</email></author></authors>
17
+ <date>2015-02-11</date>
18
+ <time>12:14:52</time>
19
+ <contents><target name="mageetc"><dir name="modules"><file name="EmizenTech_MagentoApi.xml" hash="45064c0b64da9d6250ed06f5c956d99c"/></dir></target><target name="magelocal"><dir name="EmizenTech"><dir name="MagentoApi"><dir name="Block"><file name="Index.php" hash="a3a9f7ed857a3ca2d17f6499d3c7e30b"/></dir><dir name="Helper"><file name="Data.php" hash="3ae5ace47f68f7c5591ae23d9db277ba"/></dir><dir name="Model"><file name="Api.php" hash="370b5c401669bcd283d2e202355c73a4"/><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="a3830ddd48a2551df6aeb7de5a8bb38c"/></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Api.php" hash="ccddf5ec4862a6e266a9de17a64dac4b"/><dir name="Customer"><file name="Api.php" hash="2a5da3103d61786dfafe769c31e0ad11"/></dir><dir name="Product"><file name="Api.php" hash="1dd7c7413b751cccb075c4de87135259"/></dir></dir></dir><file name="Observer.php" hash="ec5c5be17ec6888019795622ca9bc90b"/><dir name="Sales"><dir name="Order"><file name="Api.php" hash="b80cad64588f39c9393e1ac4e3fac7dd"/></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="e5924eedd3a6d2867df344805fc7203b"/></dir><dir name="etc"><file name="adminhtml.xml" hash="b59d6e1965a783262aaf69e988dc2d7d"/><file name="api.xml" hash="8e32063047e6a3c9e3a1705e8f225fbf"/><file name="config.xml" hash="1d63ab9713cb7231ef92aa2aab0aacf9"/><file name="system.xml" hash="2f8eff42fd87d9f92da8c74ca1296470"/></dir></dir></dir></target></contents>
20
+ <compatible/>
21
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
22
+ </package>