Version Notes
Contus M-Comm, a ready to go solution to build native Magento mobile apps for your store across all devices.
Download this release
Release Info
Developer | contus |
Extension | Contus_Mcomm |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Contus/Configuration/Block/Adminhtml/About.php +71 -0
- app/code/local/Contus/Configuration/Helper/Data.php +30 -0
- app/code/local/Contus/Configuration/Model/Adminhtml/Count.php +56 -0
- app/code/local/Contus/Configuration/Model/Adminhtml/Homelist.php +50 -0
- app/code/local/Contus/Configuration/Model/Config.php +52 -0
- app/code/local/Contus/Configuration/etc/adminhtml.xml +16 -0
- app/code/local/Contus/Configuration/etc/config.xml +57 -0
- app/code/local/Contus/Configuration/etc/system.xml +167 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers.php +49 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit.php +77 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Form.php +50 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tab/Form.php +128 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tab/Productlist.php +139 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tabs.php +61 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Grid.php +187 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/Image.php +53 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/Notification.php +52 -0
- app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/View.php +57 -0
- app/code/local/Contus/Offers/Block/Offers.php +45 -0
- app/code/local/Contus/Offers/Helper/Data.php +30 -0
- app/code/local/Contus/Offers/Model/Mysql4/Offers.php +40 -0
- app/code/local/Contus/Offers/Model/Mysql4/Offers/Collection.php +40 -0
- app/code/local/Contus/Offers/Model/Offers.php +41 -0
- app/code/local/Contus/Offers/Model/Status.php +44 -0
- app/code/local/Contus/Offers/controllers/Adminhtml/OffersController.php +525 -0
- app/code/local/Contus/Offers/controllers/IndexController.php +40 -0
- app/code/local/Contus/Offers/etc/adminhtml.xml +16 -0
- app/code/local/Contus/Offers/etc/config.xml +108 -0
- app/code/local/Contus/Offers/sql/offers_setup/mysql4-install-0.1.0.php +55 -0
- app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders.php +39 -0
- app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Edit.php +67 -0
- app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Grid.php +177 -0
- app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Renderer/Notification.php +53 -0
- app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Renderer/View.php +51 -0
- app/code/local/Contus/Pushnoteorders/Block/Pushnoteorders.php +39 -0
- app/code/local/Contus/Pushnoteorders/Helper/Data.php +30 -0
- app/code/local/Contus/Pushnoteorders/controllers/Adminhtml/PushnoteordersController.php +282 -0
- app/code/local/Contus/Pushnoteorders/controllers/IndexController.php +34 -0
- app/code/local/Contus/Pushnoteorders/etc/adminhtml.xml +18 -0
- app/code/local/Contus/Pushnoteorders/etc/config.xml +81 -0
- app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts.php +39 -0
- app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Edit.php +67 -0
- app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Grid.php +161 -0
- app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Renderer/Notification.php +57 -0
- app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Renderer/View.php +57 -0
- app/code/local/Contus/Pushnoteproducts/Block/Pushnoteproducts.php +39 -0
- app/code/local/Contus/Pushnoteproducts/Helper/Data.php +30 -0
- app/code/local/Contus/Pushnoteproducts/controllers/Adminhtml/PushnoteproductsController.php +282 -0
- app/code/local/Contus/Pushnoteproducts/controllers/IndexController.php +34 -0
- app/code/local/Contus/Pushnoteproducts/etc/config.xml +99 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest.php +30 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBookapi.php +411 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/Country.php +57 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Admin/V1.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Customer/V1.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Guest/V1.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/State.php +50 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest/Admin/V1.php +31 -0
- app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest/Guest/V1.php +31 -0
- app/code/local/ContusRestapi/AddressBook/etc/api2.xml +231 -0
- app/code/local/ContusRestapi/AddressBook/etc/config.xml +15 -0
- app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest.php +30 -0
- app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCouponapi.php +329 -0
- app/code/local/ContusRestapi/ApplyCoupon/etc/api2.xml +66 -0
- app/code/local/ContusRestapi/ApplyCoupon/etc/config.xml +15 -0
- app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi.php +119 -0
- app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest.php +30 -0
- app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/CartAddressapi/etc/api2.xml +65 -0
- app/code/local/ContusRestapi/CartAddressapi/etc/config.xml +15 -0
- app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi.php +652 -0
- app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest.php +30 -0
- app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Cartapi/etc/api2.xml +94 -0
- app/code/local/ContusRestapi/Cartapi/etc/config.xml +15 -0
- app/code/local/ContusRestapi/Filters/Model/Api2/Filters.php +303 -0
- app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest.php +30 -0
- app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Filters/etc/api2.xml +50 -0
- app/code/local/ContusRestapi/Filters/etc/config.xml +15 -0
- app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi.php +619 -0
- app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest.php +30 -0
- app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/HomePageapi/etc/api2.xml +63 -0
- app/code/local/ContusRestapi/HomePageapi/etc/config.xml +15 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword.php +109 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Login.php +175 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Login/Model/Methods/Functions.php +152 -0
- app/code/local/ContusRestapi/Login/Model/Resource/Token.php +35 -0
- app/code/local/ContusRestapi/Login/Model/Resource/Token/Collection.php +36 -0
- app/code/local/ContusRestapi/Login/Model/Token.php +737 -0
- app/code/local/ContusRestapi/Login/etc/api2.xml +109 -0
- app/code/local/ContusRestapi/Login/etc/config.xml +39 -0
- app/code/local/ContusRestapi/Login/sql/login_setup/install-0.0.1.php +39 -0
- app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi.php +413 -0
- app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest.php +30 -0
- app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/MultiCartapi/etc/api2.xml +89 -0
- app/code/local/ContusRestapi/MultiCartapi/etc/config.xml +15 -0
- app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi.php +427 -0
- app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest.php +30 -0
- app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/MyOrders/etc/api2.xml +184 -0
- app/code/local/ContusRestapi/MyOrders/etc/config.xml +15 -0
- app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi.php +322 -0
- app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest.php +30 -0
- app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/PlaceOrder/etc/api2.xml +62 -0
- app/code/local/ContusRestapi/PlaceOrder/etc/config.xml +15 -0
- app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest.php +770 -0
- app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest/Admin/V1.php +33 -0
- app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest/Guest/V1.php +33 -0
- app/code/local/ContusRestapi/ProductList/etc/api2.xml +194 -0
- app/code/local/ContusRestapi/ProductList/etc/config.xml +24 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest.php +98 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest.php +272 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Registration/etc/api2.xml +158 -0
- app/code/local/ContusRestapi/Registration/etc/config.xml +16 -0
- app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating.php +220 -0
- app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest.php +30 -0
- app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/ReviewRating/etc/api2.xml +66 -0
- app/code/local/ContusRestapi/ReviewRating/etc/config.xml +15 -0
- app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts.php +248 -0
- app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest.php +30 -0
- app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/SearchProducts/etc/api2.xml +55 -0
- app/code/local/ContusRestapi/SearchProducts/etc/config.xml +15 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi.php +105 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest.php +30 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/etc/api2.xml +58 -0
- app/code/local/ContusRestapi/ShippingPaymentapi/etc/config.xml +15 -0
- app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin.php +180 -0
- app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest.php +30 -0
- app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/SocialLogin/etc/api2.xml +64 -0
- app/code/local/ContusRestapi/SocialLogin/etc/config.xml +15 -0
- app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages.php +78 -0
- app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest.php +30 -0
- app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Staticpages/etc/api2.xml +47 -0
- app/code/local/ContusRestapi/Staticpages/etc/config.xml +15 -0
- app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist.php +448 -0
- app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest.php +30 -0
- app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Admin/V1.php +30 -0
- app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Customer/V1.php +30 -0
- app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Guest/V1.php +30 -0
- app/code/local/ContusRestapi/Wishlistapi/etc/api2.xml +76 -0
- app/code/local/ContusRestapi/Wishlistapi/etc/config.xml +15 -0
- app/design/adminhtml/default/default/layout/offers.xml +9 -0
- app/design/adminhtml/default/default/layout/pushnoteorders.xml +9 -0
- app/design/adminhtml/default/default/layout/pushnoteproducts.xml +9 -0
- app/design/adminhtml/default/default/template/offers/offers.phtml +89 -0
- app/design/adminhtml/default/default/template/pushnoteorders/pushnoteorders.phtml +90 -0
- app/design/adminhtml/default/default/template/pushnoteproducts/pushnoteproducts.phtml +88 -0
- app/etc/modules/ContusRestapi_AddressBook.xml +9 -0
- app/etc/modules/ContusRestapi_ApplyCoupon.xml +9 -0
- app/etc/modules/ContusRestapi_CartAddressapi.xml +9 -0
- app/etc/modules/ContusRestapi_Cartapi.xml +9 -0
- app/etc/modules/ContusRestapi_Filters.xml +9 -0
- app/etc/modules/ContusRestapi_HomePageapi.xml +9 -0
- app/etc/modules/ContusRestapi_Login.xml +9 -0
- app/etc/modules/ContusRestapi_MultiCartapi.xml +9 -0
- app/etc/modules/ContusRestapi_MyOrders.xml +9 -0
- app/etc/modules/ContusRestapi_PlaceOrder.xml +9 -0
- app/etc/modules/ContusRestapi_ProductList.xml +9 -0
- app/etc/modules/ContusRestapi_Registration.xml +9 -0
- app/etc/modules/ContusRestapi_ReviewRating.xml +9 -0
- app/etc/modules/ContusRestapi_SearchProducts.xml +9 -0
- app/etc/modules/ContusRestapi_ShippingPaymentapi.xml +9 -0
- app/etc/modules/ContusRestapi_SocialLogin.xml +9 -0
- app/etc/modules/ContusRestapi_Staticpages.xml +9 -0
- app/etc/modules/ContusRestapi_Wishlistapi.xml +9 -0
- app/etc/modules/Contus_Configuration.xml +9 -0
- app/etc/modules/Contus_Offers.xml +9 -0
- app/etc/modules/Contus_Pushnoteorders.xml +9 -0
- app/etc/modules/Contus_Pushnoteproducts.xml +9 -0
- contus/Mcom_development.pem +68 -0
- contus/Mcom_production.pem +68 -0
- contus/image/splash_logo.png +0 -0
- js/iframe/jquery-2.1.1.min.js +5 -0
- js/iframe/jquery.simplemodal.js +27 -0
- package.xml +19 -0
- paypal/PaymentGateway.php +197 -0
- paypal/Paypal.php +120 -0
- paypal/cancel.php +10 -0
- paypal/ipn.php +308 -0
- paypal/ipnlistener.php +315 -0
- paypal/redirect.php +154 -0
- paypal/success.php +51 -0
- rest/.htaccess +12 -0
- rest/Rest.inc.php +136 -0
- rest/api.php +1635 -0
- skin/adminhtml/default/default/popup.css +54 -0
app/code/local/Contus/Configuration/Block/Adminhtml/About.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Configuration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Configuration_Block_Adminhtml_About extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface {
|
30 |
+
/**
|
31 |
+
* Support tab
|
32 |
+
* version 2.0.0
|
33 |
+
*/
|
34 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
35 |
+
|
36 |
+
$logoLink = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, false ).'contus/image/splash_logo.png';
|
37 |
+
$helper = Mage::helper ( 'configuration' );
|
38 |
+
|
39 |
+
|
40 |
+
$html = '<style>
|
41 |
+
.line {border-top: 1px solid #c6c6c6; padding-top: 10px;}
|
42 |
+
.developer-label {color: #000000; font-weight:bold; width: 200px;}
|
43 |
+
.developer-text { padding-bottom: 15px;}
|
44 |
+
.developer {width: 600px; }
|
45 |
+
</style>';
|
46 |
+
|
47 |
+
$html .= '
|
48 |
+
<table cellspacing="0" cellpading="0" class="developer">
|
49 |
+
<tr>
|
50 |
+
<td class="developer-label "><img src="' . $logoLink . '" width="180px" > </td>
|
51 |
+
<td class="developer-text ">' . $helper->__ ( '<strong>version 2.1</strong> ' ) . '</td>
|
52 |
+
</tr>
|
53 |
+
<tr>
|
54 |
+
<td class="developer-label line">' . $helper->__ ( 'Extension:' ) . '</td>
|
55 |
+
<td class="developer-text line">' . $helper->__ ( ' version 1.0.0' ) . '</td>
|
56 |
+
</tr>
|
57 |
+
<tr>
|
58 |
+
<td class="developer-label line">' . $helper->__ ( 'License:' ) . '</td>
|
59 |
+
<td class="developer-text line">' . $helper->__ ( ' <a href="http://www.apptha.com/LICENSE.txt" target="_blank" >License</a>' ) . '</td>
|
60 |
+
</tr>
|
61 |
+
<tr>
|
62 |
+
<td class="developer-label line">' . $helper->__ ( 'Support:' ) . '</td>
|
63 |
+
<td class="developer-text line">' . $helper->__ ( 'Please, for request to Build Mobile applications, feature requests or report any bugs related to the Solution.<br>' . '<br><a href="http://www.contus.com/magento-mobile-app.php?utm_source=Mobile App for Magento � Contus M-Comm&utm_medium=CTA&utm_campaign=Magento Commerce#request_quote" target="_blank">Contact us</a>' ) . '</td>
|
64 |
+
</tr>
|
65 |
+
|
66 |
+
</table>';
|
67 |
+
|
68 |
+
return $html;
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
app/code/local/Contus/Configuration/Helper/Data.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Configuration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Configuration_Helper_Data extends Mage_Core_Helper_Abstract {
|
30 |
+
}
|
app/code/local/Contus/Configuration/Model/Adminhtml/Count.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php
|
3 |
+
/**
|
4 |
+
* Contus
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Configuration
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class Contus_Configuration_Model_Adminhtml_Count {
|
31 |
+
|
32 |
+
public function toOptionArray() {
|
33 |
+
return array (
|
34 |
+
array (
|
35 |
+
'value' => '1',
|
36 |
+
'label' => '1'
|
37 |
+
),
|
38 |
+
array (
|
39 |
+
'value' => '2',
|
40 |
+
'label' => '2'
|
41 |
+
),
|
42 |
+
array (
|
43 |
+
'value' => '3',
|
44 |
+
'label' => '3'
|
45 |
+
),
|
46 |
+
array (
|
47 |
+
'value' => '4',
|
48 |
+
'label' => '4'
|
49 |
+
),
|
50 |
+
array (
|
51 |
+
'value' => '5',
|
52 |
+
'label' => '5'
|
53 |
+
)
|
54 |
+
);
|
55 |
+
}
|
56 |
+
}
|
app/code/local/Contus/Configuration/Model/Adminhtml/Homelist.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php
|
3 |
+
/**
|
4 |
+
* Contus
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Configuration
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class Contus_Configuration_Model_Adminhtml_Homelist {
|
31 |
+
public function getCommentText() {
|
32 |
+
return "Some text here";
|
33 |
+
}
|
34 |
+
public function toOptionArray() {
|
35 |
+
return array (
|
36 |
+
array (
|
37 |
+
'value' => 'newarrivals',
|
38 |
+
'label' => 'New Arrivals'
|
39 |
+
),
|
40 |
+
array (
|
41 |
+
'value' => 'bestsellers',
|
42 |
+
'label' => 'Best sellers'
|
43 |
+
),
|
44 |
+
array (
|
45 |
+
'value' => 'offers',
|
46 |
+
'label' => 'Offers'
|
47 |
+
)
|
48 |
+
);
|
49 |
+
}
|
50 |
+
}
|
app/code/local/Contus/Configuration/Model/Config.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php
|
3 |
+
/**
|
4 |
+
* Contus
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Configuration
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class Contus_Configuration_Model_Config {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Change push notification mode
|
34 |
+
* true - live mode
|
35 |
+
* false - development mode
|
36 |
+
*
|
37 |
+
* @return boolean
|
38 |
+
*/
|
39 |
+
public function getNotificationMode() {
|
40 |
+
$response = array ();
|
41 |
+
$notificationMode = false;
|
42 |
+
|
43 |
+
if ($notificationMode) {
|
44 |
+
$pemfile = getcwd () . '/contus/Mcom_production.pem';
|
45 |
+
} else {
|
46 |
+
$pemfile = getcwd () . '/contus/Mcom_development.pem';
|
47 |
+
}
|
48 |
+
$response ['mode'] = $notificationMode;
|
49 |
+
$response ['pemfile'] = $pemfile;
|
50 |
+
return $response;
|
51 |
+
}
|
52 |
+
}
|
app/code/local/Contus/Configuration/etc/adminhtml.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
|
5 |
+
<pushnoteproducts>
|
6 |
+
<children>
|
7 |
+
<contus_configuration translate="title" module="configuration">
|
8 |
+
<sort_order>20</sort_order>
|
9 |
+
<title>Configuration</title>
|
10 |
+
<action>adminhtml/system_config/edit/section/contus/</action>
|
11 |
+
</contus_configuration >
|
12 |
+
</children>
|
13 |
+
</pushnoteproducts>
|
14 |
+
|
15 |
+
</menu>
|
16 |
+
</config>
|
app/code/local/Contus/Configuration/etc/config.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Configuration>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Contus_Configuration>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<configuration>
|
11 |
+
<class>Contus_Configuration_Model</class>
|
12 |
+
</configuration>
|
13 |
+
</models>
|
14 |
+
<blocks>
|
15 |
+
<configuration>
|
16 |
+
<class>Contus_Configuration_Block</class>
|
17 |
+
</configuration>
|
18 |
+
</blocks>
|
19 |
+
|
20 |
+
<helpers>
|
21 |
+
<configuration>
|
22 |
+
<class>Contus_Configuration_Helper</class>
|
23 |
+
</configuration>
|
24 |
+
</helpers>
|
25 |
+
</global>
|
26 |
+
<adminhtml>
|
27 |
+
<acl>
|
28 |
+
<resources>
|
29 |
+
<all>
|
30 |
+
<title>Allow Everything</title>
|
31 |
+
</all>
|
32 |
+
<admin>
|
33 |
+
<children>
|
34 |
+
<configuration translate="title" module="configuration">
|
35 |
+
<title>configuration</title>
|
36 |
+
<sort_order>1000</sort_order>
|
37 |
+
|
38 |
+
</configuration>
|
39 |
+
<system>
|
40 |
+
<children>
|
41 |
+
<config>
|
42 |
+
<children>
|
43 |
+
<contus>
|
44 |
+
<title>Allow Everything</title>
|
45 |
+
</contus>
|
46 |
+
</children>
|
47 |
+
</config>
|
48 |
+
</children>
|
49 |
+
</system>
|
50 |
+
</children>
|
51 |
+
</admin>
|
52 |
+
</resources>
|
53 |
+
</acl>
|
54 |
+
|
55 |
+
</adminhtml>
|
56 |
+
|
57 |
+
</config>
|
app/code/local/Contus/Configuration/etc/system.xml
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<contus translate="label" module="configuration">
|
5 |
+
<label>MCOMM App Configuration</label>
|
6 |
+
<sort_order>1500</sort_order>
|
7 |
+
</contus>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<contus translate="label" module="configuration">
|
11 |
+
<label>MCOMM App Configuration</label>
|
12 |
+
<tab>contus</tab>
|
13 |
+
<sort_order>1200</sort_order>
|
14 |
+
<show_in_default>1</show_in_default>
|
15 |
+
<show_in_website>1</show_in_website>
|
16 |
+
<show_in_store>1</show_in_store>
|
17 |
+
|
18 |
+
<groups>
|
19 |
+
|
20 |
+
<info translate="label">
|
21 |
+
<label>Information</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>1</sort_order>
|
24 |
+
<show_in_default>1</show_in_default>
|
25 |
+
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
+
<fields>
|
28 |
+
<support_information>
|
29 |
+
<frontend_model>configuration/adminhtml_about
|
30 |
+
</frontend_model>
|
31 |
+
<sort_order>1</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 |
+
</support_information>
|
36 |
+
</fields>
|
37 |
+
<expanded>1</expanded>
|
38 |
+
</info>
|
39 |
+
|
40 |
+
<mcomapp_about translate="label">
|
41 |
+
<label>MCOMM App</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>1</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
<expanded>1</expanded>
|
48 |
+
|
49 |
+
<fields>
|
50 |
+
<rest_apikey translate="label">
|
51 |
+
<label>Rest Key</label>
|
52 |
+
<frontend_type>text</frontend_type>
|
53 |
+
<sort_order>2</sort_order>
|
54 |
+
<show_in_default>1</show_in_default>
|
55 |
+
<show_in_website>0</show_in_website>
|
56 |
+
<show_in_store>0</show_in_store>
|
57 |
+
<validate>required-entry</validate>
|
58 |
+
|
59 |
+
<comment><![CDATA[<a href="http://inchoo.net/magento/configure-magento-rest-and-oauth-settings/" target="_blank">How to create key?</a>]]></comment>
|
60 |
+
</rest_apikey>
|
61 |
+
|
62 |
+
<rest_secretkey translate="label">
|
63 |
+
<label>Rest Secret </label>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>3</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>0</show_in_website>
|
68 |
+
<show_in_store>0</show_in_store>
|
69 |
+
<validate>required-entry</validate>
|
70 |
+
|
71 |
+
<comment><![CDATA[<a href="http://inchoo.net/magento/configure-magento-rest-and-oauth-settings/" target="_blank">How to create secret key?</a>]]></comment>
|
72 |
+
</rest_secretkey>
|
73 |
+
</fields>
|
74 |
+
</mcomapp_about>
|
75 |
+
|
76 |
+
<configuration_pushnotifications
|
77 |
+
translate="label">
|
78 |
+
<label>Push Notifications</label>
|
79 |
+
<frontend_type>text</frontend_type>
|
80 |
+
<sort_order>2</sort_order>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>1</show_in_store>
|
84 |
+
<fields>
|
85 |
+
|
86 |
+
<gcm_apikey translate="label">
|
87 |
+
<label>GCM Application Key</label>
|
88 |
+
<frontend_type>text</frontend_type>
|
89 |
+
<sort_order>1</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
|
94 |
+
<comment><![CDATA[<a href="https://code.google.com/apis/console" target="_blank">How to create GCM key?</a>]]></comment>
|
95 |
+
</gcm_apikey>
|
96 |
+
|
97 |
+
<product_pushnotification_enabled
|
98 |
+
translate="label">
|
99 |
+
<label>Push Notification for Product</label>
|
100 |
+
<frontend_type>select</frontend_type>
|
101 |
+
<source_model>adminhtml/system_config_source_enabledisable
|
102 |
+
</source_model>
|
103 |
+
<comment><![CDATA[Send push notification for each products manually.]]></comment>
|
104 |
+
<sort_order>3</sort_order>
|
105 |
+
<show_in_default>1</show_in_default>
|
106 |
+
<show_in_website>1</show_in_website>
|
107 |
+
<show_in_store>1</show_in_store>
|
108 |
+
</product_pushnotification_enabled>
|
109 |
+
|
110 |
+
<order_pushnotification_enabled
|
111 |
+
translate="label">
|
112 |
+
<label>Push Notification for Order</label>
|
113 |
+
<frontend_type>select</frontend_type>
|
114 |
+
<source_model>adminhtml/system_config_source_enabledisable
|
115 |
+
</source_model>
|
116 |
+
<comment><![CDATA[Send push notification for each orders manually.]]></comment>
|
117 |
+
<sort_order>4</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>1</show_in_store>
|
121 |
+
</order_pushnotification_enabled>
|
122 |
+
|
123 |
+
</fields>
|
124 |
+
<expanded>1</expanded>
|
125 |
+
</configuration_pushnotifications>
|
126 |
+
|
127 |
+
<configuration_home translate="label" module="configuration">
|
128 |
+
<label>Home Page Banner</label>
|
129 |
+
<frontend_type>text</frontend_type>
|
130 |
+
<sort_order>100</sort_order>
|
131 |
+
<show_in_default>1</show_in_default>
|
132 |
+
<show_in_website>1</show_in_website>
|
133 |
+
<show_in_store>1</show_in_store>
|
134 |
+
|
135 |
+
<fields>
|
136 |
+
<home_banner translate="label">
|
137 |
+
<label>Home Banner</label>
|
138 |
+
<frontend_type>select</frontend_type>
|
139 |
+
<source_model>configuration/adminhtml_homelist</source_model>
|
140 |
+
<comment><![CDATA[
|
141 |
+
New arrivals - Display products on banner based on the date.<br/>
|
142 |
+
Best Sellers - Display most sold products.<br/>
|
143 |
+
Offers - Display offers from offer module .
|
144 |
+
]]></comment>
|
145 |
+
<sort_order>1</sort_order>
|
146 |
+
<show_in_default>1</show_in_default>
|
147 |
+
<show_in_website>1</show_in_website>
|
148 |
+
<show_in_store>1</show_in_store>
|
149 |
+
</home_banner>
|
150 |
+
<banner_count translate="label">
|
151 |
+
<label>Home Banner Slider Count</label>
|
152 |
+
<frontend_type>select</frontend_type>
|
153 |
+
<source_model>configuration/adminhtml_count</source_model>
|
154 |
+
<comment><![CDATA[
|
155 |
+
Its affect on home page slider. If you select 5, 5 sliders will be display on home page.
|
156 |
+
]]></comment>
|
157 |
+
<sort_order>2</sort_order>
|
158 |
+
<show_in_default>1</show_in_default>
|
159 |
+
<show_in_website>1</show_in_website>
|
160 |
+
<show_in_store>1</show_in_store>
|
161 |
+
</banner_count>
|
162 |
+
</fields>
|
163 |
+
</configuration_home>
|
164 |
+
</groups>
|
165 |
+
</contus>
|
166 |
+
</sections>
|
167 |
+
</config>
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Constructor initializes the controller and blocks
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
$this->_controller = 'adminhtml_offers';
|
36 |
+
$this->_blockGroup = 'offers';
|
37 |
+
$this->_headerText = Mage::helper ( 'offers' )->__ ( 'Offers' );
|
38 |
+
$this->_addButtonLabel = Mage::helper ( 'offers' )->__ ( 'Add Offer' );
|
39 |
+
|
40 |
+
$this->_addButton('button1', array(
|
41 |
+
'label' => Mage::helper('offers')->__('Add Offer'),
|
42 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/checkCount') .'\')',
|
43 |
+
'class' => 'add',
|
44 |
+
));
|
45 |
+
|
46 |
+
parent::__construct ();
|
47 |
+
$this->_removeButton ( 'add' );
|
48 |
+
}
|
49 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialize controller, blockgroup and currently editable record id
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
parent::__construct ();
|
36 |
+
|
37 |
+
$this->_objectId = 'id';
|
38 |
+
$this->_blockGroup = 'offers';
|
39 |
+
$this->_controller = 'adminhtml_offers';
|
40 |
+
|
41 |
+
$this->_updateButton ( 'save', 'label', Mage::helper ( 'offers' )->__ ( 'Save Item' ) );
|
42 |
+
$this->_updateButton ( 'delete', 'label', Mage::helper ( 'offers' )->__ ( 'Delete Item' ) );
|
43 |
+
|
44 |
+
$this->_addButton ( 'saveandcontinue', array (
|
45 |
+
'label' => Mage::helper ( 'adminhtml' )->__ ( 'Save And Continue Edit' ),
|
46 |
+
'onclick' => 'saveAndContinueEdit()',
|
47 |
+
'class' => 'save'
|
48 |
+
), - 100 );
|
49 |
+
|
50 |
+
$this->_formScripts [] = "
|
51 |
+
function toggleEditor() {
|
52 |
+
if (tinyMCE.getInstanceById('offers_content') == null) {
|
53 |
+
tinyMCE.execCommand('mceAddControl', false, 'offers_content');
|
54 |
+
} else {
|
55 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'offers_content');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
function saveAndContinueEdit(){
|
60 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
61 |
+
}
|
62 |
+
";
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Set edit page header with offer title
|
67 |
+
*
|
68 |
+
* @return string Returns page header and Includes MCE
|
69 |
+
*/
|
70 |
+
public function getHeaderText() {
|
71 |
+
if (Mage::registry ( 'offers_data' ) && Mage::registry ( 'offers_data' )->getId ()) {
|
72 |
+
return Mage::helper ( 'offers' )->__ ( "Edit offer '%s'", $this->htmlEscape ( Mage::registry ( 'offers_data' )->getOfferTitle () ) );
|
73 |
+
} else {
|
74 |
+
return Mage::helper ( 'offers' )->__ ( 'Add Offer' );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Form.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Generate pre filled form details and save link for saving edited datas
|
33 |
+
*
|
34 |
+
* @return mixed Returns pre filled form details and save link
|
35 |
+
*/
|
36 |
+
protected function _prepareForm() {
|
37 |
+
$form = new Varien_Data_Form ( array (
|
38 |
+
'id' => 'edit_form',
|
39 |
+
'action' => $this->getUrl ( '*/*/save', array (
|
40 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
41 |
+
) ),
|
42 |
+
'method' => 'post',
|
43 |
+
'enctype' => 'multipart/form-data'
|
44 |
+
) );
|
45 |
+
|
46 |
+
$form->setUseContainer ( true );
|
47 |
+
$this->setForm ( $form );
|
48 |
+
return parent::_prepareForm ();
|
49 |
+
}
|
50 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Defines Form field to be edited
|
33 |
+
*
|
34 |
+
* @return object Form field to be edited
|
35 |
+
*/
|
36 |
+
protected function _prepareForm() {
|
37 |
+
$form = new Varien_Data_Form ();
|
38 |
+
$this->setForm ( $form );
|
39 |
+
$fieldset = $form->addFieldset ( 'offers_form', array (
|
40 |
+
'legend' => Mage::helper ( 'offers' )->__ ( 'Offer information' )
|
41 |
+
) );
|
42 |
+
|
43 |
+
$fieldset->addField ( 'offer_title', 'text', array (
|
44 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Offer Title' ),
|
45 |
+
'class' => 'required-entry',
|
46 |
+
'required' => true,
|
47 |
+
'name' => 'offer_title'
|
48 |
+
) );
|
49 |
+
|
50 |
+
// display Promotion image if already exit
|
51 |
+
$data = Mage::registry ( 'offers_data' );
|
52 |
+
|
53 |
+
if ($data->getData ( 'offer_img' ) != '') {
|
54 |
+
$html = '';
|
55 |
+
$url = Mage::getBaseUrl ( 'media' );
|
56 |
+
$html = '<img ';
|
57 |
+
$html .= 'src="' . $url . $data->getData ( 'offer_img' ) . '"' . 'width = "60px" />';
|
58 |
+
Mage::registry ( 'offers_data' )->setData ( 'offer_img_view', $data->getData ( 'offer_img' ) );
|
59 |
+
|
60 |
+
$fieldset->addField ( 'offer_img_view', 'text', array (
|
61 |
+
'label' => '',
|
62 |
+
'required' => false,
|
63 |
+
'style' => "display:none",
|
64 |
+
'name' => "offer_img_view",
|
65 |
+
'after_element_html' => $html
|
66 |
+
) );
|
67 |
+
|
68 |
+
$fieldset->addField ( 'offer_img', 'file', array (
|
69 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Promotion Image' ),
|
70 |
+
'required' => false,
|
71 |
+
'name' => 'offer_img',
|
72 |
+
'after_element_html' => '<small style="display:block">Upload image size (960 X 450 pixels)<small>'
|
73 |
+
) );
|
74 |
+
} else {
|
75 |
+
$fieldset->addField ( 'offer_img', 'file', array (
|
76 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Promotion Image ' ),
|
77 |
+
'required' => true,
|
78 |
+
'name' => 'offer_img',
|
79 |
+
'class' => 'required-entry required-file',
|
80 |
+
'after_element_html' => '<small style="display:block">Upload image size (960 X 450 pixels)<small>'
|
81 |
+
) );
|
82 |
+
}
|
83 |
+
|
84 |
+
$fieldset->addField ( 'from_date', 'date', array (
|
85 |
+
'name' => 'from_date',
|
86 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'From Date' ),
|
87 |
+
'style' => 'width:200px;',
|
88 |
+
'image' => $this->getSkinUrl ( 'images/grid-cal.gif' ),
|
89 |
+
'format' => Mage::app ()->getLocale ()->getDateFormat ( Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM ),
|
90 |
+
'required' => false,
|
91 |
+
'class' => ' validate-date validate-date-range date-range-to_date-from'
|
92 |
+
) );
|
93 |
+
|
94 |
+
$fieldset->addField ( 'to_date', 'date', array (
|
95 |
+
'name' => 'to_date',
|
96 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'To Date' ),
|
97 |
+
'style' => 'width:200px;',
|
98 |
+
'image' => $this->getSkinUrl ( 'images/grid-cal.gif' ),
|
99 |
+
'format' => Mage::app ()->getLocale ()->getDateFormat ( Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM ),
|
100 |
+
'required' => false,
|
101 |
+
'class' => 'validate-date validate-date-range date-range-to_date-to'
|
102 |
+
) );
|
103 |
+
|
104 |
+
$fieldset->addField ( 'status', 'select', array (
|
105 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Status' ),
|
106 |
+
'name' => 'status',
|
107 |
+
'values' => array (
|
108 |
+
array (
|
109 |
+
'value' => 1,
|
110 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Enabled' )
|
111 |
+
),
|
112 |
+
|
113 |
+
array (
|
114 |
+
'value' => 2,
|
115 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Disabled' )
|
116 |
+
)
|
117 |
+
)
|
118 |
+
) );
|
119 |
+
|
120 |
+
if (Mage::getSingleton ( 'adminhtml/session' )->getOffersData ()) {
|
121 |
+
$form->setValues ( Mage::getSingleton ( 'adminhtml/session' )->getOffersData () );
|
122 |
+
Mage::getSingleton ( 'adminhtml/session' )->setOffersData ( null );
|
123 |
+
} elseif (Mage::registry ( 'offers_data' )) {
|
124 |
+
$form->setValues ( Mage::registry ( 'offers_data' )->getData () );
|
125 |
+
}
|
126 |
+
return parent::_prepareForm ();
|
127 |
+
}
|
128 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tab/Productlist.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Edit_Tab_Productlist extends Mage_Adminhtml_Block_Widget_Grid {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initializing the default sort entity_id for the grid
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
parent::__construct ();
|
36 |
+
$this->setId ( 'catalog_category_products' );
|
37 |
+
$this->setDefaultSort ( 'entity_id' );
|
38 |
+
$this->setDefaultDir ( 'DESC' );
|
39 |
+
$this->setSaveParametersInSession ( true );
|
40 |
+
}
|
41 |
+
protected function _prepareCollection() {
|
42 |
+
// get these type of products only
|
43 |
+
$productType = array (
|
44 |
+
"simple",
|
45 |
+
"configurable"
|
46 |
+
);
|
47 |
+
$collection = Mage::getModel ( 'catalog/product' )->getCollection ()->addAttributeToFilter ( 'visibility', array (
|
48 |
+
'neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
49 |
+
) )->addAttributeToFilter ( 'type_id', array (
|
50 |
+
'in' => $productType
|
51 |
+
) )->addAttributeToSelect ( 'name' )->addAttributeToSelect ( 'sku' )->addAttributeToSelect ( 'price' )->addAttributeToFilter ( 'visibility', 4 )->addStoreFilter ( $this->getRequest ()->getParam ( 'store' ) );
|
52 |
+
$this->setCollection ( $collection );
|
53 |
+
|
54 |
+
return parent::_prepareCollection ();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Defines Form field to be edited
|
59 |
+
*
|
60 |
+
* @return object Form field to be edited
|
61 |
+
*/
|
62 |
+
protected function _prepareColumns() {
|
63 |
+
$this->addColumn ( 'offer_products', array (
|
64 |
+
'header_css_class' => 'a-center',
|
65 |
+
'type' => 'checkbox',
|
66 |
+
'name' => 'offer_products[]',
|
67 |
+
'values' => $this->_getSelectedProducts (),
|
68 |
+
'align' => 'center',
|
69 |
+
'index' => 'entity_id',
|
70 |
+
'field_name' => 'offer_products[]'
|
71 |
+
) );
|
72 |
+
|
73 |
+
$this->addColumn ( 'entity_id', array (
|
74 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'ID' ),
|
75 |
+
'sortable' => true,
|
76 |
+
'width' => '60',
|
77 |
+
'index' => 'entity_id'
|
78 |
+
) );
|
79 |
+
$this->addColumn ( 'name', array (
|
80 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'Name' ),
|
81 |
+
'index' => 'name'
|
82 |
+
) );
|
83 |
+
$this->addColumn ( 'sku', array (
|
84 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'SKU' ),
|
85 |
+
'width' => '80',
|
86 |
+
'index' => 'sku'
|
87 |
+
) );
|
88 |
+
$this->addColumn ( 'price', array (
|
89 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'Price' ),
|
90 |
+
'type' => 'currency',
|
91 |
+
'width' => '1',
|
92 |
+
'currency_code' => ( string ) Mage::getStoreConfig ( Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE ),
|
93 |
+
'index' => 'price'
|
94 |
+
) );
|
95 |
+
|
96 |
+
$this->addColumn ( 'Action', array (
|
97 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Action' ),
|
98 |
+
'index' => 'Push',
|
99 |
+
'filter' => false,
|
100 |
+
'renderer' => 'offers/adminhtml_offers_renderer_view',
|
101 |
+
'actions' => array (
|
102 |
+
array (
|
103 |
+
'caption' => Mage::helper ( 'offers' )->__ ( 'View' ),
|
104 |
+
'url' => array (
|
105 |
+
'base' => '*/',
|
106 |
+
'params' => array (
|
107 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
108 |
+
)
|
109 |
+
),
|
110 |
+
'field' => 'id',
|
111 |
+
'target' => '_blank'
|
112 |
+
)
|
113 |
+
)
|
114 |
+
) );
|
115 |
+
|
116 |
+
return parent::_prepareColumns ();
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get products related to offer
|
121 |
+
*
|
122 |
+
* @return array as product ids
|
123 |
+
*/
|
124 |
+
protected function _getSelectedProducts() {
|
125 |
+
$data = Mage::registry ( 'offers_data' );
|
126 |
+
$event_products = $data->getData ( 'offer_products' );
|
127 |
+
|
128 |
+
if (is_null ( $event_products )) {
|
129 |
+
return array_keys ( $event_products );
|
130 |
+
}
|
131 |
+
return $event_products;
|
132 |
+
}
|
133 |
+
protected function _prepareMassaction() {
|
134 |
+
$this->setMassactionIdField ( 'entity_id' );
|
135 |
+
$this->getMassactionBlock ()->setFormFieldName ( 'offer_products[]' );
|
136 |
+
|
137 |
+
return $this;
|
138 |
+
}
|
139 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Edit/Tabs.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Sets sidebar labels
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
parent::__construct ();
|
36 |
+
$this->setId ( 'offers_tabs' );
|
37 |
+
$this->setDestElementId ( 'edit_form' );
|
38 |
+
$this->setTitle ( Mage::helper ( 'offers' )->__ ( 'Offers Information' ) );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Returns edit tab contents
|
43 |
+
*
|
44 |
+
* @return string Returns edit tab content
|
45 |
+
*/
|
46 |
+
protected function _beforeToHtml() {
|
47 |
+
$this->addTab ( 'form_section', array (
|
48 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Offer Information' ),
|
49 |
+
'title' => Mage::helper ( 'offers' )->__ ( 'Offer Information' ),
|
50 |
+
'content' => $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_edit_tab_form' )->toHtml ()
|
51 |
+
) );
|
52 |
+
|
53 |
+
$this->addTab ( 'form_section1', array (
|
54 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Products' ),
|
55 |
+
'title' => Mage::helper ( 'offers' )->__ ( 'Products' ),
|
56 |
+
'content' => $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_edit_tab_productlist' )->toHtml ()
|
57 |
+
) );
|
58 |
+
|
59 |
+
return parent::_beforeToHtml ();
|
60 |
+
}
|
61 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Grid.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Adminhtml_Offers_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initializing the default sort offer id for the grid
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
parent::__construct ();
|
36 |
+
$this->setId ( 'offersGrid' );
|
37 |
+
$this->setDefaultSort ( 'offers_id' );
|
38 |
+
$this->setDefaultDir ( 'ASC' );
|
39 |
+
$this->setSaveParametersInSession ( true );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* It will fetch all offer details
|
44 |
+
*
|
45 |
+
* @return mixed Offer list collection
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection() {
|
48 |
+
$collection = Mage::getModel ( 'offers/offers' )->getCollection ();
|
49 |
+
$this->setCollection ( $collection );
|
50 |
+
return parent::_prepareCollection ();
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* It will prepare the fields to be displayed in Grid view
|
55 |
+
*
|
56 |
+
* @return mixed It will prepare the fields to be displayed in Grid view
|
57 |
+
*/
|
58 |
+
protected function _prepareColumns() {
|
59 |
+
$this->addColumn ( 'offers_id', array (
|
60 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'ID' ),
|
61 |
+
'align' => 'right',
|
62 |
+
'width' => '50px',
|
63 |
+
'index' => 'offers_id'
|
64 |
+
) );
|
65 |
+
|
66 |
+
$this->addColumn ( 'offer_title', array (
|
67 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Title' ),
|
68 |
+
'align' => 'left',
|
69 |
+
'index' => 'offer_title'
|
70 |
+
) );
|
71 |
+
|
72 |
+
$this->addColumn ( 'offer_img', array (
|
73 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Promotion Image' ),
|
74 |
+
'align' => 'left',
|
75 |
+
'index' => 'offer_img',
|
76 |
+
'renderer' => 'offers/adminhtml_offers_renderer_image',
|
77 |
+
'attr1' => 'value1'
|
78 |
+
) );
|
79 |
+
|
80 |
+
$this->addColumn ( 'status', array (
|
81 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Status' ),
|
82 |
+
'align' => 'left',
|
83 |
+
'width' => '80px',
|
84 |
+
'index' => 'status',
|
85 |
+
'type' => 'options',
|
86 |
+
'options' => array (
|
87 |
+
1 => 'Enabled',
|
88 |
+
2 => 'Disabled'
|
89 |
+
)
|
90 |
+
) );
|
91 |
+
|
92 |
+
$this->addColumn ( 'action', array (
|
93 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Action' ),
|
94 |
+
'width' => '100',
|
95 |
+
'type' => 'action',
|
96 |
+
'getter' => 'getId',
|
97 |
+
'actions' => array (
|
98 |
+
array (
|
99 |
+
'caption' => Mage::helper ( 'offers' )->__ ( 'Edit' ),
|
100 |
+
'url' => array (
|
101 |
+
'base' => '*/*/edit'
|
102 |
+
),
|
103 |
+
'field' => 'id'
|
104 |
+
)
|
105 |
+
),
|
106 |
+
'filter' => false,
|
107 |
+
'sortable' => false,
|
108 |
+
'index' => 'stores',
|
109 |
+
'is_system' => true
|
110 |
+
) );
|
111 |
+
|
112 |
+
$this->addColumn ( 'Notification', array (
|
113 |
+
'header' => Mage::helper ( 'offers' )->__ ( 'Notification' ),
|
114 |
+
'index' => 'Push',
|
115 |
+
'filter' => false,
|
116 |
+
'renderer' => 'offers/adminhtml_offers_renderer_notification',
|
117 |
+
'actions' => array (
|
118 |
+
array (
|
119 |
+
'caption' => Mage::helper ( 'offers' )->__ ( 'Push' ),
|
120 |
+
'url' => array (
|
121 |
+
'base' => '*/',
|
122 |
+
'params' => array (
|
123 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
124 |
+
)
|
125 |
+
),
|
126 |
+
'field' => 'id',
|
127 |
+
'target' => '_blank'
|
128 |
+
)
|
129 |
+
)
|
130 |
+
) );
|
131 |
+
|
132 |
+
$this->addExportType ( '*/*/exportCsv', Mage::helper ( 'offers' )->__ ( 'CSV' ) );
|
133 |
+
$this->addExportType ( '*/*/exportXml', Mage::helper ( 'offers' )->__ ( 'XML' ) );
|
134 |
+
|
135 |
+
return parent::_prepareColumns ();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Mass edit action
|
140 |
+
*
|
141 |
+
* @return mixed Returns updated collection values
|
142 |
+
*/
|
143 |
+
protected function _prepareMassaction() {
|
144 |
+
$this->setMassactionIdField ( 'offers_id' );
|
145 |
+
$this->getMassactionBlock ()->setFormFieldName ( 'offers' );
|
146 |
+
|
147 |
+
$this->getMassactionBlock ()->addItem ( 'delete', array (
|
148 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Delete' ),
|
149 |
+
'url' => $this->getUrl ( '*/*/massDelete' ),
|
150 |
+
'confirm' => Mage::helper ( 'offers' )->__ ( 'Are you sure?' )
|
151 |
+
) );
|
152 |
+
|
153 |
+
$statuses = Mage::getSingleton ( 'offers/status' )->getOptionArray ();
|
154 |
+
|
155 |
+
array_unshift ( $statuses, array (
|
156 |
+
'label' => '',
|
157 |
+
'value' => ''
|
158 |
+
) );
|
159 |
+
$this->getMassactionBlock ()->addItem ( 'status', array (
|
160 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Change status' ),
|
161 |
+
'url' => $this->getUrl ( '*/*/massStatus', array (
|
162 |
+
'_current' => true
|
163 |
+
) ),
|
164 |
+
'additional' => array (
|
165 |
+
'visibility' => array (
|
166 |
+
'name' => 'status',
|
167 |
+
'type' => 'select',
|
168 |
+
'class' => 'required-entry',
|
169 |
+
'label' => Mage::helper ( 'offers' )->__ ( 'Status' ),
|
170 |
+
'values' => $statuses
|
171 |
+
)
|
172 |
+
)
|
173 |
+
) );
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Returns current row url to be edited
|
179 |
+
*
|
180 |
+
* @param id $row
|
181 |
+
* Current row id
|
182 |
+
*
|
183 |
+
* @return string Returns edit url
|
184 |
+
*/
|
185 |
+
public function getRowUrl($row) {
|
186 |
+
}
|
187 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/Image.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
class Contus_Offers_Block_Adminhtml_Offers_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
31 |
+
/**
|
32 |
+
* This function is used to render image in grid page.
|
33 |
+
*
|
34 |
+
* @param Varien_Object $row
|
35 |
+
* Current grid row id
|
36 |
+
*
|
37 |
+
* @return string Returns uploaded image
|
38 |
+
*/
|
39 |
+
public function render(Varien_Object $row) {
|
40 |
+
$url = Mage::getBaseUrl ( 'media' );
|
41 |
+
if ($row->getData ( $this->getColumn ()->getIndex () ) != '') {
|
42 |
+
|
43 |
+
$html = '<img ';
|
44 |
+
$html .= 'id="' . $this->getColumn ()->getId () . '" ';
|
45 |
+
$html .= 'src="' . $url . $row->getData ( $this->getColumn ()->getIndex () ) . '"' . 'width = "60px"';
|
46 |
+
$html .= 'class="grid-image ' . $this->getColumn ()->getInlineCss () . '"/>';
|
47 |
+
$html .= '<br/><p>' . $row->getData ( $this->getColumn ()->getIndex () ) . '</p>';
|
48 |
+
} else {
|
49 |
+
$html = 'No image';
|
50 |
+
}
|
51 |
+
return $html;
|
52 |
+
}
|
53 |
+
}
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/Notification.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Pushnoteproducts
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get offer Url
|
33 |
+
*/
|
34 |
+
class Contus_Offers_Block_Adminhtml_Offers_Renderer_Notification extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get offer Url
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function render(Varien_Object $row) {
|
44 |
+
$id = $row->getId ();
|
45 |
+
$model = Mage::getModel ( 'offers/offers' ); // getting product model
|
46 |
+
$offer = $model->load ( $id ); // getting product object for particular offer id
|
47 |
+
$name = $offer->getOfferTitle ();
|
48 |
+
|
49 |
+
return '<a class="PushnoteOffer" id=' . $id . ' href="#" name="' . $name . ' " >' . $this->__ ( 'Push' ) . '</a>';
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
app/code/local/Contus/Offers/Block/Adminhtml/Offers/Renderer/View.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Offers
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get product Url
|
33 |
+
*/
|
34 |
+
class Contus_Offers_Block_Adminhtml_Offers_Renderer_View extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get product Url
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
|
44 |
+
public function render(Varien_Object $row) {
|
45 |
+
|
46 |
+
$id = $row->getId ();
|
47 |
+
//getting product model
|
48 |
+
$model = Mage::getModel('catalog/product');
|
49 |
+
//getting product object for particular product id
|
50 |
+
$product = $model->load($id);
|
51 |
+
$name=$product->getName();
|
52 |
+
|
53 |
+
return '<a class="view" id=' . $id . ' href='. Mage::helper("adminhtml")->getUrl("adminhtml/catalog_product/edit/", array("id"=>$row->getId ())).' target="_blank" name="' . $name . ' ">' . $this->__ ( 'View' ) . '</a>';
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
app/code/local/Contus/Offers/Block/Offers.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Block_Offers extends Mage_Core_Block_Template {
|
30 |
+
public function _prepareLayout() {
|
31 |
+
return parent::_prepareLayout ();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get offers data collection from controller.
|
36 |
+
*
|
37 |
+
* @return array offer details
|
38 |
+
*/
|
39 |
+
public function getOffers() {
|
40 |
+
if (! $this->hasData ( 'offers' )) {
|
41 |
+
$this->setData ( 'offers', Mage::registry ( 'offers' ) );
|
42 |
+
}
|
43 |
+
return $this->getData ( 'offers' );
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Contus/Offers/Helper/Data.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Helper_Data extends Mage_Core_Helper_Abstract {
|
30 |
+
}
|
app/code/local/Contus/Offers/Model/Mysql4/Offers.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Model_Mysql4_Offers extends Mage_Core_Model_Mysql4_Abstract {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialize the table
|
33 |
+
*
|
34 |
+
* @return object Collection with primary key
|
35 |
+
*/
|
36 |
+
public function _construct() {
|
37 |
+
// Note that the offers_id refers to the key field in your database table.
|
38 |
+
$this->_init ( 'offers/offers', 'offers_id' );
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Contus/Offers/Model/Mysql4/Offers/Collection.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Model_Mysql4_Offers_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initializes the collection model
|
33 |
+
*
|
34 |
+
* @return void
|
35 |
+
*/
|
36 |
+
public function _construct() {
|
37 |
+
parent::_construct ();
|
38 |
+
$this->_init ( 'offers/offers' );
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Contus/Offers/Model/Offers.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Model_Offers extends Mage_Core_Model_Abstract {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Constructor.
|
33 |
+
* Initialize model.
|
34 |
+
*
|
35 |
+
* @return void Initializes the model
|
36 |
+
*/
|
37 |
+
public function _construct() {
|
38 |
+
parent::_construct ();
|
39 |
+
$this->_init ( 'offers/offers' );
|
40 |
+
}
|
41 |
+
}
|
app/code/local/Contus/Offers/Model/Status.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Model_Status extends Varien_Object {
|
30 |
+
const STATUS_ENABLED = 1;
|
31 |
+
const STATUS_DISABLED = 2;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* This function will return label for status numbers
|
35 |
+
*
|
36 |
+
* @return array status array
|
37 |
+
*/
|
38 |
+
static public function getOptionArray() {
|
39 |
+
return array (
|
40 |
+
self::STATUS_ENABLED => Mage::helper ( 'offers' )->__ ( 'Enabled' ),
|
41 |
+
self::STATUS_DISABLED => Mage::helper ( 'offers' )->__ ( 'Disabled' )
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Contus/Offers/controllers/Adminhtml/OffersController.php
ADDED
@@ -0,0 +1,525 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_Adminhtml_OffersController extends Mage_Adminhtml_Controller_action {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialize the current item tab with label
|
33 |
+
*
|
34 |
+
* @return mixed Current page breadcrumb object
|
35 |
+
*/
|
36 |
+
protected function _initAction() {
|
37 |
+
$this->loadLayout ()->_setActiveMenu ( 'pushnoteproducts/items' )->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Items Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
38 |
+
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Initialize the layout
|
44 |
+
* $cnt
|
45 |
+
*
|
46 |
+
* @return mixed Loads current page layouts
|
47 |
+
*/
|
48 |
+
public function indexAction() {
|
49 |
+
$this->_initAction ()->_title ( $this->__ ( 'Offers' ) )->renderLayout ();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Check total count of offers
|
54 |
+
* Restrict only 5 offers to add
|
55 |
+
*/
|
56 |
+
public function checkCountAction() {
|
57 |
+
$collection = Mage::getModel ( 'offers/offers' )->getCollection ();
|
58 |
+
|
59 |
+
$size = $collection->getSize ();
|
60 |
+
$cnt = count ( $collection );
|
61 |
+
if ($cnt >= 5) {
|
62 |
+
Mage::getSingleton ( 'core/session' )->addError ( "Can't add more than 5 offers. " );
|
63 |
+
$this->_redirectReferer ();
|
64 |
+
} else {
|
65 |
+
$key = Mage::getSingleton ( 'adminhtml/url' )->getSecretKey ( "adminhtml_offers", "new" );
|
66 |
+
|
67 |
+
$this->_redirect ( '*/*/new', array (
|
68 |
+
'key' => $key
|
69 |
+
) );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get Message and product id to push message from web to app
|
75 |
+
*/
|
76 |
+
public function getPushMsgParamsAction() {
|
77 |
+
$isEnabled = true;
|
78 |
+
|
79 |
+
$params = $this->getRequest ()->getPost ();
|
80 |
+
$message = $params ['offer_desc'];
|
81 |
+
$id = $params ['offer_id'];
|
82 |
+
|
83 |
+
if ($isEnabled) {
|
84 |
+
$this->notification ( $message, $id );
|
85 |
+
} else {
|
86 |
+
Mage::getSingleton ( 'core/session' )->addError ( 'Please enable push notification option for offers.' );
|
87 |
+
$this->_redirectReferer ();
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Nofication
|
93 |
+
*
|
94 |
+
* @param string $message
|
95 |
+
* message which was given by admin to display in app
|
96 |
+
*
|
97 |
+
* @param int $id
|
98 |
+
*/
|
99 |
+
public function notification($message, $id) {
|
100 |
+
|
101 |
+
// Information to send in the push notification
|
102 |
+
$msg ['msg'] = $message;
|
103 |
+
$msg ['id'] = $id;
|
104 |
+
$msg ['type'] = 'list';
|
105 |
+
|
106 |
+
// MCOM demo googel api key
|
107 |
+
$gcmKey = Mage::getStoreConfig ( 'contus/configuration_pushnotifications/gcm_apikey' );
|
108 |
+
$result['mode'] = false;
|
109 |
+
$result = Mage::getModel ( 'configuration/config' )->getNotificationMode();
|
110 |
+
|
111 |
+
// Send Push Notification to Android and ios
|
112 |
+
$this->sendNotificationAndroid ( $gcmKey, $msg );
|
113 |
+
$this->sendNotificationiOS ( $result['pemfile'], $gcmKey, $result['mode'], $msg );
|
114 |
+
Mage::getSingleton ( 'core/session' )->addSuccess ( 'Notification Sent Successfully.' );
|
115 |
+
$this->_redirectReferer ();
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Function to Sending Push Notification to Andriod
|
120 |
+
*
|
121 |
+
* @param $androidAuthKey android
|
122 |
+
* Auth key given by android developer
|
123 |
+
* @param $message array
|
124 |
+
* information related to the push notification
|
125 |
+
*
|
126 |
+
*/
|
127 |
+
public function sendNotificationAndroid($androidAuthKey, $message) {
|
128 |
+
// database write adapter
|
129 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
130 |
+
// database read adapter
|
131 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
132 |
+
// get the table preix value
|
133 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
134 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='android' group by devicetoken" );
|
135 |
+
|
136 |
+
foreach ( $userDetails as $users ) {
|
137 |
+
// get the device token from the database
|
138 |
+
$registration_ids [] = $users ['devicetoken'];
|
139 |
+
}
|
140 |
+
|
141 |
+
// Set POST variables
|
142 |
+
$url = 'https://android.googleapis.com/gcm/send';
|
143 |
+
|
144 |
+
$fields = array (
|
145 |
+
'registration_ids' => $registration_ids,
|
146 |
+
'data' => $message
|
147 |
+
);
|
148 |
+
$headers = array (
|
149 |
+
'Authorization: key=' . $androidAuthKey,
|
150 |
+
'Content-Type: application/json'
|
151 |
+
);
|
152 |
+
// Open connection
|
153 |
+
$ch = curl_init ();
|
154 |
+
|
155 |
+
// Set the url, number of POST vars, POST data
|
156 |
+
curl_setopt ( $ch, CURLOPT_URL, $url );
|
157 |
+
|
158 |
+
curl_setopt ( $ch, CURLOPT_POST, true );
|
159 |
+
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
|
160 |
+
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
|
161 |
+
|
162 |
+
// Disabling SSL Certificate support temporarly
|
163 |
+
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
164 |
+
|
165 |
+
curl_setopt ( $ch, CURLOPT_POSTFIELDS, json_encode ( $fields ) );
|
166 |
+
|
167 |
+
// Execute post
|
168 |
+
$result = curl_exec ( $ch );
|
169 |
+
if ($result === FALSE) {
|
170 |
+
die ( 'Curl failed: ' . curl_error ( $ch ) );
|
171 |
+
}
|
172 |
+
// Close connection
|
173 |
+
curl_close ( $ch );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Function to Sending Push Notification to IOS
|
178 |
+
*
|
179 |
+
* @param $pemfile this
|
180 |
+
* file user for push from server to ios device
|
181 |
+
* @param $passphrase while
|
182 |
+
* creating pem file if we given password here we use. In this project we have not created
|
183 |
+
*
|
184 |
+
*/
|
185 |
+
public function sendNotificationiOS($pemfile, $passphrase, $mode, $message) {
|
186 |
+
// database write adapter
|
187 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
188 |
+
// database read adapter
|
189 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
190 |
+
// get the table preix value
|
191 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
192 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='iphone' group by devicetoken" );
|
193 |
+
|
194 |
+
foreach ( $userDetails as $users ) {
|
195 |
+
// get the device token from database
|
196 |
+
$registration_ids [] = $users ['devicetoken'];
|
197 |
+
}
|
198 |
+
echo $pemfile;
|
199 |
+
$ctx = stream_context_create ();
|
200 |
+
stream_context_set_option ( $ctx, 'ssl', 'local_cert', $pemfile );
|
201 |
+
|
202 |
+
// Type pem file name
|
203 |
+
stream_context_set_option ( $ctx, 'ssl', 'passphrase', '' );
|
204 |
+
|
205 |
+
// Open a connection to the APNS server
|
206 |
+
if ($mode == false) {
|
207 |
+
$fp = stream_socket_client ( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
208 |
+
} else {
|
209 |
+
|
210 |
+
$fp = stream_socket_client ( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
211 |
+
}
|
212 |
+
if (! $fp)
|
213 |
+
echo ("Failed to connect: $err $errstr" . PHP_EOL);
|
214 |
+
else
|
215 |
+
echo 'Connected to APNS' . PHP_EOL;
|
216 |
+
|
217 |
+
// Create the payload body
|
218 |
+
$body ['aps'] = array (
|
219 |
+
|
220 |
+
'alert' => $message ['msg'],
|
221 |
+
'sound' => 'default',
|
222 |
+
'id' => $message ['id'],
|
223 |
+
'type' => $message ['type'],
|
224 |
+
'content-available' => '1'
|
225 |
+
);
|
226 |
+
|
227 |
+
// Encode the payload as JSON
|
228 |
+
$payload = json_encode ( $body );
|
229 |
+
// Build the binary notification
|
230 |
+
for($i = 0; $i < count ( $registration_ids ); $i ++) {
|
231 |
+
$msg = chr ( 0 ) . pack ( 'n', 32 ) . pack ( 'H*', $registration_ids [$i] ) . pack ( 'n', strlen ( $payload ) ) . $payload;
|
232 |
+
// Send it to the server
|
233 |
+
$result = fwrite ( $fp, $msg, strlen ( $msg ) );
|
234 |
+
|
235 |
+
if (! $result)
|
236 |
+
echo 'Message not delivered' . PHP_EOL;
|
237 |
+
else
|
238 |
+
echo 'Message successfully delivered->' . $message ['msg'] . PHP_EOL;
|
239 |
+
|
240 |
+
print_r ( $message );
|
241 |
+
}
|
242 |
+
// Close the connection to the server
|
243 |
+
fclose ( $fp );
|
244 |
+
return $result;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Edit or create offer details
|
249 |
+
*
|
250 |
+
* @return void Created record values and redirect to current page
|
251 |
+
*/
|
252 |
+
public function editAction() {
|
253 |
+
$id = $this->getRequest ()->getParam ( 'id' );
|
254 |
+
$model = Mage::getModel ( 'offers/offers' )->load ( $id );
|
255 |
+
|
256 |
+
if ($model->getId () || $id == 0) {
|
257 |
+
$data = Mage::getSingleton ( 'adminhtml/session' )->getFormData ( true );
|
258 |
+
if (! empty ( $data )) {
|
259 |
+
$model->setData ( $data );
|
260 |
+
}
|
261 |
+
|
262 |
+
// set offer_products data string to array to model
|
263 |
+
if (isset ( $model ['offer_products'] ) && $model ['offer_products'] != '') {
|
264 |
+
$model ['offer_products'] = explode ( ',', $model ['offer_products'] );
|
265 |
+
}
|
266 |
+
|
267 |
+
Mage::register ( 'offers_data', $model );
|
268 |
+
|
269 |
+
$this->loadLayout ();
|
270 |
+
$this->_setActiveMenu ( 'offers/items' );
|
271 |
+
|
272 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
273 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item News' ), Mage::helper ( 'adminhtml' )->__ ( 'Item News' ) );
|
274 |
+
|
275 |
+
$this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true );
|
276 |
+
|
277 |
+
$this->_addContent ( $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_edit' ) )->_addLeft ( $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_edit_tabs' ) );
|
278 |
+
|
279 |
+
$this->renderLayout ();
|
280 |
+
} else {
|
281 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'offers' )->__ ( 'Item does not exist' ) );
|
282 |
+
$this->_redirect ( '*/*/' );
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Redirects page to edit action
|
288 |
+
*
|
289 |
+
* @return void Redirects to edit action
|
290 |
+
*/
|
291 |
+
public function newAction() {
|
292 |
+
$this->_forward ( 'edit' );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Save action for current records
|
297 |
+
*
|
298 |
+
* @return boolean True if data saved successfull else redirects page to edit action
|
299 |
+
*/
|
300 |
+
public function saveAction() {
|
301 |
+
if ($data = $this->getRequest ()->getPost ()) {
|
302 |
+
|
303 |
+
// convert offer_products array to string
|
304 |
+
if (! is_array ( $data ['offer_products'] )) {
|
305 |
+
$err_offer_product = 1;
|
306 |
+
} else if (is_array ( $data ['offer_products'] )) {
|
307 |
+
$err_offer_product = '';
|
308 |
+
$data ['offer_products'] = implode ( ',', $data ['offer_products'] );
|
309 |
+
}
|
310 |
+
|
311 |
+
// Format date
|
312 |
+
$data = $this->_filterDates ( $data, array (
|
313 |
+
'from_date',
|
314 |
+
'to_date'
|
315 |
+
) );
|
316 |
+
|
317 |
+
// Save offer image
|
318 |
+
$err_img = '';
|
319 |
+
$err_array = array ();
|
320 |
+
|
321 |
+
if (isset ( $_FILES ['offer_img'] ['name'] ) && $_FILES ['offer_img'] ['name'] != '') {
|
322 |
+
try {
|
323 |
+
|
324 |
+
/* Starting upload */
|
325 |
+
$uploader = new Varien_File_Uploader ( 'offer_img' );
|
326 |
+
|
327 |
+
// for creating the directory if not exists
|
328 |
+
$uploader->setAllowCreateFolders ( true );
|
329 |
+
// Alloweed extention would work
|
330 |
+
$uploader->setAllowedExtensions ( array (
|
331 |
+
'jpg',
|
332 |
+
'jpeg',
|
333 |
+
'gif',
|
334 |
+
'png'
|
335 |
+
) );
|
336 |
+
$uploader->setAllowRenameFiles ( false );
|
337 |
+
$uploader->setFilesDispersion ( false );
|
338 |
+
|
339 |
+
// We set media as the upload dir
|
340 |
+
$path = Mage::getBaseDir ( 'media' ) . DS . 'offers' . DS;
|
341 |
+
if ($uploader->save ( $path, $_FILES ['offer_img'] ['name'] )) {
|
342 |
+
|
343 |
+
// this way the name is saved in DB
|
344 |
+
$data ['offer_img'] = 'offers/' . $_FILES ['offer_img'] ['name'];
|
345 |
+
}
|
346 |
+
} catch ( Exception $e ) {
|
347 |
+
$err_img = 1;
|
348 |
+
$err_array [] = $e->getMessage ();
|
349 |
+
}
|
350 |
+
} else {
|
351 |
+
if (isset ( $data ['offer_img_view'] ) && $data ['offer_img_view'] != '') {
|
352 |
+
$data ['offer_img'] = $data ['offer_img_view'];
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
$model = Mage::getModel ( 'offers/offers' );
|
357 |
+
$model->setData ( $data )->setId ( $this->getRequest ()->getParam ( 'id' ) );
|
358 |
+
|
359 |
+
// Check validation for uploaded imgae and non empty of products before insert
|
360 |
+
|
361 |
+
if (isset ( $err_offer_product ) && $err_offer_product == 1) {
|
362 |
+
$err_array [] = 'Please select product(s) for this offer';
|
363 |
+
}
|
364 |
+
|
365 |
+
if (isset ( $err_img ) && $err_img == 1 || isset ( $err_offer_product ) && $err_offer_product == 1) {
|
366 |
+
|
367 |
+
foreach ( $err_array as $msg ) {
|
368 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'offers' )->__ ( $msg ) );
|
369 |
+
}
|
370 |
+
$offerId = $this->getRequest ()->getParam ( 'id' );
|
371 |
+
if (isset ( $offerId ) && $this->getRequest ()->getParam ( 'id' ) != '') {
|
372 |
+
$this->_redirect ( '*/*/edit', array (
|
373 |
+
'id' => $model->getId ()
|
374 |
+
) );
|
375 |
+
} else {
|
376 |
+
|
377 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( $data );
|
378 |
+
$key = Mage::getSingleton ( 'adminhtml/url' )->getSecretKey ( "adminhtml_offers", "new" );
|
379 |
+
|
380 |
+
$this->_redirect ( '*/*/new', array (
|
381 |
+
'key' => $key
|
382 |
+
) );
|
383 |
+
}
|
384 |
+
|
385 |
+
return;
|
386 |
+
}
|
387 |
+
|
388 |
+
try {
|
389 |
+
if ($model->getCreatedOn == NULL || $model->getUpdateOn () == NULL) {
|
390 |
+
$model->setCreatedOn ( now () )->setUpdateOn ( now () );
|
391 |
+
} else {
|
392 |
+
$model->setUpdateOn ( now () );
|
393 |
+
}
|
394 |
+
|
395 |
+
$model->save ();
|
396 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'offers' )->__ ( 'Offer was successfully saved.' ) );
|
397 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( false );
|
398 |
+
|
399 |
+
if ($this->getRequest ()->getParam ( 'back' )) {
|
400 |
+
$this->_redirect ( '*/*/edit', array (
|
401 |
+
'id' => $model->getId ()
|
402 |
+
) );
|
403 |
+
return;
|
404 |
+
}
|
405 |
+
$this->_redirect ( '*/*/' );
|
406 |
+
return;
|
407 |
+
} catch ( Exception $e ) {
|
408 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
409 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( $data );
|
410 |
+
$this->_redirect ( '*/*/edit', array (
|
411 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
412 |
+
) );
|
413 |
+
return;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'offers' )->__ ( 'Unable to find item to save.' ) );
|
417 |
+
$this->_redirect ( '*/*/' );
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Delete the current id
|
422 |
+
*
|
423 |
+
* @return void Redirects to grid page
|
424 |
+
*/
|
425 |
+
public function deleteAction() {
|
426 |
+
if ($this->getRequest ()->getParam ( 'id' ) > 0) {
|
427 |
+
try {
|
428 |
+
$model = Mage::getModel ( 'offers/offers' );
|
429 |
+
|
430 |
+
$model->setId ( $this->getRequest ()->getParam ( 'id' ) )->delete ();
|
431 |
+
|
432 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'adminhtml' )->__ ( 'Item was successfully deleted.' ) );
|
433 |
+
$this->_redirect ( '*/*/' );
|
434 |
+
} catch ( Exception $e ) {
|
435 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
436 |
+
$this->_redirect ( '*/*/edit', array (
|
437 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
438 |
+
) );
|
439 |
+
}
|
440 |
+
}
|
441 |
+
$this->_redirect ( '*/*/' );
|
442 |
+
}
|
443 |
+
|
444 |
+
/**
|
445 |
+
* Deletes selected records from database
|
446 |
+
*
|
447 |
+
* @return void Redirect to grid page
|
448 |
+
*/
|
449 |
+
public function massDeleteAction() {
|
450 |
+
$offersIds = $this->getRequest ()->getParam ( 'offers' );
|
451 |
+
if (! is_array ( $offersIds )) {
|
452 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'adminhtml' )->__ ( 'Please select item(s).' ) );
|
453 |
+
} else {
|
454 |
+
try {
|
455 |
+
foreach ( $offersIds as $offersId ) {
|
456 |
+
$offers = Mage::getModel ( 'offers/offers' )->load ( $offersId );
|
457 |
+
$offers->delete ();
|
458 |
+
}
|
459 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'adminhtml' )->__ ( 'Total of %d record(s) were successfully deleted', count ( $offersIds ) ) );
|
460 |
+
} catch ( Exception $e ) {
|
461 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
462 |
+
}
|
463 |
+
}
|
464 |
+
$this->_redirect ( '*/*/index' );
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Updates mass status update on selected grid records
|
469 |
+
*
|
470 |
+
* @return void Redirects back to index page
|
471 |
+
*/
|
472 |
+
public function massStatusAction() {
|
473 |
+
$offersIds = $this->getRequest ()->getParam ( 'offers' );
|
474 |
+
if (! is_array ( $offersIds )) {
|
475 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $this->__ ( 'Please select item(s)' ) );
|
476 |
+
} else {
|
477 |
+
try {
|
478 |
+
foreach ( $offersIds as $offersId ) {
|
479 |
+
$offers = Mage::getSingleton ( 'offers/offers' )->load ( $offersId )->setStatus ( $this->getRequest ()->getParam ( 'status' ) )->setIsMassupdate ( true )->save ();
|
480 |
+
}
|
481 |
+
$this->_getSession ()->addSuccess ( $this->__ ( 'Total of %d record(s) were successfully updated', count ( $offersIds ) ) );
|
482 |
+
} catch ( Exception $e ) {
|
483 |
+
$this->_getSession ()->addError ( $e->getMessage () );
|
484 |
+
}
|
485 |
+
}
|
486 |
+
$this->_redirect ( '*/*/index' );
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* CSV file export
|
491 |
+
*
|
492 |
+
* @return csv Returns csv file
|
493 |
+
*/
|
494 |
+
public function exportCsvAction() {
|
495 |
+
$fileName = 'offers.csv';
|
496 |
+
$content = $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_grid' )->getCsv ();
|
497 |
+
|
498 |
+
$this->_sendUploadResponse ( $fileName, $content );
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* XML file export
|
503 |
+
*
|
504 |
+
* @return xml Returns xml file to be download
|
505 |
+
*/
|
506 |
+
public function exportXmlAction() {
|
507 |
+
$fileName = 'offers.xml';
|
508 |
+
$content = $this->getLayout ()->createBlock ( 'offers/adminhtml_offers_grid' )->getXml ();
|
509 |
+
|
510 |
+
$this->_sendUploadResponse ( $fileName, $content );
|
511 |
+
}
|
512 |
+
protected function _sendUploadResponse($fileName, $content, $contentType = 'application/octet-stream') {
|
513 |
+
$response = $this->getResponse ();
|
514 |
+
$response->setHeader ( 'HTTP/1.1 200 OK', '' );
|
515 |
+
$response->setHeader ( 'Pragma', 'public', true );
|
516 |
+
$response->setHeader ( 'Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true );
|
517 |
+
$response->setHeader ( 'Content-Disposition', 'attachment; filename=' . $fileName );
|
518 |
+
$response->setHeader ( 'Last-Modified', date ( 'r' ) );
|
519 |
+
$response->setHeader ( 'Accept-Ranges', 'bytes' );
|
520 |
+
$response->setHeader ( 'Content-Length', strlen ( $content ) );
|
521 |
+
$response->setHeader ( 'Content-type', $contentType );
|
522 |
+
$response->setBody ( $content );
|
523 |
+
$response->sendResponse ();
|
524 |
+
}
|
525 |
+
}
|
app/code/local/Contus/Offers/controllers/IndexController.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Offers_IndexController extends Mage_Core_Controller_Front_Action {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Initialize the layout
|
33 |
+
*
|
34 |
+
* @return mixed Loads current page layouts
|
35 |
+
*/
|
36 |
+
public function indexAction() {
|
37 |
+
$this->loadLayout ();
|
38 |
+
$this->renderLayout ();
|
39 |
+
}
|
40 |
+
}
|
app/code/local/Contus/Offers/etc/adminhtml.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
|
5 |
+
<pushnoteproducts>
|
6 |
+
<children>
|
7 |
+
<contus_offers translate="title" module="offers">
|
8 |
+
<sort_order>30</sort_order>
|
9 |
+
<title>Offers</title>
|
10 |
+
<action>offers/adminhtml_offers</action>
|
11 |
+
</contus_offers >
|
12 |
+
</children>
|
13 |
+
</pushnoteproducts>
|
14 |
+
|
15 |
+
</menu>
|
16 |
+
</config>
|
app/code/local/Contus/Offers/etc/config.xml
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Offers>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Contus_Offers>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<offers>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Contus_Offers</module>
|
14 |
+
<frontName>offers</frontName>
|
15 |
+
</args>
|
16 |
+
</offers>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<offers>
|
21 |
+
<file>offers.xml</file>
|
22 |
+
</offers>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<offers>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Contus_Offers</module>
|
32 |
+
<frontName>offers</frontName>
|
33 |
+
</args>
|
34 |
+
</offers>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
|
39 |
+
<acl>
|
40 |
+
<resources>
|
41 |
+
<all>
|
42 |
+
<title>Allow Everything</title>
|
43 |
+
</all>
|
44 |
+
<admin>
|
45 |
+
<children>
|
46 |
+
<Contus_Offers>
|
47 |
+
<title>Offers Module</title>
|
48 |
+
<sort_order>10</sort_order>
|
49 |
+
</Contus_Offers>
|
50 |
+
</children>
|
51 |
+
</admin>
|
52 |
+
</resources>
|
53 |
+
</acl>
|
54 |
+
<layout>
|
55 |
+
<updates>
|
56 |
+
<offers>
|
57 |
+
<file>offers.xml</file>
|
58 |
+
</offers>
|
59 |
+
</updates>
|
60 |
+
</layout>
|
61 |
+
</adminhtml>
|
62 |
+
<global>
|
63 |
+
<models>
|
64 |
+
<offers>
|
65 |
+
<class>Contus_Offers_Model</class>
|
66 |
+
<resourceModel>offers_mysql4</resourceModel>
|
67 |
+
</offers>
|
68 |
+
<offers_mysql4>
|
69 |
+
<class>Contus_Offers_Model_Mysql4</class>
|
70 |
+
<entities>
|
71 |
+
<offers>
|
72 |
+
<table>offers</table>
|
73 |
+
</offers>
|
74 |
+
</entities>
|
75 |
+
</offers_mysql4>
|
76 |
+
</models>
|
77 |
+
<resources>
|
78 |
+
<offers_setup>
|
79 |
+
<setup>
|
80 |
+
<module>Contus_Offers</module>
|
81 |
+
</setup>
|
82 |
+
<connection>
|
83 |
+
<use>core_setup</use>
|
84 |
+
</connection>
|
85 |
+
</offers_setup>
|
86 |
+
<offers_write>
|
87 |
+
<connection>
|
88 |
+
<use>core_write</use>
|
89 |
+
</connection>
|
90 |
+
</offers_write>
|
91 |
+
<offers_read>
|
92 |
+
<connection>
|
93 |
+
<use>core_read</use>
|
94 |
+
</connection>
|
95 |
+
</offers_read>
|
96 |
+
</resources>
|
97 |
+
<blocks>
|
98 |
+
<offers>
|
99 |
+
<class>Contus_Offers_Block</class>
|
100 |
+
</offers>
|
101 |
+
</blocks>
|
102 |
+
<helpers>
|
103 |
+
<offers>
|
104 |
+
<class>Contus_Offers_Helper</class>
|
105 |
+
</offers>
|
106 |
+
</helpers>
|
107 |
+
</global>
|
108 |
+
</config>
|
app/code/local/Contus/Offers/sql/offers_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Offers
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Created table offers to offer information
|
32 |
+
*/
|
33 |
+
$installer = $this;
|
34 |
+
|
35 |
+
$installer->startSetup ();
|
36 |
+
|
37 |
+
$installer->run ( "
|
38 |
+
|
39 |
+
-- DROP TABLE IF EXISTS {$this->getTable('offers')};
|
40 |
+
CREATE TABLE {$this->getTable('offers')} (
|
41 |
+
`offers_id` int(11) unsigned NOT NULL auto_increment,
|
42 |
+
`offer_title` varchar(255) NOT NULL default '',
|
43 |
+
`offer_img` varchar(255) NOT NULL default '',
|
44 |
+
`from_date` date DEFAULT NULL,
|
45 |
+
`to_date` date DEFAULT NULL,
|
46 |
+
`offer_products` varchar(255) NOT NULL default '',
|
47 |
+
`status` int(1) NOT NULL default '2',
|
48 |
+
`created_on` datetime NULL,
|
49 |
+
`update_on` datetime NULL,
|
50 |
+
PRIMARY KEY (`offers_id`)
|
51 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
52 |
+
|
53 |
+
" );
|
54 |
+
|
55 |
+
$installer->endSetup ();
|
app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Block_Adminhtml_Pushnoteorders extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
30 |
+
public function __construct() {
|
31 |
+
$this->_controller = 'adminhtml_pushnoteorders';
|
32 |
+
$this->_blockGroup = 'pushnoteorders';
|
33 |
+
$this->_headerText = Mage::helper ( 'pushnoteorders' )->__ ( 'Orders' );
|
34 |
+
$this->_addButtonLabel = Mage::helper ( 'pushnoteorders' )->__ ( 'Add Item' );
|
35 |
+
parent::__construct ();
|
36 |
+
// Remove add button in admin grid page
|
37 |
+
$this->_removeButton ( 'add' );
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Edit.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Block_Adminhtml_Pushnoteorders_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
30 |
+
public function __construct() {
|
31 |
+
parent::__construct ();
|
32 |
+
|
33 |
+
$this->_objectId = 'id';
|
34 |
+
$this->_blockGroup = 'pushnoteorders';
|
35 |
+
$this->_controller = 'adminhtml_pushnoteorders';
|
36 |
+
|
37 |
+
$this->_updateButton ( 'save', 'label', Mage::helper ( 'pushnoteorders' )->__ ( 'Save Item' ) );
|
38 |
+
$this->_updateButton ( 'delete', 'label', Mage::helper ( 'pushnoteorders' )->__ ( 'Delete Item' ) );
|
39 |
+
|
40 |
+
$this->_addButton ( 'saveandcontinue', array (
|
41 |
+
'label' => Mage::helper ( 'adminhtml' )->__ ( 'Save And Continue Edit' ),
|
42 |
+
'onclick' => 'saveAndContinueEdit()',
|
43 |
+
'class' => 'save'
|
44 |
+
), - 100 );
|
45 |
+
|
46 |
+
$this->_formScripts [] = "
|
47 |
+
function toggleEditor() {
|
48 |
+
if (tinyMCE.getInstanceById('pushnoteorders_content') == null) {
|
49 |
+
tinyMCE.execCommand('mceAddControl', false, 'pushnoteorders_content');
|
50 |
+
} else {
|
51 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'pushnoteorders_content');
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
function saveAndContinueEdit(){
|
56 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
57 |
+
}
|
58 |
+
";
|
59 |
+
}
|
60 |
+
public function getHeaderText() {
|
61 |
+
if (Mage::registry ( 'pushnoteorders_data' ) && Mage::registry ( 'pushnoteorders_data' )->getId ()) {
|
62 |
+
return Mage::helper ( 'pushnoteorders' )->__ ( "Edit Item '%s'", $this->htmlEscape ( Mage::registry ( 'pushnoteorders_data' )->getTitle () ) );
|
63 |
+
} else {
|
64 |
+
return Mage::helper ( 'pushnoteorders' )->__ ( 'Add Item' );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Grid.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Block_Adminhtml_Pushnoteorders_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
30 |
+
public function __construct() {
|
31 |
+
parent::__construct ();
|
32 |
+
$this->setId ( 'pushnoteordersGrid' );
|
33 |
+
$this->setDefaultSort ( 'pushnoteorders_id' );
|
34 |
+
$this->setDefaultDir ( 'ASC' );
|
35 |
+
$this->setSaveParametersInSession ( true );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieve collection class
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
protected function _getCollectionClass() {
|
44 |
+
return 'sales/order_grid_collection';
|
45 |
+
}
|
46 |
+
protected function _prepareCollection() {
|
47 |
+
$collection = Mage::getResourceModel ( $this->_getCollectionClass () );
|
48 |
+
$this->setCollection ( $collection );
|
49 |
+
return parent::_prepareCollection ();
|
50 |
+
}
|
51 |
+
protected function _prepareColumns() {
|
52 |
+
$this->addColumn ( 'real_order_id', array (
|
53 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Order #' ),
|
54 |
+
'width' => '80px',
|
55 |
+
'type' => 'text',
|
56 |
+
'index' => 'increment_id'
|
57 |
+
) );
|
58 |
+
|
59 |
+
if (! Mage::app ()->isSingleStoreMode ()) {
|
60 |
+
$this->addColumn ( 'store_id', array (
|
61 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Purchased From (Store)' ),
|
62 |
+
'index' => 'store_id',
|
63 |
+
'type' => 'store',
|
64 |
+
'store_view' => true,
|
65 |
+
'display_deleted' => true
|
66 |
+
) );
|
67 |
+
}
|
68 |
+
|
69 |
+
$this->addColumn ( 'created_at', array (
|
70 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Purchased On' ),
|
71 |
+
'index' => 'created_at',
|
72 |
+
'type' => 'datetime',
|
73 |
+
'width' => '100px'
|
74 |
+
) );
|
75 |
+
|
76 |
+
$this->addColumn ( 'billing_name', array (
|
77 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Bill to Name' ),
|
78 |
+
'index' => 'billing_name'
|
79 |
+
) );
|
80 |
+
|
81 |
+
$this->addColumn ( 'shipping_name', array (
|
82 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Ship to Name' ),
|
83 |
+
'index' => 'shipping_name'
|
84 |
+
) );
|
85 |
+
|
86 |
+
$this->addColumn ( 'base_grand_total', array (
|
87 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'G.T. (Base)' ),
|
88 |
+
'index' => 'base_grand_total',
|
89 |
+
'type' => 'currency',
|
90 |
+
'currency' => 'base_currency_code'
|
91 |
+
) );
|
92 |
+
|
93 |
+
$this->addColumn ( 'grand_total', array (
|
94 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'G.T. (Purchased)' ),
|
95 |
+
'index' => 'grand_total',
|
96 |
+
'type' => 'currency',
|
97 |
+
'currency' => 'order_currency_code'
|
98 |
+
) );
|
99 |
+
|
100 |
+
$this->addColumn ( 'status', array (
|
101 |
+
'header' => Mage::helper ( 'sales' )->__ ( 'Status' ),
|
102 |
+
'index' => 'status',
|
103 |
+
'type' => 'options',
|
104 |
+
'width' => '70px',
|
105 |
+
'options' => Mage::getSingleton ( 'sales/order_config' )->getStatuses ()
|
106 |
+
) );
|
107 |
+
|
108 |
+
$this->addColumn ( 'Notification', array (
|
109 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Notification' ),
|
110 |
+
'index' => 'Push',
|
111 |
+
'filter' => false,
|
112 |
+
'renderer' => 'pushnoteorders/adminhtml_pushnoteorders_renderer_notification',
|
113 |
+
'actions' => array (
|
114 |
+
array (
|
115 |
+
'caption' => Mage::helper ( 'pushnoteorders' )->__ ( 'Push' ),
|
116 |
+
'url' => array (
|
117 |
+
'base' => '*/',
|
118 |
+
'params' => array (
|
119 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
120 |
+
)
|
121 |
+
),
|
122 |
+
'field' => 'id',
|
123 |
+
'target' => '_blank'
|
124 |
+
)
|
125 |
+
)
|
126 |
+
) );
|
127 |
+
|
128 |
+
$this->addColumn ( 'Action', array (
|
129 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Action' ),
|
130 |
+
'index' => 'Push',
|
131 |
+
'filter' => false,
|
132 |
+
'renderer' => 'pushnoteorders/adminhtml_pushnoteorders_renderer_view',
|
133 |
+
'actions' => array (
|
134 |
+
array (
|
135 |
+
'caption' => Mage::helper ( 'pushnoteorders' )->__ ( 'View' ),
|
136 |
+
'url' => array (
|
137 |
+
'base' => '*/',
|
138 |
+
'params' => array (
|
139 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
140 |
+
)
|
141 |
+
),
|
142 |
+
'field' => 'id',
|
143 |
+
'target' => '_blank'
|
144 |
+
)
|
145 |
+
)
|
146 |
+
) );
|
147 |
+
|
148 |
+
if (Mage::helper ( 'catalog' )->isModuleEnabled ( 'Mage_Rss' )) {
|
149 |
+
$this->addRssList ( 'rss/catalog/notifystock', Mage::helper ( 'catalog' )->__ ( 'Notify Low Stock RSS' ) );
|
150 |
+
}
|
151 |
+
|
152 |
+
return parent::_prepareColumns ();
|
153 |
+
}
|
154 |
+
/**
|
155 |
+
* Get store id
|
156 |
+
*
|
157 |
+
* @return int $storeId
|
158 |
+
*/
|
159 |
+
protected function _getStore() {
|
160 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( 'store', 0 );
|
161 |
+
return Mage::app ()->getStore ( $storeId );
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Mass edit action
|
166 |
+
*
|
167 |
+
* @return mixed Returns updated collection values
|
168 |
+
*/
|
169 |
+
protected function _prepareMassaction() {
|
170 |
+
$this->setMassactionIdField ( 'pushnoteorders_id' );
|
171 |
+
$this->getMassactionBlock ()->setFormFieldName ( 'pushnoteorders' );
|
172 |
+
|
173 |
+
return $this;
|
174 |
+
}
|
175 |
+
public function getRowUrl($row) {
|
176 |
+
}
|
177 |
+
}
|
app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Renderer/Notification.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Pushnoteorders
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get order detail
|
33 |
+
*/
|
34 |
+
class Contus_Pushnoteorders_Block_Adminhtml_Pushnoteorders_Renderer_Notification extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get order
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function render(Varien_Object $row) {
|
44 |
+
$id = $row->getId ();
|
45 |
+
|
46 |
+
$_helper = Mage::helper ( 'core' );
|
47 |
+
$order = Mage::getModel ( "sales/order" )->load ( $id );
|
48 |
+
|
49 |
+
$msg = 'Hi ' . $order->getCustomerName () . '! The status of your order id ' . $order->getRealOrderId () . ' amounted to ' . $_helper->currency ( $order->getBaseSubtotal (), true, false ) . ' has been changed to ' . $order->getStatus ();
|
50 |
+
return '<a class="PushnoteOrders" id=' . $order->getRealOrderId () . ' href="#" name="' . $msg . ' " customer_id="'.$order->getCustomerId () .' ">' . $this->__ ( 'Push' ) . '</a>';
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
app/code/local/Contus/Pushnoteorders/Block/Adminhtml/Pushnoteorders/Renderer/View.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Pushnoteorders
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get order detail
|
33 |
+
*/
|
34 |
+
class Contus_Pushnoteorders_Block_Adminhtml_Pushnoteorders_Renderer_View extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get order Url
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function render(Varien_Object $row) {
|
44 |
+
$id = $row->getId ();
|
45 |
+
|
46 |
+
return '<a class="view" href=' . Mage::helper ( "adminhtml" )->getUrl ( "adminhtml/sales_order/view/", array (
|
47 |
+
"order_id" => $row->getId ()
|
48 |
+
) ) . ' target="_blank" name="' . $id . ' ">' . $this->__ ( 'View' ) . '</a>';
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
app/code/local/Contus/Pushnoteorders/Block/Pushnoteorders.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Block_Pushnoteorders extends Mage_Core_Block_Template {
|
30 |
+
public function _prepareLayout() {
|
31 |
+
return parent::_prepareLayout ();
|
32 |
+
}
|
33 |
+
public function getPushnoteorders() {
|
34 |
+
if (! $this->hasData ( 'pushnoteorders' )) {
|
35 |
+
$this->setData ( 'pushnoteorders', Mage::registry ( 'pushnoteorders' ) );
|
36 |
+
}
|
37 |
+
return $this->getData ( 'pushnoteorders' );
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Contus/Pushnoteorders/Helper/Data.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Helper_Data extends Mage_Core_Helper_Abstract {
|
30 |
+
}
|
app/code/local/Contus/Pushnoteorders/controllers/Adminhtml/PushnoteordersController.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_Adminhtml_PushnoteordersController extends Mage_Adminhtml_Controller_action {
|
30 |
+
protected function _initAction() {
|
31 |
+
$this->loadLayout ()->_setActiveMenu ( 'pushnoteproducts/items' )->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Items Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
public function indexAction() {
|
36 |
+
$this->_initAction ()->_title ( $this->__ ( 'Push Notification - Orders' ) )->renderLayout ();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get Message and order id to push message from web to app
|
41 |
+
*/
|
42 |
+
public function getPushMsgParamsAction() {
|
43 |
+
$isEnabled = false;
|
44 |
+
$isEnabled = Mage::getStoreConfig ( 'contus/configuration_pushnotifications/order_pushnotification_enabled' );
|
45 |
+
|
46 |
+
$params = $this->getRequest ()->getPost ();
|
47 |
+
$message = $params ['order_detail'];
|
48 |
+
$id = $params ['order_id'];
|
49 |
+
$customer_id = $params ['customer_id'];
|
50 |
+
if ($isEnabled && trim ( $customer_id ) != '') {
|
51 |
+
$this->notification ( $message, $id, $customer_id );
|
52 |
+
} else if (trim ( $customer_id ) == '') {
|
53 |
+
Mage::getSingleton ( 'core/session' )->addError ( "Can't sent notification because this order placed by guest." );
|
54 |
+
$this->_redirectReferer ();
|
55 |
+
} else {
|
56 |
+
Mage::getSingleton ( 'core/session' )->addError ( 'Please enable push notification option for order.' );
|
57 |
+
$this->_redirectReferer ();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
/**
|
61 |
+
* Nofication
|
62 |
+
*
|
63 |
+
* @param string $message
|
64 |
+
* message which was given by admin to display in app
|
65 |
+
*
|
66 |
+
* @param int $id
|
67 |
+
*/
|
68 |
+
public function notification($message, $id, $customer_id) {
|
69 |
+
|
70 |
+
// Information to send in the push notification
|
71 |
+
$msg ['msg'] = $message;
|
72 |
+
$msg ['id'] = $id;
|
73 |
+
$msg ['type'] = 'order';
|
74 |
+
|
75 |
+
// MCOM demo googel api key
|
76 |
+
$gcmKey = Mage::getStoreConfig ( 'contus/configuration_pushnotifications/gcm_apikey' );
|
77 |
+
$result['mode'] = false;
|
78 |
+
$result = Mage::getModel ( 'configuration/config' )->getNotificationMode();
|
79 |
+
// Send Push Notification to Android and ios
|
80 |
+
$this->sendNotificationAndroid ( $gcmKey, $msg, $customer_id );
|
81 |
+
|
82 |
+
$this->sendNotificationiOS ( $result['pemfile'], $gcmKey, $result['mode'], $msg, $customer_id );
|
83 |
+
Mage::getSingleton ( 'core/session' )->addSuccess ( 'Notification Sent Successfully.' );
|
84 |
+
$this->_redirectReferer ();
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Function to Sending Push Notification to Andriod
|
89 |
+
*
|
90 |
+
* @param $androidAuthKey android
|
91 |
+
* Auth key given by android developer
|
92 |
+
* @param $message array
|
93 |
+
* information related to the push notification
|
94 |
+
*
|
95 |
+
*/
|
96 |
+
public function sendNotificationAndroid($androidAuthKey, $message, $customer_id) {
|
97 |
+
// echo $customer_id; exit;
|
98 |
+
// database write adapter
|
99 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
100 |
+
// database read adapter
|
101 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
102 |
+
// get the table preix value
|
103 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
104 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='android' and userid=" . $customer_id );
|
105 |
+
|
106 |
+
foreach ( $userDetails as $users ) {
|
107 |
+
// get the device token from the database
|
108 |
+
$registration_ids [] = $users ['devicetoken'];
|
109 |
+
}
|
110 |
+
|
111 |
+
// Set POST variables
|
112 |
+
$url = 'https://android.googleapis.com/gcm/send';
|
113 |
+
|
114 |
+
$fields = array (
|
115 |
+
'registration_ids' => $registration_ids,
|
116 |
+
'data' => $message
|
117 |
+
);
|
118 |
+
$headers = array (
|
119 |
+
'Authorization: key=' . $androidAuthKey,
|
120 |
+
'Content-Type: application/json'
|
121 |
+
);
|
122 |
+
// Open connection
|
123 |
+
$ch = curl_init ();
|
124 |
+
|
125 |
+
// Set the url, number of POST vars, POST data
|
126 |
+
curl_setopt ( $ch, CURLOPT_URL, $url );
|
127 |
+
|
128 |
+
curl_setopt ( $ch, CURLOPT_POST, true );
|
129 |
+
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
|
130 |
+
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
|
131 |
+
|
132 |
+
// Disabling SSL Certificate support temporarly
|
133 |
+
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
134 |
+
|
135 |
+
curl_setopt ( $ch, CURLOPT_POSTFIELDS, json_encode ( $fields ) );
|
136 |
+
|
137 |
+
// Execute post
|
138 |
+
$result = curl_exec ( $ch );
|
139 |
+
if ($result === FALSE) {
|
140 |
+
die ( 'Curl failed: ' . curl_error ( $ch ) );
|
141 |
+
}
|
142 |
+
// Close connection
|
143 |
+
curl_close ( $ch );
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Function to Sending Push Notification to IOS
|
148 |
+
*
|
149 |
+
* @param $pemfile this
|
150 |
+
* file user for push from server to ios device
|
151 |
+
* @param $passphrase while
|
152 |
+
* creating pem file if we given password here we use. In this project we have not created
|
153 |
+
*
|
154 |
+
*/
|
155 |
+
public function sendNotificationiOS($pemfile, $passphrase, $mode, $message, $customer_id) {
|
156 |
+
// database write adapter
|
157 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
158 |
+
// database read adapter
|
159 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
160 |
+
// get the table preix value
|
161 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
162 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='iphone' and userid=" . $customer_id );
|
163 |
+
foreach ( $userDetails as $users ) {
|
164 |
+
// get the device token from database
|
165 |
+
$registration_ids [] = $users ['devicetoken'];
|
166 |
+
}
|
167 |
+
$ctx = stream_context_create ();
|
168 |
+
stream_context_set_option ( $ctx, 'ssl', 'local_cert', $pemfile );
|
169 |
+
|
170 |
+
// Type pem file name
|
171 |
+
stream_context_set_option ( $ctx, 'ssl', 'passphrase', '' );
|
172 |
+
|
173 |
+
// Open a connection to the APNS server
|
174 |
+
if ($mode == false) {
|
175 |
+
$fp = stream_socket_client ( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
176 |
+
} else {
|
177 |
+
|
178 |
+
$fp = stream_socket_client ( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
179 |
+
}
|
180 |
+
if (! $fp)
|
181 |
+
echo ("Failed to connect: $err $errstr" . PHP_EOL);
|
182 |
+
else
|
183 |
+
echo 'Connected to APNS' . PHP_EOL;
|
184 |
+
|
185 |
+
// Create the payload body
|
186 |
+
$body ['aps'] = array (
|
187 |
+
|
188 |
+
'alert' => $message ['msg'],
|
189 |
+
'sound' => 'default',
|
190 |
+
'id' => $message ['id'],
|
191 |
+
'type' => $message ['type'],
|
192 |
+
'content-available' => '1'
|
193 |
+
);
|
194 |
+
|
195 |
+
// Encode the payload as JSON
|
196 |
+
$payload = json_encode ( $body );
|
197 |
+
// Build the binary notification
|
198 |
+
for($i = 0; $i < count ( $registration_ids ); $i ++) {
|
199 |
+
$msg = chr ( 0 ) . pack ( 'n', 32 ) . pack ( 'H*', $registration_ids [$i] ) . pack ( 'n', strlen ( $payload ) ) . $payload;
|
200 |
+
// Send it to the server
|
201 |
+
$result = fwrite ( $fp, $msg, strlen ( $msg ) );
|
202 |
+
|
203 |
+
if (! $result)
|
204 |
+
echo 'Message not delivered' . PHP_EOL;
|
205 |
+
else
|
206 |
+
echo 'Message successfully delivered->' . $message ['msg'] . PHP_EOL;
|
207 |
+
|
208 |
+
print_r ( $message );
|
209 |
+
}
|
210 |
+
// Close the connection to the server
|
211 |
+
fclose ( $fp );
|
212 |
+
return $result;
|
213 |
+
}
|
214 |
+
public function editAction() {
|
215 |
+
$id = $this->getRequest ()->getParam ( 'id' );
|
216 |
+
$model = Mage::getModel ( 'pushnoteorders/pushnoteorders' )->load ( $id );
|
217 |
+
|
218 |
+
if ($model->getId () || $id == 0) {
|
219 |
+
$data = Mage::getSingleton ( 'adminhtml/session' )->getFormData ( true );
|
220 |
+
if (! empty ( $data )) {
|
221 |
+
$model->setData ( $data );
|
222 |
+
}
|
223 |
+
|
224 |
+
Mage::register ( 'pushnoteorders_data', $model );
|
225 |
+
|
226 |
+
$this->loadLayout ();
|
227 |
+
$this->_setActiveMenu ( 'pushnoteorders/items' );
|
228 |
+
|
229 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
230 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item News' ), Mage::helper ( 'adminhtml' )->__ ( 'Item News' ) );
|
231 |
+
|
232 |
+
$this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true );
|
233 |
+
|
234 |
+
$this->_addContent ( $this->getLayout ()->createBlock ( 'pushnoteorders/adminhtml_pushnoteorders_edit' ) )->_addLeft ( $this->getLayout ()->createBlock ( 'pushnoteorders/adminhtml_pushnoteorders_edit_tabs' ) );
|
235 |
+
|
236 |
+
$this->renderLayout ();
|
237 |
+
} else {
|
238 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'pushnoteorders' )->__ ( 'Item does not exist' ) );
|
239 |
+
$this->_redirect ( '*/*/' );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
public function newAction() {
|
243 |
+
$this->_forward ( 'edit' );
|
244 |
+
}
|
245 |
+
public function saveAction() {
|
246 |
+
if ($data = $this->getRequest ()->getPost ()) {
|
247 |
+
|
248 |
+
$model = Mage::getModel ( 'pushnoteorders/pushnoteorders' );
|
249 |
+
$model->setData ( $data )->setId ( $this->getRequest ()->getParam ( 'id' ) );
|
250 |
+
|
251 |
+
try {
|
252 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime () == NULL) {
|
253 |
+
$model->setCreatedTime ( now () )->setUpdateTime ( now () );
|
254 |
+
} else {
|
255 |
+
$model->setUpdateTime ( now () );
|
256 |
+
}
|
257 |
+
|
258 |
+
$model->save ();
|
259 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'pushnoteorders' )->__ ( 'Item was successfully saved' ) );
|
260 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( false );
|
261 |
+
|
262 |
+
if ($this->getRequest ()->getParam ( 'back' )) {
|
263 |
+
$this->_redirect ( '*/*/edit', array (
|
264 |
+
'id' => $model->getId ()
|
265 |
+
) );
|
266 |
+
return;
|
267 |
+
}
|
268 |
+
$this->_redirect ( '*/*/' );
|
269 |
+
return;
|
270 |
+
} catch ( Exception $e ) {
|
271 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
272 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( $data );
|
273 |
+
$this->_redirect ( '*/*/edit', array (
|
274 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
275 |
+
) );
|
276 |
+
return;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'pushnoteorders' )->__ ( 'Unable to find item to save' ) );
|
280 |
+
$this->_redirect ( '*/*/' );
|
281 |
+
}
|
282 |
+
}
|
app/code/local/Contus/Pushnoteorders/controllers/IndexController.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteorders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteorders_IndexController extends Mage_Core_Controller_Front_Action {
|
30 |
+
public function indexAction() {
|
31 |
+
$this->loadLayout ();
|
32 |
+
$this->renderLayout ();
|
33 |
+
}
|
34 |
+
}
|
app/code/local/Contus/Pushnoteorders/etc/adminhtml.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<pushnoteproducts module="pushnoteproducts">
|
5 |
+
<children>
|
6 |
+
<pushnoteproducts>
|
7 |
+
<children>
|
8 |
+
<contus_pushnoteorders translate="title" module="pushnoteorders">
|
9 |
+
<sort_order>10</sort_order>
|
10 |
+
<title>Orders</title>
|
11 |
+
<action>pushnoteorders/adminhtml_pushnoteorders</action>
|
12 |
+
</contus_pushnoteorders >
|
13 |
+
</children>
|
14 |
+
</pushnoteproducts>
|
15 |
+
</children>
|
16 |
+
</pushnoteproducts>
|
17 |
+
</menu>
|
18 |
+
</config>
|
app/code/local/Contus/Pushnoteorders/etc/config.xml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Pushnoteorders>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Contus_Pushnoteorders>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<pushnoteorders>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Contus_Pushnoteorders</module>
|
14 |
+
<frontName>pushnoteorders</frontName>
|
15 |
+
</args>
|
16 |
+
</pushnoteorders>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<pushnoteorders>
|
21 |
+
<file>pushnoteorders.xml</file>
|
22 |
+
</pushnoteorders>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<pushnoteorders>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Contus_Pushnoteorders</module>
|
32 |
+
<frontName>pushnoteorders</frontName>
|
33 |
+
</args>
|
34 |
+
</pushnoteorders>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<acl>
|
39 |
+
<resources>
|
40 |
+
<all>
|
41 |
+
<title>Allow Everything</title>
|
42 |
+
</all>
|
43 |
+
<admin>
|
44 |
+
<children>
|
45 |
+
<Contus_Pushnoteorders>
|
46 |
+
<title>Pushnoteorders Module</title>
|
47 |
+
<sort_order>10</sort_order>
|
48 |
+
</Contus_Pushnoteorders>
|
49 |
+
</children>
|
50 |
+
</admin>
|
51 |
+
</resources>
|
52 |
+
</acl>
|
53 |
+
<layout>
|
54 |
+
<updates>
|
55 |
+
<pushnoteorders>
|
56 |
+
<file>pushnoteorders.xml</file>
|
57 |
+
</pushnoteorders>
|
58 |
+
</updates>
|
59 |
+
</layout>
|
60 |
+
</adminhtml>
|
61 |
+
<global>
|
62 |
+
<models>
|
63 |
+
<pushnoteorders>
|
64 |
+
<class>Contus_Pushnoteorders_Model</class>
|
65 |
+
<resourceModel>pushnoteorders_mysql4</resourceModel>
|
66 |
+
</pushnoteorders>
|
67 |
+
|
68 |
+
</models>
|
69 |
+
|
70 |
+
<blocks>
|
71 |
+
<pushnoteorders>
|
72 |
+
<class>Contus_Pushnoteorders_Block</class>
|
73 |
+
</pushnoteorders>
|
74 |
+
</blocks>
|
75 |
+
<helpers>
|
76 |
+
<pushnoteorders>
|
77 |
+
<class>Contus_Pushnoteorders_Helper</class>
|
78 |
+
</pushnoteorders>
|
79 |
+
</helpers>
|
80 |
+
</global>
|
81 |
+
</config>
|
app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_Block_Adminhtml_Pushnoteproducts extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
30 |
+
public function __construct() {
|
31 |
+
$this->_controller = 'adminhtml_pushnoteproducts';
|
32 |
+
$this->_blockGroup = 'pushnoteproducts';
|
33 |
+
$this->_headerText = Mage::helper ( 'pushnoteproducts' )->__ ( 'Products' );
|
34 |
+
$this->_addButtonLabel = Mage::helper ( 'pushnoteproducts' )->__ ( 'Add Item' );
|
35 |
+
parent::__construct ();
|
36 |
+
// Remove add button in admin grid page
|
37 |
+
$this->_removeButton ( 'add' );
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Edit.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_Block_Adminhtml_Pushnoteproducts_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
30 |
+
public function __construct() {
|
31 |
+
parent::__construct ();
|
32 |
+
|
33 |
+
$this->_objectId = 'id';
|
34 |
+
$this->_blockGroup = 'pushnoteproducts';
|
35 |
+
$this->_controller = 'adminhtml_pushnoteproducts';
|
36 |
+
|
37 |
+
$this->_updateButton ( 'save', 'label', Mage::helper ( 'pushnoteproducts' )->__ ( 'Save Item' ) );
|
38 |
+
$this->_updateButton ( 'delete', 'label', Mage::helper ( 'pushnoteproducts' )->__ ( 'Delete Item' ) );
|
39 |
+
|
40 |
+
$this->_addButton ( 'saveandcontinue', array (
|
41 |
+
'label' => Mage::helper ( 'adminhtml' )->__ ( 'Save And Continue Edit' ),
|
42 |
+
'onclick' => 'saveAndContinueEdit()',
|
43 |
+
'class' => 'save'
|
44 |
+
), - 100 );
|
45 |
+
|
46 |
+
$this->_formScripts [] = "
|
47 |
+
function toggleEditor() {
|
48 |
+
if (tinyMCE.getInstanceById('pushnoteproducts_content') == null) {
|
49 |
+
tinyMCE.execCommand('mceAddControl', false, 'pushnoteproducts_content');
|
50 |
+
} else {
|
51 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'pushnoteproducts_content');
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
function saveAndContinueEdit(){
|
56 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
57 |
+
}
|
58 |
+
";
|
59 |
+
}
|
60 |
+
public function getHeaderText() {
|
61 |
+
if (Mage::registry ( 'pushnoteproducts_data' ) && Mage::registry ( 'pushnoteproducts_data' )->getId ()) {
|
62 |
+
return Mage::helper ( 'pushnoteproducts' )->__ ( "Edit Item '%s'", $this->htmlEscape ( Mage::registry ( 'pushnoteproducts_data' )->getTitle () ) );
|
63 |
+
} else {
|
64 |
+
return Mage::helper ( 'pushnoteproducts' )->__ ( 'Add Item' );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Grid.php
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_PushnoteProducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_PushnoteProducts_Block_Adminhtml_PushnoteProducts_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
30 |
+
/**
|
31 |
+
* Initializing the default sort entity_id for the grid
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
parent::__construct ();
|
35 |
+
$this->setId ( 'pushnoteproductsGrid' );
|
36 |
+
$this->setDefaultSort ( 'pushnoteproducts_id' );
|
37 |
+
$this->setDefaultDir ( 'ASC' );
|
38 |
+
$this->setSaveParametersInSession ( true );
|
39 |
+
}
|
40 |
+
protected function _prepareCollection() {
|
41 |
+
$collection = Mage::getModel ( 'catalog/product' )->getCollection ()->addAttributeToSelect ( 'name' )->addAttributeToSelect ( 'sku' )->addAttributeToSelect ( 'price' )->addAttributeToFilter ( 'visibility', 4 )->addAttributeToSelect ( 'status' )->addStoreFilter ( $this->getRequest ()->getParam ( 'store' ) );
|
42 |
+
$this->setCollection ( $collection );
|
43 |
+
|
44 |
+
return parent::_prepareCollection ();
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Defines Form field to be edited
|
49 |
+
*
|
50 |
+
* @return object Form field to be edited
|
51 |
+
*/
|
52 |
+
protected function _prepareColumns() {
|
53 |
+
$this->addColumn ( 'entity_id', array (
|
54 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'ID' ),
|
55 |
+
'sortable' => true,
|
56 |
+
'width' => '60',
|
57 |
+
'index' => 'entity_id'
|
58 |
+
) );
|
59 |
+
|
60 |
+
$this->addColumn ( 'name', array (
|
61 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'Name' ),
|
62 |
+
'index' => 'name'
|
63 |
+
) );
|
64 |
+
$this->addColumn ( 'sku', array (
|
65 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'SKU' ),
|
66 |
+
'width' => '80',
|
67 |
+
'index' => 'sku'
|
68 |
+
) );
|
69 |
+
$this->addColumn ( 'price', array (
|
70 |
+
'header' => Mage::helper ( 'catalog' )->__ ( 'Price' ),
|
71 |
+
'type' => 'currency',
|
72 |
+
'width' => '1',
|
73 |
+
'currency_code' => ( string ) Mage::getStoreConfig ( Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE ),
|
74 |
+
'index' => 'price'
|
75 |
+
) );
|
76 |
+
$this->addColumn ( 'visibility', array (
|
77 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Visibility' ),
|
78 |
+
'width' => '70px',
|
79 |
+
'index' => 'visibility',
|
80 |
+
'type' => 'options',
|
81 |
+
'options' => Mage::getModel ( 'catalog/product_visibility' )->getOptionArray ()
|
82 |
+
) );
|
83 |
+
|
84 |
+
$this->addColumn ( 'status', array (
|
85 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Status' ),
|
86 |
+
'width' => '70px',
|
87 |
+
'index' => 'status',
|
88 |
+
'type' => 'options',
|
89 |
+
'options' => Mage::getSingleton ( 'catalog/product_status' )->getOptionArray ()
|
90 |
+
) );
|
91 |
+
|
92 |
+
$this->addColumn ( 'Notification', array (
|
93 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Notification' ),
|
94 |
+
'index' => 'Push',
|
95 |
+
'filter' => false,
|
96 |
+
'renderer' => 'pushnoteproducts/adminhtml_pushnoteproducts_renderer_notification',
|
97 |
+
'actions' => array (
|
98 |
+
array (
|
99 |
+
'caption' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Push' ),
|
100 |
+
'url' => array (
|
101 |
+
'base' => '*/',
|
102 |
+
'params' => array (
|
103 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
104 |
+
)
|
105 |
+
),
|
106 |
+
'field' => 'id',
|
107 |
+
'target' => '_blank'
|
108 |
+
)
|
109 |
+
)
|
110 |
+
) );
|
111 |
+
|
112 |
+
$this->addColumn ( 'Action', array (
|
113 |
+
'header' => Mage::helper ( 'pushnoteproducts' )->__ ( 'Action' ),
|
114 |
+
'index' => 'Push',
|
115 |
+
'filter' => false,
|
116 |
+
'renderer' => 'pushnoteproducts/adminhtml_pushnoteproducts_renderer_view',
|
117 |
+
'actions' => array (
|
118 |
+
array (
|
119 |
+
'caption' => Mage::helper ( 'pushnoteproducts' )->__ ( 'View' ),
|
120 |
+
'url' => array (
|
121 |
+
'base' => '*/',
|
122 |
+
'params' => array (
|
123 |
+
'store' => $this->getRequest ()->getParam ( 'store' )
|
124 |
+
)
|
125 |
+
),
|
126 |
+
'field' => 'id',
|
127 |
+
'target' => '_blank'
|
128 |
+
)
|
129 |
+
)
|
130 |
+
) );
|
131 |
+
if (Mage::helper ( 'catalog' )->isModuleEnabled ( 'Mage_Rss' )) {
|
132 |
+
$this->addRssList ( 'rss/catalog/notifystock', Mage::helper ( 'catalog' )->__ ( 'Notify Low Stock RSS' ) );
|
133 |
+
}
|
134 |
+
|
135 |
+
return parent::_prepareColumns ();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Get store id
|
140 |
+
*
|
141 |
+
* @return int $storeId
|
142 |
+
*/
|
143 |
+
protected function _getStore() {
|
144 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( 'store', 0 );
|
145 |
+
return Mage::app ()->getStore ( $storeId );
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Mass edit action
|
150 |
+
*
|
151 |
+
* @return mixed Returns updated collection values
|
152 |
+
*/
|
153 |
+
protected function _prepareMassaction() {
|
154 |
+
$this->setMassactionIdField ( 'pushnoteproducts_id' );
|
155 |
+
$this->getMassactionBlock ()->setFormFieldName ( 'pushnoteproducts' );
|
156 |
+
|
157 |
+
return $this;
|
158 |
+
}
|
159 |
+
public function getRowUrl($row) {
|
160 |
+
}
|
161 |
+
}
|
app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Renderer/Notification.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Pushnoteproducts
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get product Url
|
33 |
+
*/
|
34 |
+
class Contus_Pushnoteproducts_Block_Adminhtml_Pushnoteproducts_Renderer_Notification extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get product Url
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
|
44 |
+
public function render(Varien_Object $row) {
|
45 |
+
|
46 |
+
$id = $row->getId ();
|
47 |
+
//getting product model
|
48 |
+
$model = Mage::getModel('catalog/product');
|
49 |
+
//getting product object for particular product id
|
50 |
+
$product = $model->load($id);
|
51 |
+
$name=$product->getName();
|
52 |
+
$baseUrl = Mage::getBaseUrl ();
|
53 |
+
return '<a class="PushnoteProducts" id=' . $id . ' href="#" name="' . $name . ' ">' . $this->__ ( 'Push' ) . '</a>';
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
app/code/local/Contus/Pushnoteproducts/Block/Adminhtml/Pushnoteproducts/Renderer/View.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Apptha
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package Contus_Pushnoteproducts
|
25 |
+
* @version 0.1
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt
|
29 |
+
*/
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Renderer to get product Url
|
33 |
+
*/
|
34 |
+
class Contus_Pushnoteproducts_Block_Adminhtml_Pushnoteproducts_Renderer_View extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Function to get product Url
|
38 |
+
*
|
39 |
+
* Return the Total sales
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
|
44 |
+
public function render(Varien_Object $row) {
|
45 |
+
|
46 |
+
$id = $row->getId ();
|
47 |
+
//getting product model
|
48 |
+
$model = Mage::getModel('catalog/product');
|
49 |
+
//getting product object for particular product id
|
50 |
+
$product = $model->load($id);
|
51 |
+
$name=$product->getName();
|
52 |
+
|
53 |
+
return '<a class="view" id=' . $id . ' href='. Mage::helper("adminhtml")->getUrl("adminhtml/catalog_product/edit/", array("id"=>$row->getId ())).' target="_blank" name="' . $name . ' ">' . $this->__ ( 'View' ) . '</a>';
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
app/code/local/Contus/Pushnoteproducts/Block/Pushnoteproducts.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_Block_Pushnoteproducts extends Mage_Core_Block_Template {
|
30 |
+
public function _prepareLayout() {
|
31 |
+
return parent::_prepareLayout ();
|
32 |
+
}
|
33 |
+
public function getPushnoteproducts() {
|
34 |
+
if (! $this->hasData ( 'pushnoteproducts' )) {
|
35 |
+
$this->setData ( 'pushnoteproducts', Mage::registry ( 'pushnoteproducts' ) );
|
36 |
+
}
|
37 |
+
return $this->getData ( 'pushnoteproducts' );
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Contus/Pushnoteproducts/Helper/Data.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_Helper_Data extends Mage_Core_Helper_Abstract {
|
30 |
+
}
|
app/code/local/Contus/Pushnoteproducts/controllers/Adminhtml/PushnoteproductsController.php
ADDED
@@ -0,0 +1,282 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_Adminhtml_PushnoteproductsController extends Mage_Adminhtml_Controller_action {
|
30 |
+
protected function _initAction() {
|
31 |
+
$this->loadLayout ()->_setActiveMenu ( 'pushnoteproducts/items' )->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Items Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
public function indexAction() {
|
36 |
+
$this->_initAction ()->_title ( $this->__ ( 'Push Notification - Products' ) )->renderLayout ();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get Message and product id to push message from web to app
|
41 |
+
*/
|
42 |
+
public function getPushMsgParamsAction() {
|
43 |
+
$isEnabled = false;
|
44 |
+
$isEnabled = Mage::getStoreConfig ( 'contus/configuration_pushnotifications/product_pushnotification_enabled' );
|
45 |
+
|
46 |
+
$params = $this->getRequest ()->getPost ();
|
47 |
+
$message = $params ['product_name'];
|
48 |
+
$id = $params ['product_id'];
|
49 |
+
|
50 |
+
if ($isEnabled) {
|
51 |
+
$this->notification ( $message, $id );
|
52 |
+
} else {
|
53 |
+
Mage::getSingleton ( 'core/session' )->addError ( 'Please enable push notification option for product.' );
|
54 |
+
$this->_redirectReferer ();
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Nofication
|
60 |
+
*
|
61 |
+
* @param string $message
|
62 |
+
* message which was given by admin to display in app
|
63 |
+
*
|
64 |
+
* @param int $id
|
65 |
+
*/
|
66 |
+
public function notification($message, $id) {
|
67 |
+
|
68 |
+
// Information to send in the push notification
|
69 |
+
$msg ['msg'] = $message;
|
70 |
+
$msg ['id'] = $id;
|
71 |
+
$msg ['type'] = 'product';
|
72 |
+
|
73 |
+
// MCOM demo googel api key
|
74 |
+
|
75 |
+
$gcmKey = Mage::getStoreConfig ( 'contus/configuration_pushnotifications/gcm_apikey' );
|
76 |
+
$result['mode'] = false;
|
77 |
+
$result = Mage::getModel ( 'configuration/config' )->getNotificationMode();
|
78 |
+
// Send Push Notification to Android and ios
|
79 |
+
$this->sendNotificationAndroid ( $gcmKey, $msg );
|
80 |
+
$result = $this->sendNotificationiOS ( $result['pemfile'], $gcmKey, $result['mode'], $msg);
|
81 |
+
|
82 |
+
Mage::getSingleton ( 'core/session' )->addSuccess ( 'Notification Sent Successfully. ' );
|
83 |
+
$this->_redirectReferer ();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Function to Sending Push Notification to Andriod
|
88 |
+
*
|
89 |
+
* @param $androidAuthKey android
|
90 |
+
* Auth key given by android developer
|
91 |
+
* @param $message array
|
92 |
+
* information related to the push notification
|
93 |
+
*
|
94 |
+
*/
|
95 |
+
public function sendNotificationAndroid($androidAuthKey, $message) {
|
96 |
+
// database write adapter
|
97 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
98 |
+
// database read adapter
|
99 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
100 |
+
// get the table preix value
|
101 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
102 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='android' group by devicetoken" );
|
103 |
+
|
104 |
+
foreach ( $userDetails as $users ) {
|
105 |
+
// get the device token from the database
|
106 |
+
$registration_ids [] = $users ['devicetoken'];
|
107 |
+
}
|
108 |
+
|
109 |
+
// Set POST variables
|
110 |
+
$url = 'https://android.googleapis.com/gcm/send';
|
111 |
+
|
112 |
+
$fields = array (
|
113 |
+
'registration_ids' => $registration_ids,
|
114 |
+
'data' => $message
|
115 |
+
);
|
116 |
+
$headers = array (
|
117 |
+
'Authorization: key=' . $androidAuthKey,
|
118 |
+
'Content-Type: application/json'
|
119 |
+
);
|
120 |
+
// Open connection
|
121 |
+
$ch = curl_init ();
|
122 |
+
|
123 |
+
// Set the url, number of POST vars, POST data
|
124 |
+
curl_setopt ( $ch, CURLOPT_URL, $url );
|
125 |
+
|
126 |
+
curl_setopt ( $ch, CURLOPT_POST, true );
|
127 |
+
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
|
128 |
+
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
|
129 |
+
|
130 |
+
// Disabling SSL Certificate support temporarly
|
131 |
+
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
132 |
+
|
133 |
+
curl_setopt ( $ch, CURLOPT_POSTFIELDS, json_encode ( $fields ) );
|
134 |
+
|
135 |
+
// Execute post
|
136 |
+
$result = curl_exec ( $ch );
|
137 |
+
if ($result === FALSE) {
|
138 |
+
die ( 'Curl failed: ' . curl_error ( $ch ) );
|
139 |
+
}
|
140 |
+
// Close connection
|
141 |
+
curl_close ( $ch );
|
142 |
+
}
|
143 |
+
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Function to Sending Push Notification to IOS
|
147 |
+
*
|
148 |
+
* @param $pemfile this
|
149 |
+
* file user for push from server to ios device
|
150 |
+
* @param $passphrase while
|
151 |
+
* creating pem file if we given password here we use. In this project we have not created
|
152 |
+
*
|
153 |
+
*/
|
154 |
+
public function sendNotificationiOS($pemfile, $passphrase, $mode, $message) {
|
155 |
+
// database write adapter
|
156 |
+
$db_write = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_write' );
|
157 |
+
// database read adapter
|
158 |
+
$db_read = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
159 |
+
// get the table preix value
|
160 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
161 |
+
$userDetails = $db_read->fetchAll ( "SELECT devicetoken FROM " . $prefix . "token WHERE devicetype='iphone' group by devicetoken" );
|
162 |
+
|
163 |
+
foreach ( $userDetails as $users ) {
|
164 |
+
// get the device token from database
|
165 |
+
$registration_ids [] = $users ['devicetoken'];
|
166 |
+
}
|
167 |
+
$ctx = stream_context_create ();
|
168 |
+
stream_context_set_option ( $ctx, 'ssl', 'local_cert', $pemfile );
|
169 |
+
|
170 |
+
// Type pem file name
|
171 |
+
stream_context_set_option ( $ctx, 'ssl', 'passphrase', '' );
|
172 |
+
|
173 |
+
// Open a connection to the APNS server
|
174 |
+
if ($mode == false) {
|
175 |
+
$fp = stream_socket_client ( 'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
176 |
+
} else {
|
177 |
+
|
178 |
+
$fp = stream_socket_client ( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx );
|
179 |
+
}
|
180 |
+
if (! $fp)
|
181 |
+
echo ("Failed to connect: $err $errstr" . PHP_EOL);
|
182 |
+
else
|
183 |
+
echo 'Connected to APNS' . PHP_EOL;
|
184 |
+
|
185 |
+
// Create the payload body
|
186 |
+
$body ['aps'] = array (
|
187 |
+
|
188 |
+
'alert' => $message ['msg'],
|
189 |
+
'sound' => 'default',
|
190 |
+
'id' => $message ['id'],
|
191 |
+
'type' => $message ['type'],
|
192 |
+
'content-available' => '1'
|
193 |
+
);
|
194 |
+
|
195 |
+
// Encode the payload as JSON
|
196 |
+
$payload = json_encode ( $body );
|
197 |
+
// Build the binary notification
|
198 |
+
for($i = 0; $i < count ( $registration_ids ); $i ++) {
|
199 |
+
$msg = chr ( 0 ) . pack ( 'n', 32 ) . pack ( 'H*', $registration_ids [$i] ) . pack ( 'n', strlen ( $payload ) ) . $payload;
|
200 |
+
// Send it to the server
|
201 |
+
$result = fwrite ( $fp, $msg, strlen ( $msg ) );
|
202 |
+
|
203 |
+
if (! $result)
|
204 |
+
echo 'Message not delivered' . PHP_EOL;
|
205 |
+
else
|
206 |
+
echo 'Message successfully delivered->' . $message ['msg'] . PHP_EOL;
|
207 |
+
|
208 |
+
print_r ( $message );
|
209 |
+
}
|
210 |
+
// Close the connection to the server
|
211 |
+
fclose ( $fp );
|
212 |
+
return $result;
|
213 |
+
}
|
214 |
+
public function editAction() {
|
215 |
+
$id = $this->getRequest ()->getParam ( 'id' );
|
216 |
+
$model = Mage::getModel ( 'pushnoteproducts/pushnoteproducts' )->load ( $id );
|
217 |
+
|
218 |
+
if ($model->getId () || $id == 0) {
|
219 |
+
$data = Mage::getSingleton ( 'adminhtml/session' )->getFormData ( true );
|
220 |
+
if (! empty ( $data )) {
|
221 |
+
$model->setData ( $data );
|
222 |
+
}
|
223 |
+
|
224 |
+
Mage::register ( 'pushnoteproducts_data', $model );
|
225 |
+
|
226 |
+
$this->loadLayout ();
|
227 |
+
$this->_setActiveMenu ( 'pushnoteproducts/items' );
|
228 |
+
|
229 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ), Mage::helper ( 'adminhtml' )->__ ( 'Item Manager' ) );
|
230 |
+
$this->_addBreadcrumb ( Mage::helper ( 'adminhtml' )->__ ( 'Item News' ), Mage::helper ( 'adminhtml' )->__ ( 'Item News' ) );
|
231 |
+
|
232 |
+
$this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true );
|
233 |
+
|
234 |
+
$this->_addContent ( $this->getLayout ()->createBlock ( 'pushnoteproducts/adminhtml_pushnoteproducts_edit' ) )->_addLeft ( $this->getLayout ()->createBlock ( 'pushnoteproducts/adminhtml_pushnoteproducts_edit_tabs' ) );
|
235 |
+
|
236 |
+
$this->renderLayout ();
|
237 |
+
} else {
|
238 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'pushnoteproducts' )->__ ( 'Item does not exist' ) );
|
239 |
+
$this->_redirect ( '*/*/' );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
public function newAction() {
|
243 |
+
$this->_forward ( 'edit' );
|
244 |
+
}
|
245 |
+
public function saveAction() {
|
246 |
+
if ($data = $this->getRequest ()->getPost ()) {
|
247 |
+
|
248 |
+
$model = Mage::getModel ( 'pushnoteproducts/pushnoteproducts' );
|
249 |
+
$model->setData ( $data )->setId ( $this->getRequest ()->getParam ( 'id' ) );
|
250 |
+
|
251 |
+
try {
|
252 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime () == NULL) {
|
253 |
+
$model->setCreatedTime ( now () )->setUpdateTime ( now () );
|
254 |
+
} else {
|
255 |
+
$model->setUpdateTime ( now () );
|
256 |
+
}
|
257 |
+
|
258 |
+
$model->save ();
|
259 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'pushnoteproducts' )->__ ( 'Item was successfully saved' ) );
|
260 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( false );
|
261 |
+
|
262 |
+
if ($this->getRequest ()->getParam ( 'back' )) {
|
263 |
+
$this->_redirect ( '*/*/edit', array (
|
264 |
+
'id' => $model->getId ()
|
265 |
+
) );
|
266 |
+
return;
|
267 |
+
}
|
268 |
+
$this->_redirect ( '*/*/' );
|
269 |
+
return;
|
270 |
+
} catch ( Exception $e ) {
|
271 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
272 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( $data );
|
273 |
+
$this->_redirect ( '*/*/edit', array (
|
274 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
275 |
+
) );
|
276 |
+
return;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'pushnoteproducts' )->__ ( 'Unable to find item to save' ) );
|
280 |
+
$this->_redirect ( '*/*/' );
|
281 |
+
}
|
282 |
+
}
|
app/code/local/Contus/Pushnoteproducts/controllers/IndexController.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package Contus_Pushnoteproducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class Contus_Pushnoteproducts_IndexController extends Mage_Core_Controller_Front_Action {
|
30 |
+
public function indexAction() {
|
31 |
+
$this->loadLayout ();
|
32 |
+
$this->renderLayout ();
|
33 |
+
}
|
34 |
+
}
|
app/code/local/Contus/Pushnoteproducts/etc/config.xml
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Pushnoteproducts>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Contus_Pushnoteproducts>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<pushnoteproducts>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Contus_Pushnoteproducts</module>
|
14 |
+
<frontName>pushnoteproducts</frontName>
|
15 |
+
</args>
|
16 |
+
</pushnoteproducts>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<pushnoteproducts>
|
21 |
+
<file>pushnoteproducts.xml</file>
|
22 |
+
</pushnoteproducts>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<pushnoteproducts>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Contus_Pushnoteproducts</module>
|
32 |
+
<frontName>pushnoteproducts</frontName>
|
33 |
+
</args>
|
34 |
+
</pushnoteproducts>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<menu>
|
39 |
+
<pushnoteproducts module="pushnoteproducts">
|
40 |
+
<title>MCOMM App</title>
|
41 |
+
<sort_order>100</sort_order>
|
42 |
+
<children>
|
43 |
+
<pushnoteproducts>
|
44 |
+
<title>Push Notification</title>
|
45 |
+
<children>
|
46 |
+
<items module="pushnoteproducts">
|
47 |
+
<title>Products</title>
|
48 |
+
<sort_order>0</sort_order>
|
49 |
+
<action>pushnoteproducts/adminhtml_pushnoteproducts</action>
|
50 |
+
</items>
|
51 |
+
</children>
|
52 |
+
</pushnoteproducts>
|
53 |
+
</children>
|
54 |
+
</pushnoteproducts>
|
55 |
+
</menu>
|
56 |
+
<acl>
|
57 |
+
<resources>
|
58 |
+
<all>
|
59 |
+
<title>Allow Everything</title>
|
60 |
+
</all>
|
61 |
+
<admin>
|
62 |
+
<children>
|
63 |
+
<Contus_Pushnoteproducts>
|
64 |
+
<title>Pushnoteproducts Module</title>
|
65 |
+
<sort_order>10</sort_order>
|
66 |
+
</Contus_Pushnoteproducts>
|
67 |
+
</children>
|
68 |
+
</admin>
|
69 |
+
</resources>
|
70 |
+
</acl>
|
71 |
+
<layout>
|
72 |
+
<updates>
|
73 |
+
<pushnoteproducts>
|
74 |
+
<file>pushnoteproducts.xml</file>
|
75 |
+
</pushnoteproducts>
|
76 |
+
</updates>
|
77 |
+
</layout>
|
78 |
+
</adminhtml>
|
79 |
+
<global>
|
80 |
+
<models>
|
81 |
+
<pushnoteproducts>
|
82 |
+
<class>Contus_Pushnoteproducts_Model</class>
|
83 |
+
<resourceModel>pushnoteproducts_mysql4</resourceModel>
|
84 |
+
</pushnoteproducts>
|
85 |
+
|
86 |
+
</models>
|
87 |
+
|
88 |
+
<blocks>
|
89 |
+
<pushnoteproducts>
|
90 |
+
<class>Contus_Pushnoteproducts_Block</class>
|
91 |
+
</pushnoteproducts>
|
92 |
+
</blocks>
|
93 |
+
<helpers>
|
94 |
+
<pushnoteproducts>
|
95 |
+
<class>Contus_Pushnoteproducts_Helper</class>
|
96 |
+
</pushnoteproducts>
|
97 |
+
</helpers>
|
98 |
+
</global>
|
99 |
+
</config>
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_AddressBook
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest extends ContusRestapi_AddressBook_Model_Api2_AddressBookapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_AddressBook
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest_Admin_V1 extends ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_AddressBook
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest_Customer_V1 extends ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBook/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_AddressBook
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest_Guest_V1 extends ContusRestapi_AddressBook_Model_Api2_AddressBook_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/AddressBookapi.php
ADDED
@@ -0,0 +1,411 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_AddressBookapi extends Mage_Customer_Model_Api2_Customer_Address_Rest {
|
31 |
+
|
32 |
+
// define static variable
|
33 |
+
const STOREID = 'store_id';
|
34 |
+
const WEBSITE_ID = 'website_id';
|
35 |
+
const CUSTOMER_ID = 'customer_id';
|
36 |
+
const ADDRESS_ID = 'address_id';
|
37 |
+
const STREET = 'street';
|
38 |
+
const COUNTRY_ID = 'country_id';
|
39 |
+
const REGION = 'region';
|
40 |
+
const SUCCESS = 'success';
|
41 |
+
const MESSAGE = 'message';
|
42 |
+
const ERROR = 'error';
|
43 |
+
const RESULT = 'result';
|
44 |
+
const TOKEN = 'token';
|
45 |
+
const LOGIN_TOKEN = 'login/token';
|
46 |
+
const VALID_TOKEN = 'isValidToken';
|
47 |
+
const AUTH_FAIL = 'Authentication failed.';
|
48 |
+
const ENTITY_ID = 'entity_id';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Add New Address to Customer Address Book
|
52 |
+
*
|
53 |
+
* @param array $data
|
54 |
+
* @return array json array
|
55 |
+
*/
|
56 |
+
protected function _create(array $data) {
|
57 |
+
$response = array ();
|
58 |
+
// get website id
|
59 |
+
$websiteId = ( int ) $data [static::WEBSITE_ID];
|
60 |
+
if ($websiteId <= 0) {
|
61 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
62 |
+
}
|
63 |
+
// get website id from request
|
64 |
+
$storeId = ( int ) $data [static::STOREID];
|
65 |
+
if ($storeId <= 0) {
|
66 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
67 |
+
}
|
68 |
+
// set street address as array
|
69 |
+
$data [static::STREET] = json_decode ( '["' . ($data [static::STREET]) . '"]' );
|
70 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
71 |
+
// get token
|
72 |
+
$token = $data [static::TOKEN];
|
73 |
+
|
74 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
75 |
+
$customer = $this->_loadCustomerById ( $customerId );
|
76 |
+
$validator = $this->_getValidator ();
|
77 |
+
|
78 |
+
$data = $validator->filter ( $data );
|
79 |
+
if (! $validator->isValidData ( $data ) || ! $validator->isValidDataForCreateAssociationWithCountry ( $data )) {
|
80 |
+
foreach ( $validator->getErrors () as $error ) {
|
81 |
+
$this->_error ( $error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST );
|
82 |
+
$message = $error;
|
83 |
+
$success = 0;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
if (isset ( $data [static::REGION] ) && isset ( $data [static::COUNTRY_ID] )) {
|
88 |
+
$data [static::REGION] = $this->_getRegionIdByNameOrCode ( $data [static::REGION], $data [static::COUNTRY_ID] );
|
89 |
+
}
|
90 |
+
|
91 |
+
/* @var $address Mage_Customer_Model_Address */
|
92 |
+
$address = Mage::getModel ( 'customer/address' );
|
93 |
+
$address->setData ( $data );
|
94 |
+
$address->setCustomer ( $customer );
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Check this customer has valid token or not
|
98 |
+
*
|
99 |
+
* @var $isValidToken Mage_Login_Model_Token
|
100 |
+
*/
|
101 |
+
$addressData = array ();
|
102 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
103 |
+
if ($isValidToken) {
|
104 |
+
try {
|
105 |
+
$address->save ();
|
106 |
+
$success = 1;
|
107 |
+
$message = 'The address has been saved.';
|
108 |
+
// get address by customer id
|
109 |
+
$addressData = $this->_getAddressList ( $customerId, $storeId );
|
110 |
+
// assign address to result tag
|
111 |
+
$response [static::RESULT] = $addressData;
|
112 |
+
} catch ( Mage_Core_Exception $e ) {
|
113 |
+
$success = 0;
|
114 |
+
$message = $e->getMessage ();
|
115 |
+
}
|
116 |
+
$this->_getLocation ( $address );
|
117 |
+
} else {
|
118 |
+
$success = 0;
|
119 |
+
$message = static::AUTH_FAIL;
|
120 |
+
}
|
121 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
122 |
+
$response [static::ERROR] = false;
|
123 |
+
$response [static::SUCCESS] = $success;
|
124 |
+
$response [static::MESSAGE] = $message;
|
125 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
126 |
+
return;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* function that is called when put is done **
|
131 |
+
* Update Address from Customer Address Book
|
132 |
+
*
|
133 |
+
* @param array $data
|
134 |
+
* @return array json array
|
135 |
+
*/
|
136 |
+
protected function _update(array $data) {
|
137 |
+
$response = array ();
|
138 |
+
$addressData = array ();
|
139 |
+
// get website id
|
140 |
+
$websiteId = ( int ) $data [static::WEBSITE_ID];
|
141 |
+
if ($websiteId <= 0) {
|
142 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
143 |
+
}
|
144 |
+
// get website id from request
|
145 |
+
$storeId = ( int ) $data [static::STOREID];
|
146 |
+
if ($storeId <= 0) {
|
147 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
148 |
+
}
|
149 |
+
// get address id
|
150 |
+
$addressId = ( int ) $data [static::ADDRESS_ID];
|
151 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
152 |
+
// get token
|
153 |
+
$token = $data [static::TOKEN];
|
154 |
+
// set street address as array
|
155 |
+
$data [static::STREET] = json_decode ( '["' . ($data [static::STREET]) . '"]' );
|
156 |
+
|
157 |
+
/* @var $address Mage_Customer_Model_Address */
|
158 |
+
$address = $this->_loadCustomerAddressById ( $addressId );
|
159 |
+
$validator = $this->_getValidator ();
|
160 |
+
|
161 |
+
$data = $validator->filter ( $data );
|
162 |
+
if (! $validator->isValidData ( $data, true ) || ! $validator->isValidDataForChangeAssociationWithCountry ( $address, $data )) {
|
163 |
+
foreach ( $validator->getErrors () as $error ) {
|
164 |
+
$this->_error ( $error, Mage_Api2_Model_Server::HTTP_BAD_REQUEST );
|
165 |
+
$err_message = $error;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
if (isset ( $data [static::REGION] )) {
|
169 |
+
$data [static::REGION] = $this->_getRegionIdByNameOrCode ( $data [static::REGION], isset ( $data [static::COUNTRY_ID] ) ? $data [static::COUNTRY_ID] : $address->getCountryId () );
|
170 |
+
// to avoid overwrite region during update in address model _beforeSave()
|
171 |
+
$data ['region_id'] = null;
|
172 |
+
}
|
173 |
+
$address->addData ( $data );
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Check this customer has valid token or not
|
177 |
+
*
|
178 |
+
* @var $isValidToken Mage_Login_Model_Token
|
179 |
+
*/
|
180 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
181 |
+
if ($isValidToken) {
|
182 |
+
try {
|
183 |
+
$address->save ();
|
184 |
+
$success = 1;
|
185 |
+
$err_message = 'The address has been updated.';
|
186 |
+
// get address by customer
|
187 |
+
$addressData = $this->_getAddressList ( $customerId, $storeId );
|
188 |
+
// assign address to result tag
|
189 |
+
$response [static::RESULT] = $addressData;
|
190 |
+
} catch ( Mage_Core_Exception $e ) {
|
191 |
+
$success = 0;
|
192 |
+
$err_message = $e->getMessage ();
|
193 |
+
}
|
194 |
+
$response [static::VALID_TOKEN] = true;
|
195 |
+
} else {
|
196 |
+
$success = 0;
|
197 |
+
$err_message = static::AUTH_FAIL;
|
198 |
+
$response [static::VALID_TOKEN] = false;
|
199 |
+
}
|
200 |
+
|
201 |
+
$response [static::ERROR] = false;
|
202 |
+
$response [static::SUCCESS] = $success;
|
203 |
+
$response [static::MESSAGE] = $err_message;
|
204 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
205 |
+
return;
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* function that is called when delete is done **
|
210 |
+
* Delete Address from Customer Address Book
|
211 |
+
*
|
212 |
+
* @return array json array
|
213 |
+
*/
|
214 |
+
protected function _delete() {
|
215 |
+
$response = array ();
|
216 |
+
|
217 |
+
// get address id from request
|
218 |
+
$addressId = ( int ) $this->getRequest ()->getParam ( static::ADDRESS_ID );
|
219 |
+
// get website id from request
|
220 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITE_ID );
|
221 |
+
if ($websiteId <= 0) {
|
222 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
223 |
+
}
|
224 |
+
// get website id from request
|
225 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
226 |
+
if ($storeId <= 0) {
|
227 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
228 |
+
}
|
229 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
230 |
+
// get token
|
231 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
232 |
+
/* @var $address Mage_Customer_Model_Address */
|
233 |
+
$address = $this->_loadCustomerAddressById ( $addressId );
|
234 |
+
$delete = TRUE;
|
235 |
+
if ($this->_isDefaultBillingAddress ( $address ) || $this->_isDefaultShippingAddress ( $address )) {
|
236 |
+
$delete = FALSE;
|
237 |
+
}
|
238 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
239 |
+
if ($isValidToken) {
|
240 |
+
try {
|
241 |
+
if ($delete) {
|
242 |
+
$address->delete ();
|
243 |
+
$success = 1;
|
244 |
+
$message = 'The address has been deleted.';
|
245 |
+
} else {
|
246 |
+
$success = 0;
|
247 |
+
$message = 'Address is default for customer so is not allowed to be deleted.';
|
248 |
+
}
|
249 |
+
} catch ( Mage_Core_Exception $e ) {
|
250 |
+
$success = 0;
|
251 |
+
$message = $e->getMessage ();
|
252 |
+
} catch ( Exception $e ) {
|
253 |
+
$success = 0;
|
254 |
+
$message = $e->getMessage ();
|
255 |
+
}
|
256 |
+
} else {
|
257 |
+
$success = 0;
|
258 |
+
$message = static::AUTH_FAIL;
|
259 |
+
}
|
260 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
261 |
+
$response [static::ERROR] = false;
|
262 |
+
$response [static::SUCCESS] = $success;
|
263 |
+
$response [static::MESSAGE] = $message;
|
264 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
265 |
+
return;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Retrieve information about specified customer address
|
270 |
+
*
|
271 |
+
* @throws Mage_Api2_Exception
|
272 |
+
* @return array
|
273 |
+
*/
|
274 |
+
protected function _retrieve() {
|
275 |
+
/* @var $address Mage_Customer_Model_Address */
|
276 |
+
/**
|
277 |
+
* Check this customer has valid token or not
|
278 |
+
*
|
279 |
+
* @var $isValidToken Mage_Login_Model_Token
|
280 |
+
*/
|
281 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
282 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
283 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
284 |
+
if ($isValidToken) {
|
285 |
+
$address = $this->_loadCustomerAddressById ( $this->getRequest ()->getParam ( 'id' ) );
|
286 |
+
$addressData = $address->getData ();
|
287 |
+
$addressData [static::STREET] = $address->getStreet ();
|
288 |
+
$addressData ['region_code'] = $address->getRegionCode ();
|
289 |
+
$addressData [static::SUCCESS] = 1;
|
290 |
+
$addressData [static::MESSAGE] = 'Get Address Detail.';
|
291 |
+
} else {
|
292 |
+
$addressData [static::SUCCESS] = 0;
|
293 |
+
$addressData [static::MESSAGE] = static::AUTH_FAIL;
|
294 |
+
}
|
295 |
+
$addressData [static::VALID_TOKEN] = $isValidToken;
|
296 |
+
$addressData [static::ERROR] = false;
|
297 |
+
return $addressData;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Get customer addresses list
|
302 |
+
*
|
303 |
+
* @return array
|
304 |
+
*/
|
305 |
+
protected function _retrieveCollection() {
|
306 |
+
$response = array ();
|
307 |
+
|
308 |
+
// get website id from request
|
309 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITE_ID );
|
310 |
+
if ($websiteId <= 0) {
|
311 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
312 |
+
}
|
313 |
+
// get website id from request
|
314 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
315 |
+
if ($storeId <= 0) {
|
316 |
+
Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
317 |
+
}
|
318 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Check this customer has valid token or not
|
322 |
+
*
|
323 |
+
* @var $isValidToken Mage_Login_Model_Token
|
324 |
+
*/
|
325 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
326 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
327 |
+
if ($isValidToken) {
|
328 |
+
$data = $this->_getAddressList ( $customerId, $storeId );
|
329 |
+
|
330 |
+
if (count ( $data ) > 0) {
|
331 |
+
$message = 'Get Address Successfully.';
|
332 |
+
} else {
|
333 |
+
$message = 'No Address Available.';
|
334 |
+
}
|
335 |
+
$success = 1;
|
336 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
337 |
+
} else {
|
338 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
339 |
+
$message = static::AUTH_FAIL;
|
340 |
+
$success = 0;
|
341 |
+
}
|
342 |
+
$response [static::ERROR] = false;
|
343 |
+
$response [static::SUCCESS] = $success;
|
344 |
+
$response [static::MESSAGE] = $message;
|
345 |
+
$response [static::RESULT] = $data;
|
346 |
+
return json_encode ( $response );
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Retrieve customer address collection
|
351 |
+
*
|
352 |
+
* @param int $customerId
|
353 |
+
* @param int $storeId
|
354 |
+
* @return Mage_Customer_Model_Address
|
355 |
+
*/
|
356 |
+
public function _getAddressList($customerId, $storeId) {
|
357 |
+
$data = array ();
|
358 |
+
/* @var $address Mage_Customer_Model_Address */
|
359 |
+
|
360 |
+
foreach ( $this->_getCollectionForRetrieve ( $customerId ) as $address ) {
|
361 |
+
$address->setStoreId ( $storeId )->load ( $address->getEntityId () );
|
362 |
+
$addressData = $address->getData ();
|
363 |
+
$addressData [static::STREET] = $address->getStreet ();
|
364 |
+
$country = Mage::getModel ( 'directory/country' )->loadByCode ( $address->getCountryId () );
|
365 |
+
$addressData ['region_code'] = $address->getRegionCode ();
|
366 |
+
// get region id
|
367 |
+
$regionModel = Mage::getModel ( 'directory/region' )->loadByCode ( $address->getRegionCode (), $address->getCountryId () );
|
368 |
+
$addressData ['region_id'] = $regionModel->getId ();
|
369 |
+
// get country name
|
370 |
+
$addressData ['country_name'] = $country->getName ();
|
371 |
+
$data [] = array_merge ( $addressData, $this->_getDefaultAddressesInfo ( $address ) );
|
372 |
+
}
|
373 |
+
$sort = array ();
|
374 |
+
foreach ( $data as $k => $v ) {
|
375 |
+
$sort [static::ENTITY_ID] [$k] = $v [static::ENTITY_ID];
|
376 |
+
}
|
377 |
+
|
378 |
+
array_multisort ( $sort [static::ENTITY_ID], SORT_DESC, $data );
|
379 |
+
return $data;
|
380 |
+
}
|
381 |
+
|
382 |
+
/**
|
383 |
+
* Retrieve collection instances
|
384 |
+
*
|
385 |
+
* @param int $customerId
|
386 |
+
* @return Mage_Customer_Model_Resource_Address_Collection
|
387 |
+
*/
|
388 |
+
protected function _getCollectionForRetrieve($customerId) {
|
389 |
+
/* @var $customer Mage_Customer_Model_Customer */
|
390 |
+
$customer = $this->_loadCustomerById ( $customerId );
|
391 |
+
|
392 |
+
/* @var $collection Mage_Customer_Model_Resource_Address_Collection */
|
393 |
+
$collection = $customer->getAddressesCollection ();
|
394 |
+
|
395 |
+
$this->_applyCollectionModifiers ( $collection );
|
396 |
+
return $collection;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Get array with default addresses information if possible
|
401 |
+
*
|
402 |
+
* @param Mage_Customer_Model_Address $address
|
403 |
+
* @return array
|
404 |
+
*/
|
405 |
+
protected function _getDefaultAddressesInfo(Mage_Customer_Model_Address $address) {
|
406 |
+
return array (
|
407 |
+
'is_default_billing' => (( int ) $this->_isDefaultBillingAddress ( $address ) > 0),
|
408 |
+
'is_default_shipping' => (( int ) $this->_isDefaultShippingAddress ( $address ) > 0)
|
409 |
+
);
|
410 |
+
}
|
411 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/Country.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_Country extends Mage_Api2_Model_Resource {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get Country collection
|
34 |
+
* function that is called when post is done **
|
35 |
+
*/
|
36 |
+
protected function _retrieveCollection() {
|
37 |
+
$countries = array ();
|
38 |
+
$countryCollection = Mage::getResourceModel ( 'directory/country_collection' )->loadByStore ()->toOptionArray ();
|
39 |
+
if (count ( $countryCollection ) > 0) {
|
40 |
+
$i = 0;
|
41 |
+
foreach ( $countryCollection as $country ) {
|
42 |
+
if ($country ['value'] != '') {
|
43 |
+
$countries [$i] ['country_id'] = $country ['value'];
|
44 |
+
$countries [$i] ['name'] = $country ['label'];
|
45 |
+
$i ++;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
$response ['success'] = 1;
|
49 |
+
$response ['result'] = $countries;
|
50 |
+
} else {
|
51 |
+
$response ['success'] = 0;
|
52 |
+
$response ['result'] = $countries;
|
53 |
+
}
|
54 |
+
$response ['error'] = false;
|
55 |
+
return json_encode ( $response );
|
56 |
+
}
|
57 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_Country_Rest extends ContusRestapi_AddressBook_Model_Api2_Country {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_Country_Rest_Admin_V1 extends ContusRestapi_AddressBook_Model_Api2_Country_Rest {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_Country_Rest_Customer_V1 extends ContusRestapi_AddressBook_Model_Api2_Country_Rest {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/Country/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_Country_Rest_Guest_V1 extends ContusRestapi_AddressBook_Model_Api2_Country_Rest {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/State.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_State extends Mage_Api2_Model_Resource {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get States collection by Country code
|
34 |
+
* function that is called when post is done **
|
35 |
+
*/
|
36 |
+
protected function _retrieveCollection() {
|
37 |
+
$response = array ();
|
38 |
+
$countryCode = $this->getRequest ()->getParam ( 'countrycode' );
|
39 |
+
$regionCollection = Mage::getModel ( 'directory/region_api' )->items ( $countryCode );
|
40 |
+
if (count ( $regionCollection ) > 0) {
|
41 |
+
$response ['success'] = 1;
|
42 |
+
$response ['result'] = $regionCollection;
|
43 |
+
} else {
|
44 |
+
$response ['success'] = 0;
|
45 |
+
$response ['result'] = array();
|
46 |
+
}
|
47 |
+
$response ['error'] = false;
|
48 |
+
return json_encode ( $response );
|
49 |
+
}
|
50 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_State_Rest extends ContusRestapi_AddressBook_Model_Api2_State {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class Restapi_Cust_Model_Api2_State_Rest_Admin_V1 extends Restapi_Cust_Model_Api2_State_Rest {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/Model/Api2/State/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Country API
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_AddressBook
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_AddressBook_Model_Api2_State_Rest_Guest_V1 extends ContusRestapi_AddressBook_Model_Api2_State_Rest {
|
31 |
+
}
|
app/code/local/ContusRestapi/AddressBook/etc/api2.xml
ADDED
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="AddressBook">
|
6 |
+
<title>AddressBook</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<addressBook translate="title" module="AddressBook">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>addressBook/api2_addressBook</model>
|
14 |
+
<working_model>customer/address</working_model>
|
15 |
+
<title>AddressBook Api</title>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<privileges>
|
18 |
+
<admin>
|
19 |
+
<create>1</create>
|
20 |
+
<retrieve>1</retrieve>
|
21 |
+
<delete>1</delete>
|
22 |
+
<update>1</update>
|
23 |
+
</admin>
|
24 |
+
<customer>
|
25 |
+
<create>1</create>
|
26 |
+
<retrieve>1</retrieve>
|
27 |
+
<delete>1</delete>
|
28 |
+
<update>1</update>
|
29 |
+
</customer>
|
30 |
+
<guest>
|
31 |
+
<create>1</create>
|
32 |
+
<retrieve>1</retrieve>
|
33 |
+
<delete>1</delete>
|
34 |
+
<update>1</update>
|
35 |
+
</guest>
|
36 |
+
</privileges>
|
37 |
+
<attributes module="api2">
|
38 |
+
<website_id>Website id</website_id>
|
39 |
+
<store_id>Store Id</store_id>
|
40 |
+
<customer_id>customer Id</customer_id>
|
41 |
+
<address_id>Addrss ID</address_id>
|
42 |
+
<result>Result</result>
|
43 |
+
<success>success</success>
|
44 |
+
<message>message</message>
|
45 |
+
<entity_id>Customer Address ID</entity_id>
|
46 |
+
<is_default_billing>Is Default Billing Address</is_default_billing>
|
47 |
+
<is_default_shipping>Is Default Shipping Address</is_default_shipping>
|
48 |
+
<street>Street</street>
|
49 |
+
<city>City</city>
|
50 |
+
<firstname>first name</firstname>
|
51 |
+
<lastname>Last name</lastname>
|
52 |
+
<country_id>Country id</country_id>
|
53 |
+
<postcode>Postal Code</postcode>
|
54 |
+
<telephone>Telephone</telephone>
|
55 |
+
<company>Company</company>
|
56 |
+
<region>region</region>
|
57 |
+
<fax></fax>
|
58 |
+
<token>Token</token>
|
59 |
+
<country_name>Country name</country_name>
|
60 |
+
<isValidToken>Is Valid Token</isValidToken>
|
61 |
+
<success>Success</success>
|
62 |
+
<region_code>region_code</region_code>
|
63 |
+
<region_id>Region id</region_id>
|
64 |
+
</attributes>
|
65 |
+
|
66 |
+
<exclude_attributes>
|
67 |
+
<admin>
|
68 |
+
<read>
|
69 |
+
<region_id>1</region_id>
|
70 |
+
<vat_is_valid>1</vat_is_valid>
|
71 |
+
<vat_request_date>1</vat_request_date>
|
72 |
+
<vat_request_id>1</vat_request_id>
|
73 |
+
<vat_request_success>1</vat_request_success>
|
74 |
+
</read>
|
75 |
+
<write>
|
76 |
+
<entity_id>1</entity_id>
|
77 |
+
<region_id>1</region_id>
|
78 |
+
<vat_is_valid>1</vat_is_valid>
|
79 |
+
<vat_request_date>1</vat_request_date>
|
80 |
+
<vat_request_id>1</vat_request_id>
|
81 |
+
<vat_request_success>1</vat_request_success>
|
82 |
+
</write>
|
83 |
+
</admin>
|
84 |
+
<customer>
|
85 |
+
<read>
|
86 |
+
<region_id>1</region_id>
|
87 |
+
</read>
|
88 |
+
<write>
|
89 |
+
<entity_id>1</entity_id>
|
90 |
+
<region_id>1</region_id>
|
91 |
+
</write>
|
92 |
+
</customer>
|
93 |
+
</exclude_attributes>
|
94 |
+
<validators>
|
95 |
+
<eav>
|
96 |
+
<admin>
|
97 |
+
<entity_model>customer/address</entity_model>
|
98 |
+
<form_model>customer/form</form_model>
|
99 |
+
<form_code>
|
100 |
+
<update>adminhtml_customer_address</update>
|
101 |
+
</form_code>
|
102 |
+
</admin>
|
103 |
+
<customer>
|
104 |
+
<entity_model>customer/address</entity_model>
|
105 |
+
<form_model>customer/form</form_model>
|
106 |
+
<form_code>
|
107 |
+
<update>customer_address_edit</update>
|
108 |
+
</form_code>
|
109 |
+
</customer>
|
110 |
+
<guest>
|
111 |
+
<entity_model>customer/address</entity_model>
|
112 |
+
<form_model>customer/form</form_model>
|
113 |
+
<form_code>
|
114 |
+
<update>customer_address_edit</update>
|
115 |
+
</form_code>
|
116 |
+
</guest>
|
117 |
+
</eav>
|
118 |
+
</validators>
|
119 |
+
|
120 |
+
<routes>
|
121 |
+
<route_collection>
|
122 |
+
<!-- Add New Address -->
|
123 |
+
<route>/addressbook/add/</route>
|
124 |
+
<action_type>collection</action_type>
|
125 |
+
</route_collection>
|
126 |
+
|
127 |
+
<!-- Update address -->
|
128 |
+
<address_update>
|
129 |
+
<route>/addressbook/update/</route>
|
130 |
+
<action_type>entity</action_type>
|
131 |
+
</address_update>
|
132 |
+
|
133 |
+
<!-- Address detail -->
|
134 |
+
<address_detail>
|
135 |
+
<route>/address_detail/</route>
|
136 |
+
<action_type>entity</action_type>
|
137 |
+
</address_detail>
|
138 |
+
|
139 |
+
<!-- Address book collection -->
|
140 |
+
<address_collection>
|
141 |
+
<route>/addressbook/</route>
|
142 |
+
<action_type>collection</action_type>
|
143 |
+
</address_collection>
|
144 |
+
|
145 |
+
<!-- Delete Address book collection -->
|
146 |
+
<address_delete>
|
147 |
+
<route>/addressbook/delete/address_id/:address_id/customer_id/:customer_id/store_id/:store_id/website_id/:website_id/token/:token</route>
|
148 |
+
<action_type>entity</action_type>
|
149 |
+
</address_delete>
|
150 |
+
|
151 |
+
</routes>
|
152 |
+
<versions>1</versions>
|
153 |
+
</addressBook>
|
154 |
+
|
155 |
+
<addressBook_country translate="title" module="AddressBook">
|
156 |
+
<group>contusrestapi</group>
|
157 |
+
<model>addressBook/api2_country</model>
|
158 |
+
<title>Country</title>
|
159 |
+
<sort_order>16</sort_order>
|
160 |
+
<privileges>
|
161 |
+
<admin>
|
162 |
+
<create>1</create>
|
163 |
+
<retrieve>1</retrieve>
|
164 |
+
<delete>1</delete>
|
165 |
+
</admin>
|
166 |
+
<customer>
|
167 |
+
<create>1</create>
|
168 |
+
<retrieve>1</retrieve>
|
169 |
+
<delete>1</delete>
|
170 |
+
</customer>
|
171 |
+
<guest>
|
172 |
+
<create>1</create>
|
173 |
+
<retrieve>1</retrieve>
|
174 |
+
<delete>1</delete>
|
175 |
+
</guest>
|
176 |
+
</privileges>
|
177 |
+
<attributes module="api2">
|
178 |
+
<status>status</status>
|
179 |
+
<message>message</message>
|
180 |
+
<website_id>Website Id</website_id>
|
181 |
+
</attributes>
|
182 |
+
<routes>
|
183 |
+
<route_collection>
|
184 |
+
<route>/countrycollection</route>
|
185 |
+
<action_type>collection</action_type>
|
186 |
+
</route_collection>
|
187 |
+
</routes>
|
188 |
+
<versions>1</versions>
|
189 |
+
</addressBook_country>
|
190 |
+
|
191 |
+
<addressBook_state translate="title" module="AddressBook">
|
192 |
+
<group>contusrestapi</group>
|
193 |
+
<model>addressBook/api2_state</model>
|
194 |
+
<title>State</title>
|
195 |
+
<sort_order>17</sort_order>
|
196 |
+
<privileges>
|
197 |
+
<admin>
|
198 |
+
<create>1</create>
|
199 |
+
<retrieve>1</retrieve>
|
200 |
+
<delete>1</delete>
|
201 |
+
</admin>
|
202 |
+
<customer>
|
203 |
+
<create>1</create>
|
204 |
+
<retrieve>1</retrieve>
|
205 |
+
<delete>1</delete>
|
206 |
+
</customer>
|
207 |
+
<guest>
|
208 |
+
<create>1</create>
|
209 |
+
<retrieve>1</retrieve>
|
210 |
+
<delete>1</delete>
|
211 |
+
</guest>
|
212 |
+
</privileges>
|
213 |
+
<attributes module="api2">
|
214 |
+
<status>status</status>
|
215 |
+
<message>message</message>
|
216 |
+
<countrycode>country code</countrycode>
|
217 |
+
<website_id>Website Id</website_id>
|
218 |
+
<result>Result</result>
|
219 |
+
</attributes>
|
220 |
+
<routes>
|
221 |
+
<route_collection>
|
222 |
+
<route>/statecollection/:countrycode</route>
|
223 |
+
<action_type>collection</action_type>
|
224 |
+
</route_collection>
|
225 |
+
</routes>
|
226 |
+
<versions>1</versions>
|
227 |
+
</addressBook_state>
|
228 |
+
|
229 |
+
</resources>
|
230 |
+
</api2>
|
231 |
+
</config>
|
app/code/local/ContusRestapi/AddressBook/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_AddressBook>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_AddressBook>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<addressBook>
|
11 |
+
<class>ContusRestapi_AddressBook_Model</class>
|
12 |
+
</addressBook>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ApplyCoupon
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest extends ContusRestapi_ApplyCoupon_Model_Api2_ApplyCouponapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ApplyCoupon
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest_Admin_V1 extends ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ApplyCoupon
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest_Customer_V1 extends ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCoupon/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ApplyCoupon
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest_Guest_V1 extends ContusRestapi_ApplyCoupon_Model_Api2_ApplyCoupon_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ApplyCoupon/Model/Api2/ApplyCouponapi.php
ADDED
@@ -0,0 +1,329 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Apply Coupon API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_ApplyCoupon
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_ApplyCoupon_Model_Api2_ApplyCouponapi extends Mage_Api2_Model_Resource {
|
32 |
+
|
33 |
+
// define static variable
|
34 |
+
const STOREID = 'store_id';
|
35 |
+
const WEBSITE_ID = 'website_id';
|
36 |
+
const CUSTOMER_ID = 'customer_id';
|
37 |
+
const COUPON_CODE = 'coupon_code';
|
38 |
+
const QUOTE_ID = 'quote_id';
|
39 |
+
const SHIPPING_AMT = 'shipping_amount';
|
40 |
+
const TAX = 'tax';
|
41 |
+
const DISCOUNT = 'discount';
|
42 |
+
const SALSE_QUOTE = 'sales/quote';
|
43 |
+
const SUCCESS = 'success';
|
44 |
+
const MESSAGE = 'message';
|
45 |
+
const RESULT = 'result';
|
46 |
+
const VALID_COUPON = 'valid_coupon';
|
47 |
+
const ERR_MSG = 'Coupon code is not valid.';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* function that is called when post is done **
|
51 |
+
* Apply coupon code to cart
|
52 |
+
*
|
53 |
+
* @param array $data
|
54 |
+
* @return array json array
|
55 |
+
*/
|
56 |
+
protected function _create(array $data) {
|
57 |
+
$response = array ();
|
58 |
+
|
59 |
+
$websiteId = ( int ) $data [static::WEBSITE_ID];
|
60 |
+
if ($websiteId <= 0) {
|
61 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
62 |
+
}
|
63 |
+
// get quote id from request
|
64 |
+
$quoteId = ( int ) $data [static::QUOTE_ID];
|
65 |
+
// get customer id
|
66 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
67 |
+
// get website id from request
|
68 |
+
$storeId = ( int ) $data [static::STOREID];
|
69 |
+
if ($storeId <= 0) {
|
70 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
71 |
+
}
|
72 |
+
|
73 |
+
// load customer by email id
|
74 |
+
$customer = Mage::getModel ( "customer/customer" );
|
75 |
+
$customer->load ( $customerId );
|
76 |
+
$customerGroupId = $customer->getGroupId ();
|
77 |
+
|
78 |
+
$quote = Mage::getModel ( static::SALSE_QUOTE );
|
79 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
80 |
+
$cartCount = $quote->getItemsCount ();
|
81 |
+
$couponCode = $data [static::COUPON_CODE];
|
82 |
+
$oCoupon = Mage::getModel ( 'salesrule/coupon' )->load ( $couponCode, 'code' );
|
83 |
+
$oRule = Mage::getModel ( 'salesrule/rule' )->load ( $oCoupon->getRuleId () );
|
84 |
+
$couponDetails = $oRule->getData ();
|
85 |
+
// check coupon code valid for this quote
|
86 |
+
$result = $this->validateCoupon ( $couponDetails, $customerGroupId, $websiteId, $cartCount );
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Check this customer has valid token or not
|
90 |
+
*
|
91 |
+
* @var $isValidToken Mage_Login_Model_Token
|
92 |
+
*/
|
93 |
+
|
94 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
95 |
+
if (! $isValidToken) {
|
96 |
+
$result [static::VALID_COUPON] = FALSE;
|
97 |
+
$result [static::MESSAGE] = 'Authentication failed.';
|
98 |
+
}
|
99 |
+
|
100 |
+
if ($result [static::VALID_COUPON]) {
|
101 |
+
|
102 |
+
$oldCouponCode = $quote->getCouponCode ();
|
103 |
+
if (! strlen ( $couponCode ) && ! strlen ( $oldCouponCode )) {
|
104 |
+
$success = 0;
|
105 |
+
$message = static::ERR_MSG;
|
106 |
+
}
|
107 |
+
|
108 |
+
try {
|
109 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( true );
|
110 |
+
$quote->setCouponCode ( strlen ( $couponCode ) ? $couponCode : '' )->collectTotals ()->save ();
|
111 |
+
$success = 1;
|
112 |
+
$message = 'Coupon code was applied.';
|
113 |
+
|
114 |
+
} catch ( Exception $e ) {
|
115 |
+
$success = 0;
|
116 |
+
$message = $e->getMessage ();
|
117 |
+
}
|
118 |
+
|
119 |
+
if (! $couponCode == $quote->getCouponCode ()) {
|
120 |
+
$success = 0;
|
121 |
+
$message = static::ERR_MSG;
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
$success = 0;
|
125 |
+
$message = $result [static::MESSAGE];
|
126 |
+
}
|
127 |
+
|
128 |
+
$cartproducts = $this->getCartAmountDetails ( array (
|
129 |
+
static::STOREID => $storeId,
|
130 |
+
static::CUSTOMER_ID => $customerId
|
131 |
+
) );
|
132 |
+
$response [static::RESULT] = $cartproducts [static::RESULT];
|
133 |
+
|
134 |
+
$response ['isValidToken'] = $isValidToken;
|
135 |
+
$response ['error'] = false;
|
136 |
+
$response [static::SUCCESS] = $success;
|
137 |
+
$response [static::MESSAGE] = $message;
|
138 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Cancel Coupon code from cart
|
144 |
+
*
|
145 |
+
* @param array $data
|
146 |
+
* @return array json array
|
147 |
+
*/
|
148 |
+
protected function _update(array $data) {
|
149 |
+
$response = array ();
|
150 |
+
// get website id
|
151 |
+
$websiteId = ( int ) $data [static::WEBSITE_ID];
|
152 |
+
if ($websiteId <= 0) {
|
153 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
154 |
+
}
|
155 |
+
// get website id from request
|
156 |
+
$storeId = ( int ) $data [static::STOREID];
|
157 |
+
if ($storeId <= 0) {
|
158 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
159 |
+
}
|
160 |
+
// get quote id from request
|
161 |
+
$quoteId = ( int ) $data [static::QUOTE_ID];
|
162 |
+
// get customer id
|
163 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
164 |
+
|
165 |
+
Mage::helper ( 'checkout/cart' )->getQuote ()->setData ( static::COUPON_CODE, '' )->save ();
|
166 |
+
$quote = Mage::getModel ( static::SALSE_QUOTE );
|
167 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Check this customer has valid token or not
|
171 |
+
*
|
172 |
+
* @var $isValidToken Mage_Login_Model_Token
|
173 |
+
*/
|
174 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
175 |
+
if ($isValidToken) {
|
176 |
+
try {
|
177 |
+
$quote->setData ( static::COUPON_CODE, '' )->collectTotals ()->save ();
|
178 |
+
$success = 1;
|
179 |
+
$message = 'Coupon code was canceled.';
|
180 |
+
$cartproducts = $this->getCartAmountDetails ( array (
|
181 |
+
static::STOREID => $storeId,
|
182 |
+
static::CUSTOMER_ID => $customerId
|
183 |
+
) );
|
184 |
+
$response [static::RESULT] = $cartproducts [static::RESULT];
|
185 |
+
} catch ( Exception $e ) {
|
186 |
+
$success = 0;
|
187 |
+
$message = $e->getMessage ();
|
188 |
+
}
|
189 |
+
} else {
|
190 |
+
$success = 0;
|
191 |
+
$message = 'Authentication failed.';
|
192 |
+
}
|
193 |
+
$response ['isValidToken'] = $isValidToken;
|
194 |
+
$response ['error'] = false;
|
195 |
+
$response [static::SUCCESS] = $success;
|
196 |
+
$response [static::MESSAGE] = $message;
|
197 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Get cart amount details
|
203 |
+
*
|
204 |
+
* @param array $data
|
205 |
+
* @return mixed array $response
|
206 |
+
*/
|
207 |
+
public function getCartAmountDetails($data) {
|
208 |
+
|
209 |
+
// get store_id
|
210 |
+
$storeId = $data [static::STOREID];
|
211 |
+
// get customer id
|
212 |
+
$customerId = $data [static::CUSTOMER_ID];
|
213 |
+
|
214 |
+
$quote = Mage::getModel ( static::SALSE_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMER_ID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( 'is_active', '1' )->setOrder ( 'entity_id', 'desc' );
|
215 |
+
$quoteData = $quote->getData ();
|
216 |
+
$quoteId = $quoteData [0] ['entity_id'];
|
217 |
+
$quote = $this->_getQuote ( $quoteId, $storeId );
|
218 |
+
$totals = $quote->getTotals ();
|
219 |
+
if (isset ( $totals [static::DISCOUNT] )) {
|
220 |
+
$discount = number_format ( abs ( $totals [static::DISCOUNT]->getValue () ), 2, '.', '' );
|
221 |
+
} else {
|
222 |
+
$discount = '';
|
223 |
+
}
|
224 |
+
|
225 |
+
$returnArray = array ();
|
226 |
+
|
227 |
+
if (isset ( $quoteData ) && ! empty ( $quoteData )) {
|
228 |
+
$itemCount = $quoteData [0] ['items_count'];
|
229 |
+
if ($itemCount > 0) {
|
230 |
+
$returnArray ['item_count'] = $itemCount;
|
231 |
+
$returnArray ['grand_total'] = number_format ( $quoteData [0] ['grand_total'], 2, '.', '' );
|
232 |
+
$returnArray ['subtotal'] = number_format ( $quoteData [0] ['subtotal'], 2, '.', '' );
|
233 |
+
$returnArray [static::DISCOUNT] = $discount;
|
234 |
+
$returnArray [static::QUOTE_ID] = $quoteId;
|
235 |
+
$returnArray [static::COUPON_CODE] = $quoteData [0] [static::COUPON_CODE];
|
236 |
+
$addressobj = $quote->getShippingAddress ();
|
237 |
+
$returnArray [static::SHIPPING_AMT] = 0;
|
238 |
+
$returnArray [static::TAX] = 0;
|
239 |
+
if ($addressobj) {
|
240 |
+
$returnArray [static::SHIPPING_AMT] = $quote->getShippingAddress ()->getData ( static::SHIPPING_AMT );
|
241 |
+
$returnArray [static::TAX] = $quote->getShippingAddress ()->getData ( 'tax_amount' );
|
242 |
+
|
243 |
+
$returnArray [static::SHIPPING_AMT] = number_format ( $returnArray [static::SHIPPING_AMT], 2, '.', '' );
|
244 |
+
$returnArray [static::TAX] = number_format ( $returnArray [static::TAX], 2, '.', '' );
|
245 |
+
}
|
246 |
+
|
247 |
+
$success = 1;
|
248 |
+
$message = 'Quote fetched successfully.';
|
249 |
+
} else {
|
250 |
+
|
251 |
+
$success = 0;
|
252 |
+
$message = 'No items in your cart.';
|
253 |
+
}
|
254 |
+
} else {
|
255 |
+
|
256 |
+
$success = 0;
|
257 |
+
$message = 'No items in your cart.';
|
258 |
+
}
|
259 |
+
$response [static::RESULT] = $returnArray;
|
260 |
+
$response [static::SUCCESS] = $success;
|
261 |
+
$response [static::MESSAGE] = $message;
|
262 |
+
return $response;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
*
|
267 |
+
* @param integer $quoteId
|
268 |
+
* @param integer $storeId
|
269 |
+
* @return mixed array $quote
|
270 |
+
*/
|
271 |
+
protected function _getQuote($quoteId, $storeId) {
|
272 |
+
/**
|
273 |
+
*
|
274 |
+
* @var $quote Mage_Sales_Model_Quote
|
275 |
+
*/
|
276 |
+
$quote = Mage::getModel ( static::SALSE_QUOTE );
|
277 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
278 |
+
return $quote;
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Check given coupon valid or not
|
283 |
+
*
|
284 |
+
* @param array $couponDetails
|
285 |
+
* @param int $customerGroupId
|
286 |
+
* @param int $websiteId
|
287 |
+
* @return array $result
|
288 |
+
*/
|
289 |
+
public function validateCoupon($couponDetails, $customerGroupId, $websiteId, $cartCount) {
|
290 |
+
$apply_coupon = TRUE;
|
291 |
+
$errorMsg = '';
|
292 |
+
if ($cartCount <= 0) {
|
293 |
+
$apply_coupon = FALSE;
|
294 |
+
$errorMsg = 'Cart is Empty';
|
295 |
+
}
|
296 |
+
// check coupon code is active
|
297 |
+
if ($couponDetails [static::COUPON_CODE] == '') {
|
298 |
+
$apply_coupon = FALSE;
|
299 |
+
$errorMsg = 'Coupon code is wrong.';
|
300 |
+
}
|
301 |
+
// check coupon code is active
|
302 |
+
if ($couponDetails ['is_active'] != 1) {
|
303 |
+
$apply_coupon = FALSE;
|
304 |
+
$errorMsg = static::ERR_MSG;
|
305 |
+
}
|
306 |
+
// check coupon is available for customer group
|
307 |
+
if (! in_array ( $customerGroupId, $couponDetails ['customer_group_ids'] )) {
|
308 |
+
$apply_coupon = FALSE;
|
309 |
+
$errorMsg = static::ERR_MSG;
|
310 |
+
}
|
311 |
+
// check coupon is available for website
|
312 |
+
if (! in_array ( $websiteId, $couponDetails ['website_ids'] )) {
|
313 |
+
$apply_coupon = FALSE;
|
314 |
+
$errorMsg = static::ERR_MSG;
|
315 |
+
}
|
316 |
+
// check coupon expiry date
|
317 |
+
// Get today date
|
318 |
+
$today_date = Date ( 'Y-m-d' );
|
319 |
+
|
320 |
+
if (($couponDetails ['from_date'] != '' && $today_date <= $couponDetails ['from_date']) || ($couponDetails ['to_date'] != '' && $today_date >= $couponDetails ['to_date'])) {
|
321 |
+
$apply_coupon = FALSE;
|
322 |
+
$errorMsg = 'Coupon code is expired.';
|
323 |
+
}
|
324 |
+
|
325 |
+
$result [static::VALID_COUPON] = $apply_coupon;
|
326 |
+
$result [static::MESSAGE] = $errorMsg;
|
327 |
+
return $result;
|
328 |
+
}
|
329 |
+
}
|
app/code/local/ContusRestapi/ApplyCoupon/etc/api2.xml
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="ApplyCoupon">
|
6 |
+
<title>Apply Coupon Api</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<applyCoupon translate="title" module="ApplyCoupon">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>applyCoupon/api2_applyCoupon</model>
|
14 |
+
<title>Apply Coupon Api</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
<update>1</update>
|
22 |
+
</admin>
|
23 |
+
<customer>
|
24 |
+
<create>1</create>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
<delete>1</delete>
|
27 |
+
<update>1</update>
|
28 |
+
</customer>
|
29 |
+
<guest>
|
30 |
+
<create>1</create>
|
31 |
+
<retrieve>1</retrieve>
|
32 |
+
<delete>1</delete>
|
33 |
+
<update>1</update>
|
34 |
+
</guest>
|
35 |
+
</privileges>
|
36 |
+
<attributes module="api2">
|
37 |
+
<website_id>Website id</website_id>
|
38 |
+
<store_id>Store Id</store_id>
|
39 |
+
<customer_id>customer Id</customer_id>
|
40 |
+
<quote_id>quote Id</quote_id>
|
41 |
+
<coupon_code>Coupon Code</coupon_code>
|
42 |
+
<result>Result</result>
|
43 |
+
<success>success</success>
|
44 |
+
<message>message</message>
|
45 |
+
<token>Token</token>
|
46 |
+
</attributes>
|
47 |
+
<routes>
|
48 |
+
<route_collection>
|
49 |
+
<!-- Apply Coupon to Cart -->
|
50 |
+
<route>/coupon/apply</route>
|
51 |
+
<action_type>collection</action_type>
|
52 |
+
</route_collection>
|
53 |
+
|
54 |
+
<!-- Cancel coupon from cart -->
|
55 |
+
<coupon_update>
|
56 |
+
<route>/coupon/cancel/</route>
|
57 |
+
<action_type>entity</action_type>
|
58 |
+
</coupon_update>
|
59 |
+
|
60 |
+
</routes>
|
61 |
+
<versions>1</versions>
|
62 |
+
</applyCoupon>
|
63 |
+
|
64 |
+
</resources>
|
65 |
+
</api2>
|
66 |
+
</config>
|
app/code/local/ContusRestapi/ApplyCoupon/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ApplyCoupon>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_ApplyCoupon>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<applyCoupon>
|
11 |
+
<class>ContusRestapi_ApplyCoupon_Model</class>
|
12 |
+
</applyCoupon>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_CartAddressapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi extends Mage_Api2_Model_Resource {
|
30 |
+
|
31 |
+
/**
|
32 |
+
* function that is called when post is done **
|
33 |
+
* Get active shipping and payment Methods
|
34 |
+
*
|
35 |
+
* @return array json array
|
36 |
+
*/
|
37 |
+
protected function _create(array $data) {
|
38 |
+
$response = array ();
|
39 |
+
$ship_payment = array ();
|
40 |
+
// get website id
|
41 |
+
$websiteId = ( int ) $data ['website_id'];
|
42 |
+
if ($websiteId <= 0) {
|
43 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
44 |
+
}
|
45 |
+
// get website id from request
|
46 |
+
$storeId = ( int ) $data ['store_id'];
|
47 |
+
if ($storeId <= 0) {
|
48 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
49 |
+
}
|
50 |
+
// get customer id
|
51 |
+
$customerId = ( int ) $data ['customer_id'];
|
52 |
+
|
53 |
+
// get quote id
|
54 |
+
$quoteId = ( int ) $data ['quote_id'];
|
55 |
+
// get default billing address id
|
56 |
+
$billing_addressId = ( int ) $data ['billing_address_id'];
|
57 |
+
// get default shipping address id
|
58 |
+
$shipping_addressId = ( int ) $data ['shipping_address_id'];
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Check this customer has valid token or not
|
62 |
+
*
|
63 |
+
* @var $isValidToken Mage_Login_Model_Token
|
64 |
+
*/
|
65 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
66 |
+
if ($quoteId && $isValidToken) {
|
67 |
+
try {
|
68 |
+
$quote = Mage::getModel ( 'sales/quote' );
|
69 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
70 |
+
|
71 |
+
$active = $quote->getIsActive ();
|
72 |
+
if (! $active) {
|
73 |
+
throw new Exception ( 'Quote is invalid!.' );
|
74 |
+
}
|
75 |
+
|
76 |
+
// Set billing address
|
77 |
+
$quoteBillingAddress = Mage::getModel ( 'sales/quote_address' );
|
78 |
+
if ($billing_addressId > 0 && $shipping_addressId > 0) {
|
79 |
+
$quoteBillingAddress->setStoreId ( $storeId )->setCustomerId ( $customerId )->setCustomerAddressId ( $billing_addressId );
|
80 |
+
$billingAddress = Mage::getModel ( 'customer/address' )->load ( $billing_addressId );
|
81 |
+
$quoteBillingAddress->setData ( $billingAddress->getData () );
|
82 |
+
$quote->setBillingAddress ( $quoteBillingAddress );
|
83 |
+
|
84 |
+
// set shipping adress
|
85 |
+
$quoteShippingAddress = Mage::getModel ( 'sales/quote_address' );
|
86 |
+
$quoteShippingAddress->setStoreId ( $storeId )->setCustomerId ( $customerId )->setCustomerAddressId ( $shipping_addressId );
|
87 |
+
$shippingAddress = Mage::getModel ( 'customer/address' )->load ( $shipping_addressId );
|
88 |
+
|
89 |
+
$quoteShippingAddress->setData ( $shippingAddress->getData () );
|
90 |
+
$quote->setShippingAddress ( $quoteShippingAddress );
|
91 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( true );
|
92 |
+
$quote->collectTotals ();
|
93 |
+
$quote->setIsActive ( 1 );
|
94 |
+
$quote->save ();
|
95 |
+
|
96 |
+
$success = 1;
|
97 |
+
$message = "Billing and Shipping Address added successfully.";
|
98 |
+
} else {
|
99 |
+
$success = 0;
|
100 |
+
$message = "Please select billing and shipping address.";
|
101 |
+
}
|
102 |
+
$ship_payment = Mage::getModel ( 'login/methods_functions' )->getShippingPaymentMethods ( $quoteId, $storeId );
|
103 |
+
} catch ( Exception $e ) {
|
104 |
+
$success = 0;
|
105 |
+
$message = $e->getMessage ();
|
106 |
+
}
|
107 |
+
} else {
|
108 |
+
$success = 0;
|
109 |
+
$message = "Authentication failed.";
|
110 |
+
}
|
111 |
+
$response ['isValidToken'] = $isValidToken;
|
112 |
+
$response ['error'] = false;
|
113 |
+
$response ['success'] = $success;
|
114 |
+
$response ['message'] = $message;
|
115 |
+
$response ['result'] = $ship_payment;
|
116 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
}
|
app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_CartAddressapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest extends ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_CartAddressapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest_Admin_V1 extends ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_CartAddressapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest_Customer_V1 extends ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/CartAddressapi/Model/Api2/CartAddressapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_CartAddressapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest_Guest_V1 extends ContusRestapi_CartAddressapi_Model_Api2_CartAddressapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/CartAddressapi/etc/api2.xml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="CartAddressapi">
|
6 |
+
<title>Cart Address API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<cartAddressapi translate="title" module="CartAddressapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>cartAddressapi/api2_cartAddressapi</model>
|
14 |
+
<title>Cart Address</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
</customer>
|
26 |
+
<guest>
|
27 |
+
<create>1</create>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes module="api2">
|
32 |
+
<website_id>websiteid</website_id>
|
33 |
+
<store_id>Associate to Store</store_id>
|
34 |
+
<quote_id>Shopping cart Id</quote_id>
|
35 |
+
<billing_address_id>Billing Address Id</billing_address_id>
|
36 |
+
<shipping_address_id>Shipping Address Id</shipping_address_id>
|
37 |
+
<address_type>address_type</address_type>
|
38 |
+
<same_for_shipping>same_for_shipping</same_for_shipping>
|
39 |
+
<first_name>first_name</first_name>
|
40 |
+
<last_name>last_name</last_name>
|
41 |
+
<address1>address1</address1>
|
42 |
+
<city>city</city>
|
43 |
+
<state>state</state>
|
44 |
+
<zip>zip</zip>
|
45 |
+
<country>country</country>
|
46 |
+
<telephone>telephone</telephone>
|
47 |
+
<success>success</success>
|
48 |
+
<message>message</message>
|
49 |
+
<token>Token</token>
|
50 |
+
<customer_id>Customer Id</customer_id>
|
51 |
+
</attributes>
|
52 |
+
<routes>
|
53 |
+
|
54 |
+
<address_add>
|
55 |
+
<route>/cart_address/add/</route>
|
56 |
+
<action_type>collection</action_type>
|
57 |
+
</address_add>
|
58 |
+
|
59 |
+
</routes>
|
60 |
+
<versions>1</versions>
|
61 |
+
</cartAddressapi>
|
62 |
+
|
63 |
+
</resources>
|
64 |
+
</api2>
|
65 |
+
</config>
|
app/code/local/ContusRestapi/CartAddressapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_CartAddressapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_CartAddressapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<cartAddressapi>
|
11 |
+
<class>ContusRestapi_CartAddressapi_Model</class>
|
12 |
+
</cartAddressapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi.php
ADDED
@@ -0,0 +1,652 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Cart Api
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Cartapi
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Cartapi_Model_Api2_Cartapi extends Mage_Api2_Model_Resource {
|
32 |
+
// define staic variable
|
33 |
+
const STOREID = 'store_id';
|
34 |
+
const WEBSITEID = 'website_id';
|
35 |
+
const CUSTOMER_ID = 'customer_id';
|
36 |
+
const ENTITYID = 'entity_id';
|
37 |
+
const PRODUCT_ID = 'product_id';
|
38 |
+
const QUOTE_ID = 'quote_id';
|
39 |
+
const SLAES_QUOTE = 'sales/quote';
|
40 |
+
const IS_STOCK = 'is_stock';
|
41 |
+
const STOCK_QTY = 'stock_qty';
|
42 |
+
const CATALOG_STOCK = 'cataloginventory/stock_item';
|
43 |
+
const SUCCESS = 'success';
|
44 |
+
const MESSAGE = 'message';
|
45 |
+
const ERROR = 'error';
|
46 |
+
const RESULT = 'result';
|
47 |
+
const TOKEN = 'token';
|
48 |
+
const LOGIN_TOKEN = 'login/token';
|
49 |
+
const VALID_TOKEN = 'isValidToken';
|
50 |
+
const AUTH_FAIL = 'Authentication failed.';
|
51 |
+
const CUSTOM_OPTION = 'custom_option';
|
52 |
+
const OPTIONS = 'options';
|
53 |
+
const SUPER_ATTR = 'super_attribute';
|
54 |
+
const SUPER_GRP = 'super_group';
|
55 |
+
const QTY = 'qty';
|
56 |
+
const DISCOUNT = 'discount';
|
57 |
+
const SHIPPING_AMT = 'shipping_amount';
|
58 |
+
const TAX = 'tax';
|
59 |
+
const ITEM_COUNT = 'item_count';
|
60 |
+
const GRAND_TOTAL = 'grand_total';
|
61 |
+
const SUBTOTAL = 'subtotal';
|
62 |
+
const COUPON_CODE = 'coupon_code';
|
63 |
+
const NO_ITEM = 'No items in your cart.';
|
64 |
+
const ITEMS_COUNT = 'items_count';
|
65 |
+
const LINKS = 'links';
|
66 |
+
const ITEMS_QTY = 'items_qty';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Add product to cart
|
70 |
+
*
|
71 |
+
* @param array $data
|
72 |
+
* @return array json array
|
73 |
+
*/
|
74 |
+
protected function _create(array $data) {
|
75 |
+
$response = array ();
|
76 |
+
|
77 |
+
// Get website id
|
78 |
+
$websiteId = (isset ( $data [static::WEBSITEID] )) ? $data [static::WEBSITEID] : Mage::app ()->getWebsite ( 'base' )->getId ();
|
79 |
+
// get store id
|
80 |
+
$storeId = (isset ( $data [static::STOREID] )) ? $data [static::STOREID] : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
81 |
+
// get customer id
|
82 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
83 |
+
// get product Id from request
|
84 |
+
$productId = ( int ) $data [static::PRODUCT_ID];
|
85 |
+
$qty = ( int ) $data [static::QTY];
|
86 |
+
if ($qty <= 0) {
|
87 |
+
$qty = 1;
|
88 |
+
}
|
89 |
+
// get base currency code
|
90 |
+
$currencyCode = (isset ( $data ['currencyCode'] )) ? $data ['currencyCode'] : Mage::app ()->getStore ()->getBaseCurrencyCode ();
|
91 |
+
|
92 |
+
// get cart quote by customer
|
93 |
+
$quote = Mage::getModel ( static::LOGIN_TOKEN )->setSaleQuoteByCustomer ( $customerId, $storeId, $currencyCode );
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Check this customer has valid token or not
|
97 |
+
*
|
98 |
+
* @var $isValidToken Mage_Login_Model_Token
|
99 |
+
*/
|
100 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $data [static::TOKEN] );
|
101 |
+
|
102 |
+
$response [static::VALID_TOKEN] = true;
|
103 |
+
$product = $this->_getProduct ( $productId, $storeId, 'id' );
|
104 |
+
if (is_null ( $product )) {
|
105 |
+
$error = 'Can not specify the product.';
|
106 |
+
} else if (! $isValidToken) {
|
107 |
+
$error = static::AUTH_FAIL;
|
108 |
+
$response [static::VALID_TOKEN] = false;
|
109 |
+
} else {
|
110 |
+
$error = $this->addToCart ( $product, $quote, $qty, $data );
|
111 |
+
}
|
112 |
+
|
113 |
+
if (is_string ( $error ) || $quote == 0) {
|
114 |
+
$message = ($quote) ? $error : 'Customer not found.';
|
115 |
+
$error_flag = false;
|
116 |
+
$success = 0;
|
117 |
+
} else {
|
118 |
+
$message = 'Product added to cart successfully.';
|
119 |
+
$quote->collectTotals ();
|
120 |
+
$quote->save ();
|
121 |
+
$error_flag = false;
|
122 |
+
$success = 1;
|
123 |
+
|
124 |
+
$response [static::ITEM_COUNT] = Mage::getModel ( static::LOGIN_TOKEN )->getCartCount ( $customerId, $storeId );
|
125 |
+
}
|
126 |
+
$response [static::SUCCESS] = $success;
|
127 |
+
$response [static::ERROR] = $error_flag;
|
128 |
+
$response [static::MESSAGE] = $message;
|
129 |
+
|
130 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
131 |
+
return;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Retrieve Cart products collection
|
136 |
+
*
|
137 |
+
* @param integer $customerId
|
138 |
+
* @return array json array
|
139 |
+
*/
|
140 |
+
protected function _retrieveCollection() {
|
141 |
+
$response = array ();
|
142 |
+
|
143 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
144 |
+
// get website id from request
|
145 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITEID );
|
146 |
+
if ($websiteId <= 0) {
|
147 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
148 |
+
}
|
149 |
+
|
150 |
+
// get store id
|
151 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
152 |
+
if ($storeId <= 0) {
|
153 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* Check this customer has valid token or not
|
157 |
+
*
|
158 |
+
* @var $isValidToken Mage_Login_Model_Token
|
159 |
+
*/
|
160 |
+
$response [static::VALID_TOKEN] = true;
|
161 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
162 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
163 |
+
if ($isValidToken) {
|
164 |
+
$prodctsList = Mage::getModel ( static::LOGIN_TOKEN )->getCartProducts ( array (
|
165 |
+
static::STOREID => $storeId,
|
166 |
+
static::CUSTOMER_ID => $customerId
|
167 |
+
) );
|
168 |
+
$result = $prodctsList ['result'];
|
169 |
+
$response [static::SUCCESS] = 1;
|
170 |
+
$response [static::ERROR] = false;
|
171 |
+
$response [static::MESSAGE] = $prodctsList [static::MESSAGE];
|
172 |
+
} else {
|
173 |
+
$result = array ();
|
174 |
+
$response [static::VALID_TOKEN] = false;
|
175 |
+
$response [static::ERROR] = true;
|
176 |
+
$response [static::SUCCESS] = 0;
|
177 |
+
$response [static::MESSAGE] = static::AUTH_FAIL;
|
178 |
+
}
|
179 |
+
$response [static::RESULT] = $result;
|
180 |
+
return $response;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Update Cart products Qty
|
185 |
+
*
|
186 |
+
* @param array $data
|
187 |
+
* @return array json array
|
188 |
+
*/
|
189 |
+
protected function _update(array $data) {
|
190 |
+
$response = array ();
|
191 |
+
|
192 |
+
// get quote id from request
|
193 |
+
$quoteId = ( int ) $data [static::QUOTE_ID];
|
194 |
+
// get product id from request
|
195 |
+
$productId = ( int ) $data [static::PRODUCT_ID];
|
196 |
+
// get qty from request
|
197 |
+
$qty = $data [static::QTY];
|
198 |
+
|
199 |
+
// get customer id from request
|
200 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
201 |
+
|
202 |
+
// Get website id
|
203 |
+
$websiteId = (isset ( $data [static::WEBSITEID] )) ? $data [static::WEBSITEID] : Mage::app ()->getWebsite ( 'base' )->getId ();
|
204 |
+
// get store id
|
205 |
+
$storeId = (isset ( $data [static::STOREID] )) ? $data [static::STOREID] : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
206 |
+
|
207 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
208 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
209 |
+
$productByItem = $this->_getProduct ( $productId, $storeId, 'id' );
|
210 |
+
$productItem = $this->updateToCart ( $productByItem, $quote, $qty, $data );
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Check this customer has valid token or not
|
214 |
+
*
|
215 |
+
* @var $isValidToken Mage_Login_Model_Token
|
216 |
+
*/
|
217 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $data [static::TOKEN] );
|
218 |
+
if ($isValidToken) {
|
219 |
+
try {
|
220 |
+
|
221 |
+
if (empty ( $productByItem )) {
|
222 |
+
$success = 0;
|
223 |
+
$message = 'Item is not available.';
|
224 |
+
} else {
|
225 |
+
$quoteItem = Mage::getModel ( static::LOGIN_TOKEN )->_getQuoteItemByProduct ( $quote, $productByItem, Mage::getModel ( static::LOGIN_TOKEN )->_getProductRequest ( $productItem ) );
|
226 |
+
|
227 |
+
$update = $this->cartUpdate ( $quoteItem, $quote, $qty );
|
228 |
+
$success = $update [static::SUCCESS];
|
229 |
+
$message = $update [static::MESSAGE];
|
230 |
+
}
|
231 |
+
} catch ( Mage_Core_Exception $e ) {
|
232 |
+
$success = 0;
|
233 |
+
$message = $e->getMessage ();
|
234 |
+
}
|
235 |
+
} else {
|
236 |
+
$success = 0;
|
237 |
+
$message = static::AUTH_FAIL;
|
238 |
+
}
|
239 |
+
|
240 |
+
$cartTotal = Mage::getModel ( static::LOGIN_TOKEN )->getCartTotal ( array (
|
241 |
+
static::STOREID => $storeId,
|
242 |
+
static::CUSTOMER_ID => $customerId
|
243 |
+
) );
|
244 |
+
$response [static::ITEM_COUNT] = $cartTotal [static::ITEM_COUNT];
|
245 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
246 |
+
$response [static::ERROR] = false;
|
247 |
+
$response [static::SUCCESS] = $success;
|
248 |
+
$response [static::MESSAGE] = $message;
|
249 |
+
$response [static::RESULT] = $cartTotal [static::RESULT];
|
250 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
251 |
+
return;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Delete product from cart
|
256 |
+
*
|
257 |
+
* @param integer $quoteId
|
258 |
+
* @param integer $productId
|
259 |
+
*
|
260 |
+
* @return array json array
|
261 |
+
*/
|
262 |
+
protected function _delete() {
|
263 |
+
|
264 |
+
// get quote id from request
|
265 |
+
$quoteId = ( int ) $this->getRequest ()->getParam ( static::QUOTE_ID );
|
266 |
+
// get product id from request
|
267 |
+
$productId = ( int ) $this->getRequest ()->getParam ( static::PRODUCT_ID );
|
268 |
+
|
269 |
+
// get customer id from request
|
270 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
271 |
+
// Get website id
|
272 |
+
$websiteId = $this->getRequest ()->getParam ( static::WEBSITEID );
|
273 |
+
// get store id
|
274 |
+
$storeId = $this->getRequest ()->getParam ( static::STOREID );
|
275 |
+
|
276 |
+
$websiteId = (isset ( $websiteId )) ? $websiteId : Mage::app ()->getWebsite ( 'base' )->getId ();
|
277 |
+
$storeId = (isset ( $storeId )) ? $storeId : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
278 |
+
|
279 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
280 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
281 |
+
|
282 |
+
// get custom options
|
283 |
+
$options = $this->getRequest ()->getParam ( static::CUSTOM_OPTION );
|
284 |
+
foreach ( (json_decode ( $options )) as $key => $option ) {
|
285 |
+
if (is_string ( $option )) {
|
286 |
+
$option = str_replace ( '$$$$', ' ', $option );
|
287 |
+
}
|
288 |
+
$custom_option [$key] = $option;
|
289 |
+
}
|
290 |
+
$custom_option = json_encode ( $custom_option );
|
291 |
+
// get configurable product attribute
|
292 |
+
$super_attribute = $this->getRequest ()->getParam ( static::SUPER_ATTR );
|
293 |
+
// get downloadble product links
|
294 |
+
$links = $this->getRequest ()->getParam ( static::LINKS );
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Check this customer has valid token or not
|
298 |
+
*
|
299 |
+
* @var $isValidToken Mage_Login_Model_Token
|
300 |
+
*/
|
301 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $this->getRequest ()->getParam ( static::TOKEN ) );
|
302 |
+
if ($isValidToken) {
|
303 |
+
|
304 |
+
$productByItem = $this->_getProduct ( $productId, $storeId, 'id' );
|
305 |
+
$productItem = $this->deleteFromCart ( $productByItem, $quote, $qty, $custom_option, $super_attribute, $links );
|
306 |
+
|
307 |
+
try {
|
308 |
+
|
309 |
+
if (empty ( $productByItem )) {
|
310 |
+
$success = 0;
|
311 |
+
$err_message = 'Item is not available.';
|
312 |
+
} else {
|
313 |
+
$quoteItem = Mage::getModel ( static::LOGIN_TOKEN )->_getQuoteItemByProduct ( $quote, $productByItem, Mage::getModel ( static::LOGIN_TOKEN )->_getProductRequest ( $productItem ) );
|
314 |
+
|
315 |
+
$delete = $this->cartDelete ( $quoteItem, $quote );
|
316 |
+
$success = $delete [static::SUCCESS];
|
317 |
+
$err_message = $delete [static::MESSAGE];
|
318 |
+
}
|
319 |
+
} catch ( Mage_Core_Exception $e ) {
|
320 |
+
$success = 0;
|
321 |
+
$err_message = $e->getMessage ();
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
$success = 0;
|
325 |
+
$err_message = static::AUTH_FAIL;
|
326 |
+
}
|
327 |
+
// get cart total
|
328 |
+
$cartTotal = Mage::getModel ( static::LOGIN_TOKEN )->getCartTotal ( array (
|
329 |
+
static::STOREID => $storeId,
|
330 |
+
static::CUSTOMER_ID => $customerId
|
331 |
+
) );
|
332 |
+
$response [static::ITEM_COUNT] = $cartTotal [static::ITEM_COUNT];
|
333 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
334 |
+
$response [static::ERROR] = false;
|
335 |
+
$response [static::SUCCESS] = $success;
|
336 |
+
$response [static::MESSAGE] = $err_message;
|
337 |
+
$response [static::RESULT] = $cartTotal [static::RESULT];
|
338 |
+
|
339 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
340 |
+
return;
|
341 |
+
}
|
342 |
+
|
343 |
+
/**
|
344 |
+
* Get cart dotal qty
|
345 |
+
*
|
346 |
+
* @param integer $customerId
|
347 |
+
* @return array json array
|
348 |
+
*/
|
349 |
+
protected function _retrieve() {
|
350 |
+
$response = array ();
|
351 |
+
// get customer id from request
|
352 |
+
$customerId = Mage::app ()->getRequest ()->getParam ( static::CUSTOMER_ID );
|
353 |
+
// get website id from request
|
354 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITEID );
|
355 |
+
if ($websiteId <= 0) {
|
356 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
357 |
+
}
|
358 |
+
// get store id from request
|
359 |
+
$storeId = ( int ) Mage::app ()->getRequest ()->getParam ( static::STOREID );
|
360 |
+
if ($storeId <= 0) {
|
361 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
362 |
+
}
|
363 |
+
/**
|
364 |
+
* Check this customer has valid token or not
|
365 |
+
*
|
366 |
+
* @var $isValidToken Mage_Login_Model_Token
|
367 |
+
*/
|
368 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
369 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
370 |
+
if ($isValidToken) {
|
371 |
+
$quoteData = $this->getQuoteIdBycustomer ( $customerId, $storeId );
|
372 |
+
|
373 |
+
$itemCount = '0';
|
374 |
+
if (isset ( $quoteData ) && ! empty ( $quoteData )) {
|
375 |
+
$itemCount = $quoteData [0] [static::ITEMS_COUNT];
|
376 |
+
$success = 1;
|
377 |
+
$message = 'Item is listed';
|
378 |
+
}
|
379 |
+
} else {
|
380 |
+
$itemCount = null;
|
381 |
+
$success = 0;
|
382 |
+
$message = static::AUTH_FAIL;
|
383 |
+
}
|
384 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
385 |
+
$response [static::ERROR] = false;
|
386 |
+
$response [static::ITEM_COUNT] = $itemCount;
|
387 |
+
$response [static::SUCCESS] = $success;
|
388 |
+
$response [static::MESSAGE] = $message;
|
389 |
+
return $response;
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* Get product details
|
394 |
+
*
|
395 |
+
* @param integer $productId
|
396 |
+
* @param string $store
|
397 |
+
* @param string $identifierType
|
398 |
+
* @return NULL array
|
399 |
+
*/
|
400 |
+
public function _getProduct($productId, $store = NULL, $identifierType = NULL) {
|
401 |
+
|
402 |
+
/**
|
403 |
+
*
|
404 |
+
* @var $product Mage_Catalog_Model_Product
|
405 |
+
*/
|
406 |
+
$product = Mage::helper ( 'catalog/product' )->getProduct ( $productId, $store, $identifierType );
|
407 |
+
if (! $product->getId ()) {
|
408 |
+
return NULL;
|
409 |
+
}
|
410 |
+
|
411 |
+
return $product;
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Get Quote data by customer
|
416 |
+
*
|
417 |
+
* @param int $customerId
|
418 |
+
* @param int $storeId
|
419 |
+
* @return array $quoteData
|
420 |
+
*/
|
421 |
+
public function getQuoteIdBycustomer($customerId, $storeId) {
|
422 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMER_ID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( 'is_active', '1' )->setOrder ( static::ENTITYID, 'desc' );
|
423 |
+
return $quote->getData ();
|
424 |
+
}
|
425 |
+
/**
|
426 |
+
*
|
427 |
+
* @param integer $quoteId
|
428 |
+
* @param integer $storeId
|
429 |
+
* @return mixed array $quote
|
430 |
+
*/
|
431 |
+
protected function _getQuote($quoteId, $storeId) {
|
432 |
+
/**
|
433 |
+
*
|
434 |
+
* @var $quote Mage_Sales_Model_Quote
|
435 |
+
*/
|
436 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
437 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
438 |
+
return $quote;
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
+
* Add product to cart
|
443 |
+
*
|
444 |
+
* @param object $product
|
445 |
+
* @param object $quote
|
446 |
+
* @param int $qty
|
447 |
+
* @return $result
|
448 |
+
*/
|
449 |
+
public function addToCart($product, $quote, $qty, $data) {
|
450 |
+
// get product type
|
451 |
+
$type = $product->getTypeId ();
|
452 |
+
switch ($type) {
|
453 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
454 |
+
$request = new Varien_Object ( array (
|
455 |
+
static::SUPER_GRP => $qty
|
456 |
+
) );
|
457 |
+
$result = $quote->addProduct ( $product, $request );
|
458 |
+
break;
|
459 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
460 |
+
$request = new Varien_Object ( array (
|
461 |
+
static::SUPER_ATTR => $data [static::SUPER_ATTR],
|
462 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
463 |
+
static::QTY => $qty
|
464 |
+
) );
|
465 |
+
$result = $quote->addProduct ( $product, $request );
|
466 |
+
break;
|
467 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
468 |
+
$request = new Varien_Object ( array (
|
469 |
+
static::LINKS => explode ( ',', $data [static::LINKS] ),
|
470 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
471 |
+
static::QTY => $qty
|
472 |
+
) );
|
473 |
+
$result = $quote->addProduct ( $product, $request );
|
474 |
+
break;
|
475 |
+
default :
|
476 |
+
if (isset ( $data [static::CUSTOM_OPTION] )) {
|
477 |
+
$qty = new Varien_Object ( array (
|
478 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
479 |
+
static::QTY => $qty
|
480 |
+
) );
|
481 |
+
}
|
482 |
+
$result = $quote->addProduct ( $product, $qty );
|
483 |
+
break;
|
484 |
+
}
|
485 |
+
return $result;
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Update product to cart
|
490 |
+
*
|
491 |
+
* @param object $productByItem
|
492 |
+
* @param object $quote
|
493 |
+
* @param int $qty
|
494 |
+
* @return $result
|
495 |
+
*/
|
496 |
+
public function updateToCart($productByItem, $quote, $qty, $data) {
|
497 |
+
$type = $productByItem->getTypeId ();
|
498 |
+
$productItem = '';
|
499 |
+
switch ($type) {
|
500 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
501 |
+
$productItem = new Varien_Object ( array (
|
502 |
+
static::SUPER_GRP => $qty
|
503 |
+
) );
|
504 |
+
$quote->addProduct ( $product, $request );
|
505 |
+
break;
|
506 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
507 |
+
if (isset ( $data [static::SUPER_ATTR] ) && $data [static::SUPER_ATTR] != '') {
|
508 |
+
$productItem = new Varien_Object ( array (
|
509 |
+
static::SUPER_ATTR => $data [static::SUPER_ATTR],
|
510 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
511 |
+
static::QTY => $qty
|
512 |
+
) );
|
513 |
+
}
|
514 |
+
break;
|
515 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
516 |
+
if (isset ( $data [static::LINKS] ) && $data [static::LINKS] != '') {
|
517 |
+
$productItem = new Varien_Object ( array (
|
518 |
+
static::LINKS => explode ( ',', $data [static::LINKS] ),
|
519 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
520 |
+
static::QTY => $qty
|
521 |
+
) );
|
522 |
+
}
|
523 |
+
break;
|
524 |
+
default :
|
525 |
+
if (isset ( $data [static::CUSTOM_OPTION] ) && $data [static::CUSTOM_OPTION] != '') {
|
526 |
+
$productItem = new Varien_Object ( array (
|
527 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
528 |
+
static::QTY => $qty
|
529 |
+
) );
|
530 |
+
} else {
|
531 |
+
$productItem = '';
|
532 |
+
}
|
533 |
+
break;
|
534 |
+
}
|
535 |
+
|
536 |
+
return $productItem;
|
537 |
+
}
|
538 |
+
|
539 |
+
/**
|
540 |
+
* Delete product from cart
|
541 |
+
*
|
542 |
+
* @param object $productByItem
|
543 |
+
* @param object $quote
|
544 |
+
* @param int $qty
|
545 |
+
* @param string $custom_option
|
546 |
+
* @param string $super_attribute
|
547 |
+
* @return $productItem
|
548 |
+
*/
|
549 |
+
public function deleteFromCart($productByItem, $quote, $qty, $custom_option, $super_attribute, $links) {
|
550 |
+
$type = $productByItem->getTypeId ();
|
551 |
+
$productItem = '';
|
552 |
+
switch ($type) {
|
553 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
554 |
+
$request = new Varien_Object ( array (
|
555 |
+
static::SUPER_GRP => $qty
|
556 |
+
) );
|
557 |
+
$quote->addProduct ( $product, $request );
|
558 |
+
break;
|
559 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
560 |
+
if (isset ( $super_attribute ) && $super_attribute != '') {
|
561 |
+
$productItem = new Varien_Object ( array (
|
562 |
+
static::SUPER_ATTR => json_decode ( $super_attribute, true ),
|
563 |
+
static::OPTIONS => json_decode ( $custom_option, true )
|
564 |
+
) );
|
565 |
+
}
|
566 |
+
break;
|
567 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
568 |
+
if (isset ( $links ) && $links != '') {
|
569 |
+
$productItem = new Varien_Object ( array (
|
570 |
+
static::LINKS => explode ( ',', $links ),
|
571 |
+
static::OPTIONS => json_decode ( $custom_option, true )
|
572 |
+
) );
|
573 |
+
}
|
574 |
+
break;
|
575 |
+
default :
|
576 |
+
if (isset ( $custom_option ) && $custom_option != '') {
|
577 |
+
$productItem = new Varien_Object ( array (
|
578 |
+
static::OPTIONS => json_decode ( $custom_option, true )
|
579 |
+
) );
|
580 |
+
} else {
|
581 |
+
$productItem = '';
|
582 |
+
}
|
583 |
+
break;
|
584 |
+
}
|
585 |
+
return $productItem;
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Delete product from cart
|
590 |
+
*
|
591 |
+
* @param object $quoteItem
|
592 |
+
* @param object $quote
|
593 |
+
* @return array $response
|
594 |
+
*/
|
595 |
+
public function cartDelete($quoteItem, $quote) {
|
596 |
+
$response = array ();
|
597 |
+
if ($quoteItem != NULL) {
|
598 |
+
if (is_null ( $quoteItem->getId () )) {
|
599 |
+
$response [static::SUCCESS] = 0;
|
600 |
+
$response [static::MESSAGE] = 'Item is not added in cart.';
|
601 |
+
}
|
602 |
+
// remove product from cart
|
603 |
+
$quote->removeItem ( $quoteItem->getId () );
|
604 |
+
// save quote address details
|
605 |
+
$quote->getBillingAddress ();
|
606 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( TRUE );
|
607 |
+
$quote->collectTotals ();
|
608 |
+
$quote->save ();
|
609 |
+
|
610 |
+
$response [static::SUCCESS] = 1;
|
611 |
+
$response [static::MESSAGE] = 'Product deleted from cart successfully.';
|
612 |
+
} else {
|
613 |
+
$response [static::SUCCESS] = 0;
|
614 |
+
$response [static::MESSAGE] = 'Item is not added in cart.';
|
615 |
+
}
|
616 |
+
|
617 |
+
return $response;
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Update product in cart
|
622 |
+
*
|
623 |
+
* @param object $quoteItem
|
624 |
+
* @param object $quote
|
625 |
+
* @return array $response
|
626 |
+
*/
|
627 |
+
public function cartUpdate($quoteItem, $quote, $qty) {
|
628 |
+
$response = array ();
|
629 |
+
|
630 |
+
if (empty ( $quoteItem )) {
|
631 |
+
$success = 0;
|
632 |
+
$message = 'Item is not added in cart';
|
633 |
+
} else {
|
634 |
+
if ($qty > 0) {
|
635 |
+
$quoteItem->setQty ( $qty );
|
636 |
+
} else {
|
637 |
+
$quote->removeItem ( $quoteItem->getId () );
|
638 |
+
}
|
639 |
+
|
640 |
+
$quote->getBillingAddress ();
|
641 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( TRUE );
|
642 |
+
$quote->collectTotals ();
|
643 |
+
$quote->save ();
|
644 |
+
|
645 |
+
$success = 1;
|
646 |
+
$message = 'Cart updated successfully.';
|
647 |
+
}
|
648 |
+
$response [static::SUCCESS] = $success;
|
649 |
+
$response [static::MESSAGE] = $message;
|
650 |
+
return $response;
|
651 |
+
}
|
652 |
+
}
|
app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Cartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest extends ContusRestapi_Cartapi_Model_Api2_Cartapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Cartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest_Admin_V1 extends ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Cartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest_Customer_V1 extends ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Cartapi/Model/Api2/Cartapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Cartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest_Guest_V1 extends ContusRestapi_Cartapi_Model_Api2_Cartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Cartapi/etc/api2.xml
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="Cartapi">
|
6 |
+
<title>Cartapi</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<cartapi translate="title" module="Cartapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>cartapi/api2_cartapi</model>
|
14 |
+
<title>Cart</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
<update>1</update>
|
22 |
+
</admin>
|
23 |
+
<customer>
|
24 |
+
<create>1</create>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
<delete>1</delete>
|
27 |
+
<update>1</update>
|
28 |
+
</customer>
|
29 |
+
<guest>
|
30 |
+
<create>1</create>
|
31 |
+
<retrieve>1</retrieve>
|
32 |
+
<delete>1</delete>
|
33 |
+
<update>1</update>
|
34 |
+
</guest>
|
35 |
+
</privileges>
|
36 |
+
<attributes module="api2">
|
37 |
+
<website_id>Website id</website_id>
|
38 |
+
<store_id>Store Id</store_id>
|
39 |
+
<customer_id>customer Id</customer_id>
|
40 |
+
<product_id>product Id</product_id>
|
41 |
+
<quote_id>quote Id</quote_id>
|
42 |
+
<qty>qty</qty>
|
43 |
+
<super_attribute>super_attribute</super_attribute>
|
44 |
+
<custom_option>Custom Option</custom_option>
|
45 |
+
<links>Links</links>
|
46 |
+
<currencyCode>Currency code</currencyCode>
|
47 |
+
<result>Result</result>
|
48 |
+
<success>success</success>
|
49 |
+
<message>message</message>
|
50 |
+
<token>Token</token>
|
51 |
+
<isValidToken>Is Valid Token</isValidToken>
|
52 |
+
<items>Item</items>
|
53 |
+
<item_count>Item Count</item_count>
|
54 |
+
<items_qty>Item Qty</items_qty>
|
55 |
+
<grand_total>Grand Total</grand_total>
|
56 |
+
<subtotal>SubTotal</subtotal>
|
57 |
+
<discount>Discount</discount>
|
58 |
+
<coupon_code>Coupon Code</coupon_code>
|
59 |
+
<shipping_amount>Shipping Amount</shipping_amount>
|
60 |
+
<address>Address</address>
|
61 |
+
<tax></tax>
|
62 |
+
</attributes>
|
63 |
+
<routes>
|
64 |
+
<route_collection>
|
65 |
+
<route>/cart/add</route>
|
66 |
+
<action_type>collection</action_type>
|
67 |
+
</route_collection>
|
68 |
+
<!-- Cart products collection -->
|
69 |
+
<cart_collection>
|
70 |
+
<route>/cart/productlist/</route>
|
71 |
+
<action_type>collection</action_type> <!-- This will call _retrieveCollection function -->
|
72 |
+
<!--<action_type>entity</action_type>--> <!-- This will call _retrieve function -->
|
73 |
+
</cart_collection>
|
74 |
+
|
75 |
+
<cart_delete>
|
76 |
+
<route>/cart/delete/links/:links/super_attribute/:super_attribute/custom_option/:custom_option/quote_id/:quote_id/product_id/:product_id/customer_id/:customer_id/store_id/:store_id/website_id/:website_id/token/:token</route> <!-- qid = quote_id, pid = product_id-->
|
77 |
+
<action_type>entity</action_type>
|
78 |
+
</cart_delete>
|
79 |
+
|
80 |
+
<cart_update>
|
81 |
+
<route>/cart/update/</route>
|
82 |
+
<action_type>entity</action_type>
|
83 |
+
</cart_update>
|
84 |
+
<item_count>
|
85 |
+
<route>/cart/item_count/</route>
|
86 |
+
<action_type>entity</action_type>
|
87 |
+
</item_count>
|
88 |
+
</routes>
|
89 |
+
<versions>1</versions>
|
90 |
+
</cartapi>
|
91 |
+
|
92 |
+
</resources>
|
93 |
+
</api2>
|
94 |
+
</config>
|
app/code/local/ContusRestapi/Cartapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Cartapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_Cartapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<cartapi>
|
11 |
+
<class>ContusRestapi_Cartapi_Model</class>
|
12 |
+
</cartapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/Filters/Model/Api2/Filters.php
ADDED
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_Filters
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_Filters_Model_Api2_Filters extends Mage_Api2_Model_Resource {
|
31 |
+
|
32 |
+
// define static variable
|
33 |
+
const PRICE = 'price';
|
34 |
+
const ATTR_CODE = 'attribute_code';
|
35 |
+
const ATTR_ID = 'attribute_id';
|
36 |
+
const VALUES = 'values';
|
37 |
+
const VALUE = 'value';
|
38 |
+
const LABEL = 'label';
|
39 |
+
const COUNT = 'count';
|
40 |
+
const CATALOG_PRODUCT = 'catalog/product';
|
41 |
+
const E_ATTR_SET_ID = 'e.attribute_set_id';
|
42 |
+
|
43 |
+
/**
|
44 |
+
* function that is called when post is done **
|
45 |
+
*
|
46 |
+
* Get product types for filter category products based on category id
|
47 |
+
*
|
48 |
+
* @param array $data
|
49 |
+
*
|
50 |
+
* @return array json array
|
51 |
+
*/
|
52 |
+
protected function _retrieveCollection() {
|
53 |
+
$response = array ();
|
54 |
+
$filters = array ();
|
55 |
+
// get customer id from request
|
56 |
+
$categoryId = ( int ) $this->getRequest ()->getParam ( 'category_id' );
|
57 |
+
|
58 |
+
// get website id from request
|
59 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( 'website_id' );
|
60 |
+
if ($websiteId <= 0) {
|
61 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
62 |
+
}
|
63 |
+
// get store id from request
|
64 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( 'store_id' );
|
65 |
+
if ($storeId <= 0) {
|
66 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
67 |
+
}
|
68 |
+
// load category model
|
69 |
+
$category = Mage::getModel ( 'catalog/category' )->load ( $categoryId );
|
70 |
+
|
71 |
+
// Get attribute set ids based on category
|
72 |
+
$setIds = $this->getAttributeSetIds ( $storeId, $category );
|
73 |
+
// get searchable attributes from attribute set id
|
74 |
+
$attribuets = $this->getSearchableAttr ( $setIds, $storeId );
|
75 |
+
|
76 |
+
foreach ( $attribuets as $attribute ) {
|
77 |
+
$result = array ();
|
78 |
+
// assigen attribute code
|
79 |
+
$result [static::ATTR_CODE] = $attribute [static::ATTR_CODE];
|
80 |
+
// assigen attribute label
|
81 |
+
$result ['attribute_label'] = $attribute ['store_label'];
|
82 |
+
// assigen attribute id
|
83 |
+
$result [static::ATTR_ID] = $attribute [static::ATTR_ID];
|
84 |
+
|
85 |
+
// get attribute values from CATEGORY model
|
86 |
+
$attrCollection = $this->getAttributeCollection ( $category, $attribute [static::ATTR_CODE] );
|
87 |
+
|
88 |
+
// remove duplicate attribute value from array
|
89 |
+
$attriArray = $this->remove_duplicateKeys ( $attribute [static::ATTR_CODE], $attrCollection );
|
90 |
+
|
91 |
+
// get product count in each attriubute
|
92 |
+
$productCount = $this->getProductCount ( $attribute [static::ATTR_CODE], $attribute [static::ATTR_ID], $storeId, $category );
|
93 |
+
// get attribute value array
|
94 |
+
$result [static::VALUES] = $this->setAttr ( $attriArray, $attribute [static::ATTR_CODE], $attribute [static::ATTR_ID], $productCount );
|
95 |
+
// form array
|
96 |
+
$filters [] = $result;
|
97 |
+
}
|
98 |
+
// form array for sock availability
|
99 |
+
$availability [static::ATTR_CODE] = 'availability';
|
100 |
+
$availability ['attribute_label'] = 'Availability';
|
101 |
+
$values [static::VALUE] = 1;
|
102 |
+
$values [static::LABEL] = 'Availability';
|
103 |
+
$values [static::COUNT] = '';
|
104 |
+
$availability [static::VALUES] [] = $values;
|
105 |
+
$filters [] = $availability;
|
106 |
+
|
107 |
+
$response ['error'] = false;
|
108 |
+
$response ['success'] = 1;
|
109 |
+
$response ['message'] = '';
|
110 |
+
$response ['result'] = $filters;
|
111 |
+
return json_encode ( $response );
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Get attribute set ids
|
116 |
+
*
|
117 |
+
* @param int $storeId
|
118 |
+
* @param int $categoryId
|
119 |
+
*/
|
120 |
+
public function getAttributeSetIds($storeId, $category) {
|
121 |
+
$select = Mage::getResourceModel ( 'catalog/product_collection' )->setStoreId ( $storeId )->addCategoryFilter ( $category );
|
122 |
+
$select->getSelect ()->distinct ( static::E_ATTR_SET_ID );
|
123 |
+
|
124 |
+
$select->getSelect ()->reset ( Zend_Db_Select::COLUMNS )->columns ( static::E_ATTR_SET_ID );
|
125 |
+
|
126 |
+
return $select->getData ();
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Get searchable attributes from attribute set id
|
131 |
+
*
|
132 |
+
* @param array $setIds
|
133 |
+
* @param int $storeId
|
134 |
+
*/
|
135 |
+
public function getSearchableAttr($setIds, $storeId) {
|
136 |
+
$collection = Mage::getResourceModel ( 'catalog/product_attribute_collection' );
|
137 |
+
$collection->setItemObjectClass ( 'catalog/resource_eav_attribute' )->setAttributeSetFilter ( array (
|
138 |
+
$setIds
|
139 |
+
) )->addStoreLabel ( $storeId )->setOrder ( 'position', 'ASC' );
|
140 |
+
$collection = $collection->addIsFilterableFilter ();
|
141 |
+
|
142 |
+
return $collection->load ()->getData ();
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Get attribute collection from category products
|
147 |
+
*
|
148 |
+
* @param object $category
|
149 |
+
* @param string $attributeCode
|
150 |
+
* @return array $attrCollection
|
151 |
+
*/
|
152 |
+
public function getAttributeCollection($category, $attributeCode) {
|
153 |
+
$config = false;
|
154 |
+
$productAttr = array ();
|
155 |
+
// dtabase read
|
156 |
+
$connection = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
157 |
+
|
158 |
+
// get these type of products only
|
159 |
+
$productType = array (
|
160 |
+
"simple",
|
161 |
+
"configurable"
|
162 |
+
);
|
163 |
+
// get attribute values from CATEGORY model
|
164 |
+
$productAttr = Mage::getModel ( static::CATALOG_PRODUCT )->getCollection ()->addCategoryFilter ( $category )->addAttributeToFilter ( 'type_id', array (
|
165 |
+
'in' => $productType
|
166 |
+
) );
|
167 |
+
|
168 |
+
// get attribute value from associaded products
|
169 |
+
$childproduct = Mage::getModel ( static::CATALOG_PRODUCT )->getCollection ();
|
170 |
+
foreach ( $productAttr as $_product ) {
|
171 |
+
if ($_product ['type_id'] == 'configurable') {
|
172 |
+
|
173 |
+
// get the children ids through a simple query
|
174 |
+
$ids = '';
|
175 |
+
$ids = Mage::getModel ( 'catalog/product_type_configurable' )->getChildrenIds ( $_product ['entity_id'] );
|
176 |
+
// get associated products count
|
177 |
+
$counted = count ( $ids [0] );
|
178 |
+
if ($counted > 0) {
|
179 |
+
$config = true;
|
180 |
+
$filter_attr ['attribute'] = 'entity_id';
|
181 |
+
$filter_attr ['in'] = array (
|
182 |
+
$ids
|
183 |
+
);
|
184 |
+
$data [] = $filter_attr;
|
185 |
+
}
|
186 |
+
} else {
|
187 |
+
$productAttr->addAttributeToSelect ( $attributeCode, 'asc' );
|
188 |
+
$productAttr->getSelect ()->reset ( Zend_Db_Select::COLUMNS )->columns ( 'e.entity_id' )->columns ( static::E_ATTR_SET_ID )->columns ( 'e.type_id' )->columns ( 'e.sku' )->columns ( 'at_' . $attributeCode . '.value as ' . $attributeCode );
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
if ($config) {
|
193 |
+
$childproduct->addAttributeToFilter ( $data, '', 'left' )->addAttributeToSelect ( $attributeCode, 'asc' );
|
194 |
+
$childproduct->getSelect ()->reset ( Zend_Db_Select::COLUMNS )->columns ( 'e.entity_id' )->columns ( 'e.attribute_set_id' )->columns ( 'e.type_id' )->columns ( 'e.sku' )->columns ( 'at_' . $attributeCode . '.value as ' . $attributeCode );
|
195 |
+
$childproduct->getSelect ()->group ( $attributeCode );
|
196 |
+
// union queries in product and associated product
|
197 |
+
$main_select = $connection->select ()->union ( array (
|
198 |
+
$childproduct->getSelectSql ( true ),
|
199 |
+
$productAttr->getSelectSql ( true )
|
200 |
+
), Zend_Db_Select::SQL_UNION )->group ( $attributeCode );
|
201 |
+
|
202 |
+
$attrCollection = $connection->fetchAll ( $main_select );
|
203 |
+
} else {
|
204 |
+
$productAttr->getSelect ()->group ( $attributeCode );
|
205 |
+
$attrCollection = $productAttr->getConnection ()->fetchAll ( $productAttr->getSelect () );
|
206 |
+
}
|
207 |
+
|
208 |
+
return $attrCollection;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Retrieve array with products counts per attribute option
|
213 |
+
*
|
214 |
+
* @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
|
215 |
+
* @return array
|
216 |
+
*/
|
217 |
+
public function getProductCount($attributeCode, $attributeId, $storeId, $category) {
|
218 |
+
// get the table preix value
|
219 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
220 |
+
// dtabase read
|
221 |
+
$connection = Mage::getSingleton ( 'core/resource' )->getConnection ( 'core_read' );
|
222 |
+
|
223 |
+
$select = Mage::getResourceModel ( 'catalog/product_collection' )->setStoreId ( $storeId )->addCategoryFilter ( $category );
|
224 |
+
Mage::getSingleton ( 'catalog/product_visibility' )->addVisibleInCatalogFilterToCollection ( $select );
|
225 |
+
$query_count = $select->getSelect ()->reset ( Zend_Db_Select::COLUMNS )->reset ( Zend_Db_Select::ORDER )->reset ( Zend_Db_Select::LIMIT_COUNT )->reset ( Zend_Db_Select::LIMIT_OFFSET )->join ( array (
|
226 |
+
$attributeCode . '_idx' => $prefix . 'catalog_product_index_eav'
|
227 |
+
), $attributeCode . '_idx.entity_id = e.entity_id AND ' . $attributeCode . '_idx.attribute_id = ' . $attributeId . ' AND ' . $attributeCode . '_idx.store_id = ' . $storeId, array (
|
228 |
+
$attributeCode . '_idx.value, COUNT(' . $attributeCode . '_idx.entity_id) AS count'
|
229 |
+
) )->group ( $attributeCode . '_idx.value' );
|
230 |
+
return $connection->fetchPairs ( $query_count );
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Set attibute values as array with product count
|
235 |
+
*
|
236 |
+
* @param array $productAttr
|
237 |
+
* @param string $attributeCode
|
238 |
+
* @param int $productCount
|
239 |
+
* @return array $result
|
240 |
+
*/
|
241 |
+
public function setAttr($productAttr, $attributeCode, $attributeId, $productCount) {
|
242 |
+
$result = array ();
|
243 |
+
$price = array ();
|
244 |
+
foreach ( $productAttr as $attr ) {
|
245 |
+
if ($attr [$attributeCode] != '') {
|
246 |
+
$values = array ();
|
247 |
+
// is attribute id is not price ste fale
|
248 |
+
$price_flag = false;
|
249 |
+
// check attribute id price
|
250 |
+
if ($attributeCode == static::PRICE) {
|
251 |
+
array_push ( $price, $attr [$attributeCode] );
|
252 |
+
$price_flag = true;
|
253 |
+
} else {
|
254 |
+
// get attribute value id
|
255 |
+
$values [static::VALUE] = $attr [$attributeCode];
|
256 |
+
// get attribute value label
|
257 |
+
$productModel = Mage::getModel ( static::CATALOG_PRODUCT )->getResource ()->getAttribute ( $attributeId );
|
258 |
+
$values [static::LABEL] = $productModel->getSource ()->getOptionText ( $attr [$attributeCode] );
|
259 |
+
// get product count
|
260 |
+
$values [static::COUNT] = isset ( $productCount [$attr [$attributeCode]] ) ? $productCount [$attr [$attributeCode]] : 0;
|
261 |
+
$result [] = $values;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
// get minmum and maximum price from price attribute
|
267 |
+
if ($price_flag) {
|
268 |
+
// sort price array
|
269 |
+
sort ( $price );
|
270 |
+
// get minimum price
|
271 |
+
$result [0] [static::VALUE] = number_format ( $price [0], 2, '.', '' );
|
272 |
+
$result [0] [static::LABEL] = 'min_price';
|
273 |
+
$result [0] [static::COUNT] = '';
|
274 |
+
// get maximum price
|
275 |
+
$result [1] [static::VALUE] = number_format ( end ( $price ), 2, '.', '' );
|
276 |
+
$result [1] [static::LABEL] = 'max_price';
|
277 |
+
$result [1] [static::COUNT] = '';
|
278 |
+
}
|
279 |
+
|
280 |
+
return $result;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
*
|
285 |
+
* @param string $key
|
286 |
+
* @param array $data
|
287 |
+
* @return array $data
|
288 |
+
*/
|
289 |
+
public function remove_duplicateKeys($key, $data) {
|
290 |
+
$_data = array ();
|
291 |
+
|
292 |
+
foreach ( $data as $v ) {
|
293 |
+
if (isset ( $_data [$v [$key]] )) {
|
294 |
+
// found duplicate
|
295 |
+
continue;
|
296 |
+
}
|
297 |
+
// remember unique item
|
298 |
+
$_data [$v [$key]] = $v;
|
299 |
+
}
|
300 |
+
// if you need a zero-based array, otheriwse work with $_data
|
301 |
+
return array_values ( $_data );
|
302 |
+
}
|
303 |
+
}
|
app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Filters
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Filters_Model_Api2_Filters_Rest extends ContusRestapi_Filters_Model_Api2_Filters {
|
30 |
+
}
|
app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Filters
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Filters_Model_Api2_Filters_Rest_Admin_V1 extends ContusRestapi_Filters_Model_Api2_Filters_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Filters
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Filters_Model_Api2_Filters_Rest_Customer_V1 extends ContusRestapi_Filters_Model_Api2_Filters_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Filters/Model/Api2/Filters/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Filters
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Filters_Model_Api2_Filters_Rest_Guest_V1 extends ContusRestapi_Filters_Model_Api2_Filters_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Filters/etc/api2.xml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="Filters">
|
6 |
+
<title>Filters List</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<filters translate="title" module="Filters">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>filters/api2_filters</model>
|
14 |
+
<title>Filter Types</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
<delete>1</delete>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<create>1</create>
|
29 |
+
<retrieve>1</retrieve>
|
30 |
+
<delete>1</delete>
|
31 |
+
</guest>
|
32 |
+
</privileges>
|
33 |
+
<attributes module="api2">
|
34 |
+
<website_id>websiteid</website_id>
|
35 |
+
<store_id>Associate to Store</store_id>
|
36 |
+
<category_id>Category Id</category_id>
|
37 |
+
<result>Product Types</result>
|
38 |
+
</attributes>
|
39 |
+
<routes>
|
40 |
+
<route_collection>
|
41 |
+
<route>/category/filters/</route>
|
42 |
+
<action_type>collection</action_type>
|
43 |
+
</route_collection>
|
44 |
+
</routes>
|
45 |
+
<versions>1</versions>
|
46 |
+
</filters>
|
47 |
+
|
48 |
+
</resources>
|
49 |
+
</api2>
|
50 |
+
</config>
|
app/code/local/ContusRestapi/Filters/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Filters>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_Filters>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<filters>
|
11 |
+
<class>ContusRestapi_Filters_Model</class>
|
12 |
+
</filters>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi.php
ADDED
@@ -0,0 +1,619 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_HomePageapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_HomePageapi_Model_Api2_HomePageapi extends Mage_Api2_Model_Resource {
|
30 |
+
|
31 |
+
// Declaring the string literals variable
|
32 |
+
const ENTITYID = 'entity_id';
|
33 |
+
const NAME = 'name';
|
34 |
+
const IMGURL = 'image_url';
|
35 |
+
const REGULARPRICE = 'regular_price_with_tax';
|
36 |
+
const FINALPRICE = 'final_price_with_tax';
|
37 |
+
const PRODUCTTYPE = 'product_type';
|
38 |
+
const PROCOLLECTION = 'collection';
|
39 |
+
const VISIBILITY = 'visibility';
|
40 |
+
const STATUS = 'status';
|
41 |
+
const CATIMG = 'catalog/image';
|
42 |
+
const SMALLIMG = 'small_image';
|
43 |
+
const TYPE_ID = 'type_id';
|
44 |
+
const OFFER = 'offer';
|
45 |
+
const SETTINGS = 'settings';
|
46 |
+
const BANNER_TYPE = 'banner_type';
|
47 |
+
const LOGIN_TOKEN = 'login/token';
|
48 |
+
const WEBSITE_ID = 'website_id';
|
49 |
+
const STORE_ID = 'store_id';
|
50 |
+
const DETAIL = 'detail';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* function that is called when post is done **
|
54 |
+
* Home page details
|
55 |
+
*
|
56 |
+
* @param array $data
|
57 |
+
*
|
58 |
+
* @return array json array
|
59 |
+
*/
|
60 |
+
protected function _retrieveCollection() {
|
61 |
+
$response = array ();
|
62 |
+
// set page size as 1
|
63 |
+
$page = 1;
|
64 |
+
|
65 |
+
// get website id from request
|
66 |
+
$websiteId = ( int ) Mage::app ()->getRequest ()->getParam ( static::WEBSITE_ID );
|
67 |
+
if ($websiteId <= 0) {
|
68 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
69 |
+
}
|
70 |
+
// get store id from request
|
71 |
+
$storeId = ( int ) Mage::app ()->getRequest ()->getParam ( static::STORE_ID );
|
72 |
+
if ($storeId <= 0) {
|
73 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
74 |
+
}
|
75 |
+
|
76 |
+
// get image size for resize
|
77 |
+
$imageSize = ( int ) Mage::app ()->getRequest ()->getParam ( 'image_size' );
|
78 |
+
|
79 |
+
// get today date
|
80 |
+
$todayDate = Mage::app ()->getLocale ()->date ()->toString ( Varien_Date::DATETIME_INTERNAL_FORMAT );
|
81 |
+
// get these type of products only
|
82 |
+
$productType = array (
|
83 |
+
"simple",
|
84 |
+
"configurable"
|
85 |
+
);
|
86 |
+
|
87 |
+
// Get Categories
|
88 |
+
// get root category for store base
|
89 |
+
$rootCatId = Mage::app ()->getStore ( $storeId )->getRootCategoryId ();
|
90 |
+
$response [static::SETTINGS] ['root_category_id'] = $rootCatId;
|
91 |
+
$response ['categories'] = $this->getCategoryList ( $storeId, $rootCatId );
|
92 |
+
|
93 |
+
// Get new arrival products
|
94 |
+
$limit = 10;
|
95 |
+
$newProdCollection = array ();
|
96 |
+
$newProdCollection = $this->getNewArrivalProducts ( $storeId, $page, $limit, $todayDate, $productType, $imageSize );
|
97 |
+
$response [static::PROCOLLECTION] = $newProdCollection;
|
98 |
+
$collection_type = 'New Arrivals';
|
99 |
+
// get new product count
|
100 |
+
$newProCount = count ( $newProdCollection );
|
101 |
+
|
102 |
+
// Get best selling products
|
103 |
+
if ($newProCount < 3) {
|
104 |
+
$bestSelling = $this->getbestSellingProducts ( $storeId, $page, $limit, $imageSize );
|
105 |
+
$response [static::PROCOLLECTION] = $bestSelling;
|
106 |
+
$collection_type = 'Best Seller';
|
107 |
+
}
|
108 |
+
// get best selling products count
|
109 |
+
$bestProCount = count ( $bestSelling );
|
110 |
+
|
111 |
+
// Get all product collection
|
112 |
+
if ($newProCount < 3 && $bestProCount < 3) {
|
113 |
+
$allProduct = $this->getallProducts ( $storeId, $page, $limit, $productType, $imageSize );
|
114 |
+
$response [static::PROCOLLECTION] = $allProduct;
|
115 |
+
$collection_type = 'All Products';
|
116 |
+
}
|
117 |
+
$response [static::SETTINGS] [static::PRODUCTTYPE] = $collection_type;
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Home page banner
|
121 |
+
* Get enabled home page product from configuration
|
122 |
+
*/
|
123 |
+
$offersCollection = array ();
|
124 |
+
$bannerProducts = array ();
|
125 |
+
$response [static::OFFER] = array ();
|
126 |
+
$homeBanner = Mage::getStoreConfig ( 'contus/configuration_home/home_banner', $storeId );
|
127 |
+
$BannerCount = Mage::getStoreConfig ( 'contus/configuration_home/banner_count', $storeId );
|
128 |
+
|
129 |
+
if ($homeBanner == 'offers') {
|
130 |
+
$offersCollection = $this->getOffers ( $BannerCount );
|
131 |
+
$response [static::SETTINGS] [static::BANNER_TYPE] = 'list';
|
132 |
+
$response [static::OFFER] = $offersCollection;
|
133 |
+
} else if ($homeBanner == 'bestsellers') {
|
134 |
+
$response [static::SETTINGS] [static::BANNER_TYPE] = static::DETAIL;
|
135 |
+
$response [static::OFFER] = $this->getbestSellingProducts ( $storeId, $page, $BannerCount, $imageSize );
|
136 |
+
} else if ($homeBanner == 'newarrivals') {
|
137 |
+
$response [static::SETTINGS] [static::BANNER_TYPE] = static::DETAIL;
|
138 |
+
$response [static::OFFER] = array_slice ( $newProdCollection, 0, $BannerCount );
|
139 |
+
} else {
|
140 |
+
$bannerProducts = array_slice ( $response [static::PROCOLLECTION], 0, $BannerCount );
|
141 |
+
$response [static::OFFER] = $bannerProducts;
|
142 |
+
$response [static::SETTINGS] [static::BANNER_TYPE] = static::DETAIL;
|
143 |
+
}
|
144 |
+
|
145 |
+
// Get Available stores based on website id
|
146 |
+
$response ['available_stores'] = $this->getAvailableStores ( $websiteId );
|
147 |
+
$response ['error'] = false;
|
148 |
+
$response ['success'] = 1;
|
149 |
+
return json_encode ( $response );
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Get Special offerd Products
|
154 |
+
*
|
155 |
+
* @param int $page
|
156 |
+
* @param int $storeId
|
157 |
+
* @param int $limit
|
158 |
+
*
|
159 |
+
* @param date $todayDate
|
160 |
+
* @return array $offerProducts
|
161 |
+
*/
|
162 |
+
public function getOfferedProducts($storeId, $page, $limit, $todayDate, $productType, $imageSize) {
|
163 |
+
$_productCollection = Mage::getResourceModel ( 'catalog/product_collection' );
|
164 |
+
$_productCollection->setStoreId ( $storeId );
|
165 |
+
|
166 |
+
$_productCollection->addAttributeToFilter ( 'special_from_date', array (
|
167 |
+
'date' => true,
|
168 |
+
'to' => $todayDate
|
169 |
+
) )->addAttributeToFilter ( static::TYPE_ID, array (
|
170 |
+
'in' => $productType
|
171 |
+
) )->
|
172 |
+
|
173 |
+
addAttributeToFilter ( 'special_to_date', array (
|
174 |
+
'or' => array (
|
175 |
+
|
176 |
+
0 => array (
|
177 |
+
'date' => true,
|
178 |
+
'from' => $todayDate
|
179 |
+
),
|
180 |
+
|
181 |
+
1 => array (
|
182 |
+
'is' => new Zend_Db_Expr ( 'null' )
|
183 |
+
)
|
184 |
+
)
|
185 |
+
), 'left' )->
|
186 |
+
|
187 |
+
addAttributeToSort ( 'special_price', 'asc' );
|
188 |
+
$_productCollection->addAttributeToFilter ( static::VISIBILITY, array (
|
189 |
+
'neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
190 |
+
) )->addAttributeToFilter ( static::STATUS, array (
|
191 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
192 |
+
) );
|
193 |
+
$_productCollection->addAttributeToFilter ( 'special_price', array (
|
194 |
+
'neq' => '0'
|
195 |
+
) );
|
196 |
+
$_productCollection->setPage ( $page, $limit );
|
197 |
+
|
198 |
+
$offerProducts = array ();
|
199 |
+
$i = 0;
|
200 |
+
|
201 |
+
foreach ( $_productCollection as $item ) {
|
202 |
+
$item->setStoreId ( $storeId )->load ( $item->getId () );
|
203 |
+
// get product id
|
204 |
+
$offerProducts [$i] [static::ENTITYID] = $item->getId ();
|
205 |
+
// get type id
|
206 |
+
$offerProducts [$i] [static::TYPE_ID] = $item->getTypeId ();
|
207 |
+
// get product name
|
208 |
+
$offerProducts [$i] [static::NAME] = $item->getName ();
|
209 |
+
// get product small image
|
210 |
+
if ($imageSize <= 0) {
|
211 |
+
$offerProducts [$i] [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $item, static::SMALLIMG );
|
212 |
+
} else {
|
213 |
+
$offerProducts [$i] [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $item, static::SMALLIMG )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
214 |
+
}
|
215 |
+
// get the product final price
|
216 |
+
$offerProducts [$i] [static::REGULARPRICE] = number_format ( $item->getPrice (), 2, '.', '' );
|
217 |
+
$offerProducts [$i] [static::FINALPRICE] = number_format ( $item->getFinalPrice (), 2, '.', '' );
|
218 |
+
$i ++;
|
219 |
+
}
|
220 |
+
|
221 |
+
return $offerProducts;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get new arrival products
|
226 |
+
* Based on news_from_date attribute
|
227 |
+
*
|
228 |
+
* @param int $storeId
|
229 |
+
* @param int $page
|
230 |
+
* @param $limit 10
|
231 |
+
* @param date $todayDate
|
232 |
+
* @return array $newProducts
|
233 |
+
*/
|
234 |
+
public function getNewArrivalProducts($storeId, $page, $limit, $todayDate, $productType, $imageSize) {
|
235 |
+
$collection = Mage::getResourceModel ( 'catalog/product_collection' );
|
236 |
+
$collection->setStoreId ( $storeId );
|
237 |
+
|
238 |
+
$collection->addAttributeToFilter ( static::TYPE_ID, array (
|
239 |
+
'in' => $productType
|
240 |
+
) )->addAttributeToFilter ( 'news_from_date', array (
|
241 |
+
'date' => true,
|
242 |
+
'to' => $todayDate
|
243 |
+
) )->addAttributeToFilter ( 'news_to_date', array (
|
244 |
+
'or' => array (
|
245 |
+
|
246 |
+
0 => array (
|
247 |
+
'date' => true,
|
248 |
+
'from' => $todayDate
|
249 |
+
),
|
250 |
+
|
251 |
+
1 => array (
|
252 |
+
'is' => new Zend_Db_Expr ( 'null' )
|
253 |
+
)
|
254 |
+
)
|
255 |
+
), 'left' )->
|
256 |
+
|
257 |
+
addAttributeToSort ( 'news_from_date', 'desc' );
|
258 |
+
$collection->addAttributeToFilter ( static::VISIBILITY, array (
|
259 |
+
'neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
260 |
+
) )->addAttributeToFilter ( static::STATUS, array (
|
261 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
262 |
+
) );
|
263 |
+
$collection->setPage ( $page, $limit );
|
264 |
+
|
265 |
+
return $this->getProductDetail ( $collection, $storeId, $imageSize );
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Get best selling products
|
270 |
+
*
|
271 |
+
* @param int $storeId
|
272 |
+
* @param int $page
|
273 |
+
* @param $limit 10
|
274 |
+
* @return array $bestProducts
|
275 |
+
*/
|
276 |
+
public function getbestSellingProducts($storeId, $page, $limit, $imageSize) {
|
277 |
+
$visibility = array (
|
278 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
279 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
|
280 |
+
);
|
281 |
+
|
282 |
+
$productType [0] = 'simple';
|
283 |
+
$productType [1] = 'virtual';
|
284 |
+
$productType [2] = 'downloadable';
|
285 |
+
|
286 |
+
$_productCollection = Mage::getResourceModel ( 'reports/product_collection' )->addAttributeToSelect ( '*' )->addOrderedQty ()->addAttributeToFilter ( static::VISIBILITY, $visibility )->addAttributeToFilter ( static::STATUS, array (
|
287 |
+
'eq' => '1'
|
288 |
+
) )->addAttributeToFilter ( static::TYPE_ID, array (
|
289 |
+
'in' => $productType
|
290 |
+
) )->setPage ( $page, $limit )->setOrder ( 'ordered_qty', 'desc' );
|
291 |
+
|
292 |
+
return $this->getProductDetail ( $_productCollection, $storeId, $imageSize );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Get Most viewed products
|
297 |
+
*
|
298 |
+
* @param int $storeId
|
299 |
+
* @param int $page
|
300 |
+
* @param $limit 10
|
301 |
+
* @return array $mostViewProducts
|
302 |
+
*/
|
303 |
+
public function geMostViewProducts($storeId, $page, $limit, $productType, $imageSize) {
|
304 |
+
$visibility = array (
|
305 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
306 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
|
307 |
+
);
|
308 |
+
$_productCollection = Mage::getResourceModel ( 'reports/product_collection' )->addAttributeToSelect ( '*' )->setStoreId ( $storeId )->addStoreFilter ( $storeId )->addAttributeToFilter ( static::VISIBILITY, $visibility )->addAttributeToFilter ( static::STATUS, array (
|
309 |
+
'eq' => '1'
|
310 |
+
) )->addAttributeToFilter ( static::TYPE_ID, array (
|
311 |
+
'in' => $productType
|
312 |
+
) )->addViewsCount ()->setPage ( $page, $limit );
|
313 |
+
|
314 |
+
return $this->getProductDetail ( $_productCollection, $storeId, $imageSize );
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Get all products collection
|
319 |
+
*
|
320 |
+
* @param int $storeId
|
321 |
+
* @param int $page
|
322 |
+
* @param $limit 10
|
323 |
+
* @return array $productColl
|
324 |
+
*/
|
325 |
+
public function getallProducts($storeId, $page, $limit, $productType, $imageSize) {
|
326 |
+
$visibility = array (
|
327 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
328 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
|
329 |
+
);
|
330 |
+
$collection = Mage::getModel ( 'catalog/product' )->getCollection ()->addAttributeToSelect ( array (
|
331 |
+
'*'
|
332 |
+
) )->addAttributeToFilter ( static::STATUS, array (
|
333 |
+
'eq' => '1'
|
334 |
+
) )->addAttributeToFilter ( static::TYPE_ID, array (
|
335 |
+
'in' => $productType
|
336 |
+
) )->addAttributeToFilter ( static::VISIBILITY, $visibility )->setStoreId ( $storeId )->addStoreFilter ( $storeId )->setPage ( $page, $limit )->addAttributeToSort ( 'created_at', 'desc' );
|
337 |
+
|
338 |
+
return $this->getProductDetail ( $collection, $storeId, $imageSize );
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Get Product details
|
343 |
+
*
|
344 |
+
* @param array $collection
|
345 |
+
* @param int $storeId
|
346 |
+
* @param int $imageSize
|
347 |
+
* @return $Products
|
348 |
+
*/
|
349 |
+
public function getProductDetail($collection, $storeId, $imageSize) {
|
350 |
+
$Products = array ();
|
351 |
+
$j = 0;
|
352 |
+
foreach ( $collection as $product ) {
|
353 |
+
$product->setStoreId ( $storeId )->load ( $product->getId () );
|
354 |
+
// get product id
|
355 |
+
$Products [$j] [static::ENTITYID] = $product->getId ();
|
356 |
+
// get type id
|
357 |
+
$Products [$j] [static::TYPE_ID] = $product->getTypeId ();
|
358 |
+
// get product name
|
359 |
+
$Products [$j] [static::NAME] = $product->getName ();
|
360 |
+
// get product small image
|
361 |
+
if ($imageSize <= 0) {
|
362 |
+
$Products [$j] [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, static::SMALLIMG );
|
363 |
+
} else {
|
364 |
+
$Products [$j] [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, static::SMALLIMG )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
365 |
+
}
|
366 |
+
// get the product final price
|
367 |
+
$Products [$j] [static::REGULARPRICE] = number_format ( $product->getPrice (), 2, '.', '' );
|
368 |
+
$Products [$j] [static::FINALPRICE] = number_format ( $product->getFinalPrice (), 2, '.', '' );
|
369 |
+
$j ++;
|
370 |
+
}
|
371 |
+
return $Products;
|
372 |
+
}
|
373 |
+
/**
|
374 |
+
* Get Categories
|
375 |
+
*
|
376 |
+
* @param int $storeId
|
377 |
+
* @param int $rootCatId
|
378 |
+
*
|
379 |
+
* @return array $curcategory
|
380 |
+
*/
|
381 |
+
public function getCategoryList($storeId, $rootCatId) {
|
382 |
+
// declare empty array
|
383 |
+
$curcategory = array ();
|
384 |
+
|
385 |
+
/**
|
386 |
+
*
|
387 |
+
* @var $categories Mage_Catalog_Model_Category
|
388 |
+
*/
|
389 |
+
$categories = Mage::getModel ( 'catalog/category' )->getCollection ()->setStoreId ( $storeId )->addFieldToFilter ( 'is_active', 1 )->addAttributeToFilter ( 'path', array (
|
390 |
+
'like' => "1/{$rootCatId}/%"
|
391 |
+
) )->addAttributeToSelect ( '*' );
|
392 |
+
$k = 0;
|
393 |
+
foreach ( $categories as $category ) {
|
394 |
+
// get category id
|
395 |
+
$curcategory [$k] ['category_id'] = $category->getId ();
|
396 |
+
// get Category name
|
397 |
+
$curcategory [$k] [static::NAME] = $category->getName ();
|
398 |
+
|
399 |
+
// get image url
|
400 |
+
if ($category->getImageUrl () != '') {
|
401 |
+
$curcategory [$k] [static::IMGURL] = $category->getImageUrl ();
|
402 |
+
} else {
|
403 |
+
$curcategory [$k] [static::IMGURL] = '';
|
404 |
+
}
|
405 |
+
// get category position for sorting
|
406 |
+
$curcategory [$k] ['position'] = $category->getPosition ();
|
407 |
+
// get parent category of current category
|
408 |
+
$curcategory [$k] ['parent_id'] = $category->getParent_id ();
|
409 |
+
|
410 |
+
// check category has sub category or not
|
411 |
+
$subCategory = $category->getChildren ();
|
412 |
+
if ($subCategory != "") {
|
413 |
+
$curcategory [$k] ['is_child'] = true;
|
414 |
+
} else {
|
415 |
+
$curcategory [$k] ['is_child'] = false;
|
416 |
+
}
|
417 |
+
$k ++;
|
418 |
+
}
|
419 |
+
return $curcategory;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Get Available stores based on website id
|
424 |
+
*
|
425 |
+
* @param int $storeId
|
426 |
+
* @param int $websiteId
|
427 |
+
* @return array $storesArray
|
428 |
+
*/
|
429 |
+
public function getAvailableStores($websiteId) {
|
430 |
+
$storesArray = array ();
|
431 |
+
try {
|
432 |
+
$website = Mage::app ()->getWebsite ( $websiteId );
|
433 |
+
foreach ( $website->getGroups () as $group ) {
|
434 |
+
$stores = $group->getStores ();
|
435 |
+
$l = 0;
|
436 |
+
foreach ( $stores as $store ) {
|
437 |
+
$storesArray [$l] ['store_id'] = $store->getId ();
|
438 |
+
$storesArray [$l] [static::NAME] = $store->getName ();
|
439 |
+
$currency_code = Mage::app ()->getStore ( $store->getId () )->getCurrentCurrencyCode ();
|
440 |
+
$storesArray [$l] ['currency_code'] = $currency_code;
|
441 |
+
$storesArray [$l] ['currency_symbol'] = Mage::app ()->getLocale ()->currency ( $currency_code )->getSymbol ();
|
442 |
+
$l ++;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
} catch ( Exception $e ) {
|
446 |
+
$e->getMessage ();
|
447 |
+
}
|
448 |
+
return $storesArray;
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Get offers list
|
453 |
+
*
|
454 |
+
* @return array $OffersList
|
455 |
+
*/
|
456 |
+
public function getOffers($count) {
|
457 |
+
// Get today date
|
458 |
+
$today_date = Date ( 'Y-m-d' );
|
459 |
+
$model = Mage::getModel ( 'offers/offers' );
|
460 |
+
$collection = $model->getCollection ()->addFieldToFilter ( 'status', '1' )->addFieldToFilter ( 'from_date', array (
|
461 |
+
array (
|
462 |
+
'lteq' => $today_date
|
463 |
+
),
|
464 |
+
array (
|
465 |
+
'from_date',
|
466 |
+
'null' => ''
|
467 |
+
)
|
468 |
+
) )->addFieldToFilter ( 'to_date', array (
|
469 |
+
array (
|
470 |
+
'gteq' => $today_date
|
471 |
+
),
|
472 |
+
array (
|
473 |
+
'to_date',
|
474 |
+
'null' => ''
|
475 |
+
)
|
476 |
+
) )->setOrder ( "offers_id", 'DESC' );
|
477 |
+
$collection->setPageSize ( $count )->setCurPage ( 1 );
|
478 |
+
$i = 0;
|
479 |
+
$OffersList = array ();
|
480 |
+
foreach ( $collection as $offer ) {
|
481 |
+
$offer = $model->load ( $offer->getOffersId () );
|
482 |
+
// get offer id
|
483 |
+
$OffersList [$i] [static::ENTITYID] = $offer->getOffersId ();
|
484 |
+
// get type id as null
|
485 |
+
$OffersList [$i] [static::TYPE_ID] = '';
|
486 |
+
// get offer Title
|
487 |
+
$OffersList [$i] [static::NAME] = $offer->getOfferTitle ();
|
488 |
+
// get Offer image
|
489 |
+
$OffersList [$i] [static::IMGURL] = Mage::getBaseUrl ( 'media' ) . $offer->getOfferImg ();
|
490 |
+
$OffersList [$i] [static::REGULARPRICE] = '';
|
491 |
+
$OffersList [$i] [static::FINALPRICE] = '';
|
492 |
+
|
493 |
+
$i ++;
|
494 |
+
}
|
495 |
+
|
496 |
+
return $OffersList;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* function that is called when post is done **
|
501 |
+
* offer products list
|
502 |
+
*
|
503 |
+
* @param array $data
|
504 |
+
*
|
505 |
+
* @return array json array
|
506 |
+
*/
|
507 |
+
protected function _retrieve() {
|
508 |
+
$response = array ();
|
509 |
+
|
510 |
+
$offerId = ( int ) Mage::app ()->getRequest ()->getParam ( 'offer_id' );
|
511 |
+
|
512 |
+
// get website id from request
|
513 |
+
$websiteId = ( int ) Mage::app ()->getRequest ()->getParam ( static::WEBSITE_ID );
|
514 |
+
if ($websiteId <= 0) {
|
515 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
516 |
+
}
|
517 |
+
|
518 |
+
// get store id
|
519 |
+
$storeId = ( int ) Mage::app ()->getRequest ()->getParam ( static::STORE_ID );
|
520 |
+
if ($storeId <= 0) {
|
521 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
522 |
+
}
|
523 |
+
|
524 |
+
// get the offer model
|
525 |
+
$model = Mage::getModel ( 'offers/offers' )->load ( $offerId );
|
526 |
+
|
527 |
+
$response ['offer_title'] = $model ['offer_title'];
|
528 |
+
// get offer products
|
529 |
+
$offer_products = $model->getOfferProducts ();
|
530 |
+
|
531 |
+
// set offer_products data string to array to model
|
532 |
+
if (isset ( $offer_products ) && $offer_products != '') {
|
533 |
+
$offer_products = explode ( ',', $offer_products );
|
534 |
+
}
|
535 |
+
|
536 |
+
$productCollection = $this->offerProductList ( $offer_products, $storeId );
|
537 |
+
|
538 |
+
$response ['success'] = 1;
|
539 |
+
$response ['error'] = false;
|
540 |
+
$response ['total_count'] = count ( $offer_products );
|
541 |
+
$response ['result'] = $productCollection;
|
542 |
+
|
543 |
+
return $response;
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Get offer products list
|
548 |
+
*
|
549 |
+
* @param array $offer_products
|
550 |
+
* @param int $storeId
|
551 |
+
* @return $offerProdcuts
|
552 |
+
*/
|
553 |
+
public function offerProductList($offer_products, $storeId) {
|
554 |
+
$offerProdcuts = array ();
|
555 |
+
$customerId = ( int ) Mage::app ()->getRequest ()->getParam ( 'customer_id' );
|
556 |
+
// get image size for resize
|
557 |
+
$imageSize = ( int ) $this->getRequest ()->getParam ( 'image_size' );
|
558 |
+
// get page from request
|
559 |
+
$page = ( int ) $this->getRequest ()->getParam ( 'page' );
|
560 |
+
if ($page <= 0) {
|
561 |
+
$page = 1;
|
562 |
+
}
|
563 |
+
// get page from request
|
564 |
+
$limit = ( int ) $this->getRequest ()->getParam ( 'limit' );
|
565 |
+
if ($limit <= 0) {
|
566 |
+
$limit = 10;
|
567 |
+
}
|
568 |
+
$page = ($page - 1) * $limit;
|
569 |
+
// for pagination
|
570 |
+
$offer_products = array_slice ( $offer_products, $page, $limit );
|
571 |
+
|
572 |
+
foreach ( $offer_products as $key => $productid ) {
|
573 |
+
$item = Mage::getModel ( 'catalog/product' )->load ( $productid );
|
574 |
+
$item->setStoreId ( $storeId )->load ( $item->getId () );
|
575 |
+
// get product status
|
576 |
+
$productStatus = $item->getStatus ();
|
577 |
+
// get only enabled products
|
578 |
+
if ($productStatus == 1 && $item->getId () != '') {
|
579 |
+
// get product id
|
580 |
+
$products [static::ENTITYID] = $item->getId ();
|
581 |
+
|
582 |
+
// get product name
|
583 |
+
$products [static::NAME] = $item->getName ();
|
584 |
+
$products [static::TYPE_ID] = $item->getTypeId ();
|
585 |
+
// get the product final price
|
586 |
+
$products [static::REGULARPRICE] = number_format ( $item->getPrice (), 2, '.', '' );
|
587 |
+
$products [static::FINALPRICE] = number_format ( $item->getFinalPrice (), 2, '.', '' );
|
588 |
+
// get product stock details
|
589 |
+
$stockDetail = Mage::getModel ( static::LOGIN_TOKEN )->getStockDetail ( $item );
|
590 |
+
$products ['is_saleable'] = $stockDetail ['is_saleable'];
|
591 |
+
$products ['is_stock'] = $stockDetail ['is_stock'];
|
592 |
+
// get product image
|
593 |
+
if ($imageSize <= 0) {
|
594 |
+
$products [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $item, static::SMALLIMG );
|
595 |
+
} else {
|
596 |
+
$products [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $item, static::SMALLIMG )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
597 |
+
}
|
598 |
+
|
599 |
+
// get rating
|
600 |
+
$products ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $item->getId (), $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $item->getId (), $storeId ) : '0';
|
601 |
+
|
602 |
+
// get wishlisted products by customer
|
603 |
+
$wishListIds = array ();
|
604 |
+
if ($customerId > 0) {
|
605 |
+
$wishListIds = Mage::getModel ( static::LOGIN_TOKEN )->getWishlistByCustomer ( $customerId );
|
606 |
+
}
|
607 |
+
// Check to see the product is in wishlist
|
608 |
+
if (in_array ( $item->getId (), $wishListIds )) {
|
609 |
+
$products ['is_wishlist'] = true;
|
610 |
+
} else {
|
611 |
+
$products ['is_wishlist'] = false;
|
612 |
+
}
|
613 |
+
$offerProdcuts [] = $products;
|
614 |
+
}
|
615 |
+
$i ++;
|
616 |
+
}
|
617 |
+
return $offerProdcuts;
|
618 |
+
}
|
619 |
+
}
|
app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_HomePageapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest extends ContusRestapi_HomePageapi_Model_Api2_HomePageapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_HomePageapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest_Admin_V1 extends ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_HomePageapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest_Customer_V1 extends ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/HomePageapi/Model/Api2/HomePageapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_HomePageapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest_Guest_V1 extends ContusRestapi_HomePageapi_Model_Api2_HomePageapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/HomePageapi/etc/api2.xml
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="HomePageapi">
|
6 |
+
<title>Home Page API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<homePageapi translate="title" module="HomePageapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>homePageapi/api2_homePageapi</model>
|
14 |
+
<title>Home api</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
</customer>
|
26 |
+
<guest>
|
27 |
+
<create>1</create>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes module="api2">
|
32 |
+
<website_id>websiteid</website_id>
|
33 |
+
<store_id>Associate to Store</store_id>
|
34 |
+
<image_size>Image resize size</image_size>
|
35 |
+
<result>Result</result>
|
36 |
+
<offer_products>Offer Products</offer_products>
|
37 |
+
<categories>Categories</categories>
|
38 |
+
<new_products>New Arrivals</new_products>
|
39 |
+
<available_stores>Stores</available_stores>
|
40 |
+
<offer_id>Offer Id</offer_id>
|
41 |
+
<customer_id>Customer Id</customer_id>
|
42 |
+
<results>Results</results>
|
43 |
+
<success>Success</success>
|
44 |
+
<total_count>Total products</total_count>
|
45 |
+
<error>Error</error>
|
46 |
+
<Offer_title>Offer Title</Offer_title>
|
47 |
+
</attributes>
|
48 |
+
<routes>
|
49 |
+
<route_collection>
|
50 |
+
<route>/homepage/</route>
|
51 |
+
<action_type>collection</action_type>
|
52 |
+
</route_collection>
|
53 |
+
<offer_products>
|
54 |
+
<route>/offer_products/</route>
|
55 |
+
<action_type>entity</action_type>
|
56 |
+
</offer_products>
|
57 |
+
</routes>
|
58 |
+
<versions>1</versions>
|
59 |
+
</homePageapi>
|
60 |
+
|
61 |
+
</resources>
|
62 |
+
</api2>
|
63 |
+
</config>
|
app/code/local/ContusRestapi/HomePageapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_HomePageapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_HomePageapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<homePageapi>
|
11 |
+
<class>ContusRestapi_HomePageapi_Model</class>
|
12 |
+
</homePageapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Forgotpassword API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Login
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Login_Model_Api2_Forgotpassword extends Mage_Api2_Model_Resource {
|
32 |
+
/**
|
33 |
+
* function that is called when post is done **
|
34 |
+
*
|
35 |
+
* Forgot password action for registered customers
|
36 |
+
*
|
37 |
+
* @param array $data
|
38 |
+
*
|
39 |
+
* @return array json array
|
40 |
+
*/
|
41 |
+
protected function _create(array $data) {
|
42 |
+
$response = array ();
|
43 |
+
if ($data ['website_id'] != '') {
|
44 |
+
$websiteId = $data ['website_id'];
|
45 |
+
} else {
|
46 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
47 |
+
}
|
48 |
+
|
49 |
+
$email = $data ['email'];
|
50 |
+
try {
|
51 |
+
$customer = Mage::getModel ( 'customer/customer' )->setWebsiteId ( $websiteId )->loadByEmail ( $email );
|
52 |
+
|
53 |
+
if ($customer->getId ()) {
|
54 |
+
|
55 |
+
$newPassword = $this->createPassword (6);
|
56 |
+
$customer->changePassword ( $newPassword, false );
|
57 |
+
$customer->sendPasswordReminderEmail ();
|
58 |
+
$success = 1;
|
59 |
+
$message = 'A new password has been sent.';
|
60 |
+
} else {
|
61 |
+
$success = 0;
|
62 |
+
$message = 'Customer not found.';
|
63 |
+
}
|
64 |
+
} catch ( Exception $ex ) {
|
65 |
+
$success = 0;
|
66 |
+
$message = $ex->getMessage ();
|
67 |
+
}
|
68 |
+
$response ['error'] = false;
|
69 |
+
$response ['success'] = $success;
|
70 |
+
$response ['message'] = $message;
|
71 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
72 |
+
return;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Generate random password and if it is less than fixed characters, again call create character function.
|
77 |
+
*
|
78 |
+
* @param string $length Length for password
|
79 |
+
*
|
80 |
+
* @return string $password as password
|
81 |
+
*/
|
82 |
+
|
83 |
+
public function createPassword($length) {
|
84 |
+
$password = $this->createCharacter($length);
|
85 |
+
if(strlen($password) < $length){
|
86 |
+
$password = $this->createCharacter($length);
|
87 |
+
}
|
88 |
+
return $password;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Generate random password for customers login by Social network like facebook,twiter,etc,
|
93 |
+
*
|
94 |
+
* @param string $length Length for password
|
95 |
+
*
|
96 |
+
* @return string $password as password
|
97 |
+
*/
|
98 |
+
public function createCharacter($length){
|
99 |
+
$chars = "1234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
100 |
+
$i = 0;
|
101 |
+
$password = "";
|
102 |
+
|
103 |
+
while ( $i <= $length ) {
|
104 |
+
$password .= $chars {mt_rand ( 0, strlen ( $chars ) )};
|
105 |
+
$i ++;
|
106 |
+
}
|
107 |
+
return $password;
|
108 |
+
}
|
109 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Forgotpassword_Rest extends ContusRestapi_Login_Model_Api2_Forgotpassword {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Forgotpassword_Rest_Admin_V1 extends ContusRestapi_Login_Model_Api2_Forgotpassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Forgotpassword_Rest_Customer_V1 extends ContusRestapi_Login_Model_Api2_Forgotpassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Forgotpassword/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Forgotpassword_Rest_Guest_V1 extends ContusRestapi_Login_Model_Api2_Forgotpassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Login.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Login extends Mage_Api2_Model_Resource {
|
30 |
+
const STOREID = 'store_id';
|
31 |
+
const EMAIL = 'email';
|
32 |
+
const NEWSLETTER = 'newsletter';
|
33 |
+
const LOGIN_TOKEN = 'login/token';
|
34 |
+
const SUCCESS = 'success';
|
35 |
+
const MESSAGE = 'message';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* function that is called when post is done **
|
39 |
+
* Login action for registered customers
|
40 |
+
*
|
41 |
+
* @param array $data
|
42 |
+
*
|
43 |
+
* @return array json array
|
44 |
+
*/
|
45 |
+
public function _create(array $data) {
|
46 |
+
$response = array ();
|
47 |
+
|
48 |
+
// get website id from request
|
49 |
+
$websiteId = ( int ) $data ['website_id'];
|
50 |
+
if ($websiteId <= 0) {
|
51 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
52 |
+
}
|
53 |
+
// get store id from request
|
54 |
+
$storeId = ( int ) $data [static::STOREID];
|
55 |
+
if ($storeId <= 0) {
|
56 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
57 |
+
}
|
58 |
+
|
59 |
+
$email = $data ['email'];
|
60 |
+
$password = $data ['password'];
|
61 |
+
// getting the device token
|
62 |
+
$deviceToken = $data ['device_token'];
|
63 |
+
// getting the device type
|
64 |
+
$deviceType = $data ['device_type'];
|
65 |
+
|
66 |
+
/**
|
67 |
+
*
|
68 |
+
* @var $customer Mage_Customer_Model_Customer
|
69 |
+
*/
|
70 |
+
$customerObj = Mage::getModel ( 'customer/customer' );
|
71 |
+
$validated = 0;
|
72 |
+
// check customer
|
73 |
+
$validCustomer = $this->CheckCustomer ( $customerObj, $email, $password, $websiteId );
|
74 |
+
$success = $validCustomer [static::SUCCESS];
|
75 |
+
$message = $validCustomer [static::MESSAGE];
|
76 |
+
$validated = $validCustomer ['validate'];
|
77 |
+
|
78 |
+
if ($validated) {
|
79 |
+
Mage::getSingleton ( 'customer/session' )->loginById ( $customerObj->getEntityId () );
|
80 |
+
// get customer email
|
81 |
+
$result [static::EMAIL] = $customerObj->getEmail ();
|
82 |
+
$result ['firstname'] = $customerObj->getFirstname ();
|
83 |
+
$result ['lastname'] = $customerObj->getLastname ();
|
84 |
+
$result ['customer_id'] = $customerObj->getEntityId ();
|
85 |
+
|
86 |
+
$subscriber = Mage::getModel ( 'newsletter/subscriber' )->loadByEmail ( $customerObj->getEmail () );
|
87 |
+
if ($subscriber->getId () && $subscriber->getStatus () == 1) {
|
88 |
+
$result [static::NEWSLETTER] = 1;
|
89 |
+
} else {
|
90 |
+
$result [static::NEWSLETTER] = 0;
|
91 |
+
}
|
92 |
+
// get customer dob yyyy-mm-dd hh:mm:ss
|
93 |
+
$result ['dob'] = $customerObj->getDob ();
|
94 |
+
|
95 |
+
$tokenvalue = Mage::getModel ( static::LOGIN_TOKEN )->getRandomString ( 6 );
|
96 |
+
$tokenObj = Mage::getModel ( static::LOGIN_TOKEN )->load ( $customerObj->getEntityId (), 'userid' );
|
97 |
+
$tokenObj->setUserid ( $customerObj->getEntityId () );
|
98 |
+
$tokenObj->setToken ( $tokenvalue );
|
99 |
+
$tokenObj->setCreated ( date ( 'Y-m-d H:i:s' ) );
|
100 |
+
$tokenObj->setStatus ( 1 );
|
101 |
+
$tokenObj->save ();
|
102 |
+
//Update device token and type in token table
|
103 |
+
Mage::getModel ( 'login/methods_functions' )->updateDeviceToken ( $customerObj->getEntityId (), $deviceToken, $deviceType );
|
104 |
+
|
105 |
+
$result ['token'] = $tokenvalue;
|
106 |
+
$result ['cart_count'] = Mage::getModel ( static::LOGIN_TOKEN )->getCartCount ( $customerObj->getEntityId (), $storeId );
|
107 |
+
$response ['result'] = $result;
|
108 |
+
}
|
109 |
+
$response ['error'] = false;
|
110 |
+
$response [static::SUCCESS] = $success;
|
111 |
+
$response [static::MESSAGE] = $message;
|
112 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
public function CheckCustomer($customerObj, $email, $password, $websiteId) {
|
116 |
+
$result = array ();
|
117 |
+
if (! empty ( $email ) && ! empty ( $password )) {
|
118 |
+
try {
|
119 |
+
|
120 |
+
if ($customerObj->setWebsiteId ( $websiteId )->authenticate ( $email, $password )) {
|
121 |
+
$validated = 1;
|
122 |
+
$success = 1;
|
123 |
+
$message = 'You are successfully logged in.';
|
124 |
+
}
|
125 |
+
} catch ( Mage_Core_Exception $e ) {
|
126 |
+
switch ($e->getCode ()) {
|
127 |
+
case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED :
|
128 |
+
$message = 'This account is not confirmed.';
|
129 |
+
break;
|
130 |
+
case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD :
|
131 |
+
$message = 'Invalid email or password.';
|
132 |
+
break;
|
133 |
+
default :
|
134 |
+
$message = $e->getMessage ();
|
135 |
+
}
|
136 |
+
$success = 0;
|
137 |
+
} catch ( Exception $e ) {
|
138 |
+
$message = $e->getMessage ();
|
139 |
+
$success = 0;
|
140 |
+
}
|
141 |
+
} else {
|
142 |
+
$message = 'Email and password are required.';
|
143 |
+
$success = 0;
|
144 |
+
}
|
145 |
+
$result [static::SUCCESS] = $success;
|
146 |
+
$result [static::MESSAGE] = $message;
|
147 |
+
$result ['validate'] = $validated;
|
148 |
+
|
149 |
+
return $result;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* function that is called when post is done **
|
154 |
+
* Update GCM device token
|
155 |
+
*
|
156 |
+
* @param array $data
|
157 |
+
*
|
158 |
+
* @return array json array
|
159 |
+
*/
|
160 |
+
public function _update(array $data) {
|
161 |
+
$response = array ();
|
162 |
+
// getting the device token
|
163 |
+
$deviceToken = $data ['device_token'];
|
164 |
+
// getting the device type
|
165 |
+
$deviceType = $data ['device_type'];
|
166 |
+
$customerId = $data['customer_id'];
|
167 |
+
//Update device token and type in token table
|
168 |
+
Mage::getModel ( 'login/methods_functions' )->updateDeviceToken ( $customerId, $deviceToken, $deviceType );
|
169 |
+
$response ['error'] = false;
|
170 |
+
$response [static::SUCCESS] = 1;
|
171 |
+
$response [static::MESSAGE] = 'Device token updated successfully.';
|
172 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
173 |
+
return;
|
174 |
+
}
|
175 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Login_Rest extends ContusRestapi_Login_Model_Api2_Login {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Login_Rest_Admin_V1 extends ContusRestapi_Login_Model_Api2_Login_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Login_Rest_Customer_V1 extends ContusRestapi_Login_Model_Api2_Login_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Api2/Login/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Login_Model_Api2_Login_Rest_Guest_V1 extends ContusRestapi_Login_Model_Api2_Login_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Methods/Functions.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Token table model initialization
|
5 |
+
* Contus
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Login
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Login_Model_Methods_Functions extends Mage_Core_Model_Abstract {
|
32 |
+
const SLAES_QUOTE = 'sales/quote';
|
33 |
+
const RESULT = 'result';
|
34 |
+
const MESSAGE = 'message';
|
35 |
+
const DETAILS = 'details';
|
36 |
+
const TITLE = 'title';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get active shipping methods and payment methods
|
40 |
+
*
|
41 |
+
* @param int $quoteId
|
42 |
+
* @param int $storeId
|
43 |
+
* @return array $response
|
44 |
+
*/
|
45 |
+
public function getShippingPaymentMethods($quoteId, $storeId) {
|
46 |
+
$response = array ();
|
47 |
+
$shippings = array ();
|
48 |
+
if ($quoteId) {
|
49 |
+
try {
|
50 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->loadByIdWithoutStore ( $quoteId );
|
51 |
+
$shippingMethods = Mage::getModel ( 'checkout/cart_shipping_api' )->getShippingMethodsList ( $quoteId, $storeId );
|
52 |
+
$i = 0;
|
53 |
+
foreach ( $shippingMethods as $shipping ) {
|
54 |
+
$shippings [$i] ['carrier'] = $shipping ['carrier'];
|
55 |
+
$shippings [$i] ['carrier_title'] = $shipping ['carrier_title'];
|
56 |
+
$shippings [$i] ['code'] = $shipping ['code'];
|
57 |
+
$shippings [$i] ['method'] = $shipping ['method'];
|
58 |
+
$shippings [$i] ['method_description'] = $shipping ['method_description'];
|
59 |
+
$shippings [$i] ['price'] = number_format ( $shipping ['price'], 2, '.', '' );
|
60 |
+
$shippings [$i] ['error_message'] = $shipping ['error_message'];
|
61 |
+
$shippings [$i] ['method_title'] = $shipping ['method_title'];
|
62 |
+
$shippings [$i] ['carrierName'] = $shipping ['carrierName'];
|
63 |
+
$i ++;
|
64 |
+
}
|
65 |
+
$payMentMethods = $this->getActivPaymentMethods ( $quote );
|
66 |
+
$success = 1;
|
67 |
+
$message = "Get shipping and payment methods successfully.";
|
68 |
+
} catch ( Exception $e ) {
|
69 |
+
$success = 0;
|
70 |
+
$message = $e->getMessage ();
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
$success = 0;
|
74 |
+
$message = "Quote id not exist.";
|
75 |
+
}
|
76 |
+
$response ['success'] = $success;
|
77 |
+
$response [static::MESSAGE] = $message;
|
78 |
+
$response ['shipping_methods'] = $shippings;
|
79 |
+
$response ['payment_methods'] = $payMentMethods;
|
80 |
+
return $response;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Get active payment methods
|
85 |
+
*
|
86 |
+
* @param object $quote
|
87 |
+
* @return $result
|
88 |
+
*/
|
89 |
+
public function getActivPaymentMethods($quote) {
|
90 |
+
$total = $quote->getBaseSubtotal ();
|
91 |
+
$active_methods = Mage::getSingleton ( 'payment/config' )->getActiveMethods ();
|
92 |
+
$result = array ();
|
93 |
+
foreach ( $active_methods as $_code => $payment_model ) {
|
94 |
+
|
95 |
+
if ($_code != 'free' && ($total) > 0) {
|
96 |
+
$result [] = $this->getPayments ( $_code, $payment_model );
|
97 |
+
} else if ($_code == 'free' && $total <= 0) {
|
98 |
+
$_title = Mage::getStoreConfig ( 'payment/' . $_code . '/title' );
|
99 |
+
$paymentMethods ['code'] = $_code;
|
100 |
+
$paymentMethods [static::TITLE] = $_title;
|
101 |
+
$paymentMethods ['ccTypes'] = array ();
|
102 |
+
$result [] = $paymentMethods;
|
103 |
+
} else {
|
104 |
+
// no need this condition
|
105 |
+
}
|
106 |
+
}
|
107 |
+
return $result;
|
108 |
+
}
|
109 |
+
public function getPayments($_code, $payment_model) {
|
110 |
+
$_title = Mage::getStoreConfig ( 'payment/' . $_code . '/title' );
|
111 |
+
if (strtoupper ( $_code ) == 'PAYPAL_EXPRESS' || strtoupper ( $_code ) == 'PAYPAL_DIRECT' || strtoupper ( $_code ) == 'PAYPAL_STANDARD' || strtoupper ( $_code ) == 'PAYPALUK_DIRECT' || strtoupper ( $_code ) == 'PAYPALUK_EXPRESS') {
|
112 |
+
$paymentMethods ['code'] = 'paypal_standard';
|
113 |
+
} else {
|
114 |
+
$paymentMethods ['code'] = $_code;
|
115 |
+
}
|
116 |
+
|
117 |
+
$paymentMethods [static::TITLE] = $_title;
|
118 |
+
|
119 |
+
$ccTypes = explode ( ',', $payment_model->getConfigData ( 'cctypes' ) );
|
120 |
+
$aType = Mage::getSingleton ( 'payment/config' )->getCcTypes ();
|
121 |
+
$cc = array ();
|
122 |
+
$i = 0;
|
123 |
+
foreach ( $ccTypes as $cctype ) {
|
124 |
+
if ($cctype != '') {
|
125 |
+
$cc [$i] ['card_code'] = $cctype;
|
126 |
+
$cc [$i] ['card_name'] = $aType [$cctype];
|
127 |
+
|
128 |
+
$i ++;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
$paymentMethods ['ccTypes'] = $cc;
|
132 |
+
|
133 |
+
return $paymentMethods;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Update device token and type in token table
|
138 |
+
*
|
139 |
+
* @param int $customerId
|
140 |
+
* @param string $deviceToken
|
141 |
+
* @param string $deviceType
|
142 |
+
*/
|
143 |
+
public function updateDeviceToken($customerId, $deviceToken, $deviceType) {
|
144 |
+
$tokenObj = Mage::getModel ( 'login/token' )->load ( $customerId, 'userid' );
|
145 |
+
$tokenObj->setUserid ( $customerId );
|
146 |
+
$tokenObj->setDevicetoken ( $deviceToken );
|
147 |
+
$tokenObj->setDevicetype ( $deviceType );
|
148 |
+
$tokenObj->save ();
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Resource/Token.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Token table resource model initialization
|
4 |
+
*
|
5 |
+
* Contus
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Login
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Login_Model_Resource_Token extends Mage_Core_Model_Resource_Db_Abstract {
|
32 |
+
protected function _construct() {
|
33 |
+
$this->_init ( 'login/token', 'tokenid' );
|
34 |
+
}
|
35 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Resource/Token/Collection.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Token table resource model collection initialization
|
4 |
+
*
|
5 |
+
* Contus
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Login
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Login_Model_Resource_Token_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
32 |
+
public function _construct() {
|
33 |
+
parent::_construct ();
|
34 |
+
$this->_init ( 'login/token' );
|
35 |
+
}
|
36 |
+
}
|
app/code/local/ContusRestapi/Login/Model/Token.php
ADDED
@@ -0,0 +1,737 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Token table model initialization
|
4 |
+
* Contus
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_Login
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_Login_Model_Token extends Mage_Core_Model_Abstract {
|
31 |
+
const STOREID = 'store_id';
|
32 |
+
const FIRSTNAME = 'firstname';
|
33 |
+
const LASTNAME = 'lastname';
|
34 |
+
const NEWSLETTER = 'newsletter';
|
35 |
+
const ENTITYID = 'entity_id';
|
36 |
+
const CUSTOMERID = 'customer_id';
|
37 |
+
const EMAIL = 'email';
|
38 |
+
const SUCCESS = 'success';
|
39 |
+
const TOKEN = 'token';
|
40 |
+
const IS_SALABLE = 'is_saleable';
|
41 |
+
const IS_STOCK = 'is_stock';
|
42 |
+
const RATING = 'rating';
|
43 |
+
const PRODUCT_ID = 'product_id';
|
44 |
+
const QUOTE_ID = 'quote_id';
|
45 |
+
const QTY = 'qty';
|
46 |
+
const DISCOUNT = 'discount';
|
47 |
+
const SHIPPING_AMT = 'shipping_amount';
|
48 |
+
const TAX = 'tax';
|
49 |
+
const ITEM_COUNT = 'item_count';
|
50 |
+
const ITEMS_QTY = 'items_qty';
|
51 |
+
const GRAND_TOTAL = 'grand_total';
|
52 |
+
const SUBTOTAL = 'subtotal';
|
53 |
+
const COUPON_CODE = 'coupon_code';
|
54 |
+
const SLAES_QUOTE = 'sales/quote';
|
55 |
+
const IS_ACTIVE = 'is_active';
|
56 |
+
const CUSTOMER_CUSTOMER = 'customer/customer';
|
57 |
+
const ITEMS_COUNT = 'items_count';
|
58 |
+
const NO_ITEM = 'No items in your cart.';
|
59 |
+
const STOCK_QTY = 'stock_qty';
|
60 |
+
const CATALOG_STOCK = 'cataloginventory/stock_item';
|
61 |
+
const RESULT = 'result';
|
62 |
+
const MESSAGE = 'message';
|
63 |
+
const BILLING = 'billing';
|
64 |
+
const SHIPPING = 'shipping';
|
65 |
+
const CHECKOUT_CART_QTY = 'checkout/cart_link/use_qty';
|
66 |
+
const CONFIGURABLE = 'configurable';
|
67 |
+
protected function _construct() {
|
68 |
+
$this->_init ( 'login/token' );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Generate token value for customer
|
73 |
+
*/
|
74 |
+
public function getRandomString($length = 6) {
|
75 |
+
$validCharacters = "abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ123456789";
|
76 |
+
$validCharNumber = strlen ( $validCharacters );
|
77 |
+
$result = "";
|
78 |
+
for($i = 0; $i < $length; $i ++) {
|
79 |
+
$index = mt_rand ( 0, $validCharNumber - 1 );
|
80 |
+
$result .= $validCharacters [$index];
|
81 |
+
}
|
82 |
+
$tokobj = Mage::getModel ( 'login/token' )->load ( $result, 'token' );
|
83 |
+
if ($tokobj->getTokenid ()) {
|
84 |
+
$this->getRandomString ( 6 );
|
85 |
+
}
|
86 |
+
return $result;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check Customer has vaild token or not
|
91 |
+
*
|
92 |
+
* @param int $userid
|
93 |
+
* @param string $token
|
94 |
+
* @return boolean
|
95 |
+
*/
|
96 |
+
public function checkUserToken($userid, $token) {
|
97 |
+
$tokenObj = $this->load ( $userid, 'userid' );
|
98 |
+
$value = TRUE;
|
99 |
+
if ($tokenObj->getToken () == $token && trim ( $token ) != '') {
|
100 |
+
$value = TRUE;
|
101 |
+
} else {
|
102 |
+
$value = FALSE;
|
103 |
+
}
|
104 |
+
return $value;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Get Customer Details by id
|
109 |
+
*
|
110 |
+
* @param int $customerId
|
111 |
+
* @return array $response
|
112 |
+
*/
|
113 |
+
public function getCustomerDetail($customerId) {
|
114 |
+
$response = array ();
|
115 |
+
|
116 |
+
/**
|
117 |
+
*
|
118 |
+
* @var $customer Mage_Customer_Model_Customer
|
119 |
+
*/
|
120 |
+
$customerData = Mage::getModel ( static::CUSTOMER_CUSTOMER )->load ( $customerId )->getData ();
|
121 |
+
$customerID = $customerData [static::ENTITYID];
|
122 |
+
if (isset ( $customerID )) {
|
123 |
+
$response [static::SUCCESS] = 1;
|
124 |
+
$response [static::CUSTOMERID] = $customerData [static::ENTITYID];
|
125 |
+
// get customer name
|
126 |
+
$response [static::FIRSTNAME] = $customerData [static::FIRSTNAME];
|
127 |
+
$response [static::LASTNAME] = $customerData [static::LASTNAME];
|
128 |
+
// get customer email
|
129 |
+
$response [static::EMAIL] = $customerData [static::EMAIL];
|
130 |
+
$subscriber = Mage::getModel ( 'newsletter/subscriber' )->loadByEmail ( $customerData [static::EMAIL] );
|
131 |
+
if ($subscriber->getId () && $subscriber->getStatus () == 1) {
|
132 |
+
$response [static::NEWSLETTER] = 1;
|
133 |
+
} else {
|
134 |
+
$response [static::NEWSLETTER] = 0;
|
135 |
+
}
|
136 |
+
|
137 |
+
// get customer dob yyyy-mm-dd hh:mm:ss
|
138 |
+
$response ['dob'] = $customerData ['dob'];
|
139 |
+
$response [static::STOREID] = $customerData [static::STOREID];
|
140 |
+
} else {
|
141 |
+
$response [static::SUCCESS] = 0;
|
142 |
+
}
|
143 |
+
|
144 |
+
return $response;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get product count in cart by customer
|
149 |
+
*
|
150 |
+
* @param int $customerId
|
151 |
+
* @param int $storeId
|
152 |
+
* @return number $itemCount
|
153 |
+
*/
|
154 |
+
public function getCartCount($customerId, $storeId) {
|
155 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMERID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( static::IS_ACTIVE, "1" )->setOrder ( static::ENTITYID, 'desc' );
|
156 |
+
$quoteData = $quote->getData ();
|
157 |
+
$itemCount = '0';
|
158 |
+
$cartLink = Mage::getStoreConfig ( static::CHECKOUT_CART_QTY, $storeId );
|
159 |
+
if (isset ( $quoteData )) {
|
160 |
+
if ($cartLink) {
|
161 |
+
$itemCount = strval ( intval ( $quoteData [0] ['items_qty'] ) );
|
162 |
+
} else {
|
163 |
+
$itemCount = strval ( $quoteData [0] ['items_count'] );
|
164 |
+
}
|
165 |
+
}
|
166 |
+
return $itemCount;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Customer Wishlist collection
|
171 |
+
*
|
172 |
+
* @param int $customerId
|
173 |
+
*
|
174 |
+
* @return array $wishListIds
|
175 |
+
*/
|
176 |
+
public function getWishlistByCustomer($customerId) {
|
177 |
+
$wishListIds = array ();
|
178 |
+
|
179 |
+
/**
|
180 |
+
*
|
181 |
+
* @var $customer Mage_Customer_Model_Customer
|
182 |
+
*/
|
183 |
+
$customerModel = Mage::getModel ( static::CUSTOMER_CUSTOMER );
|
184 |
+
$customerModel->load ( $customerId );
|
185 |
+
if (! empty ( $customerModel [static::EMAIL] ) && $customerModel [static::EMAIL] != "") {
|
186 |
+
$wishList = Mage::getSingleton ( 'wishlist/wishlist' )->loadByCustomer ( $customerId, true );
|
187 |
+
$wishListItemCollection = $wishList->getItemCollection ();
|
188 |
+
if (count ( $wishListItemCollection ) > 0) {
|
189 |
+
foreach ( $wishListItemCollection as $wishitem ) {
|
190 |
+
$wishListIds [] = $wishitem->getProductId ();
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
return $wishListIds;
|
195 |
+
}
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Products Rating
|
199 |
+
*
|
200 |
+
* @param int $productId
|
201 |
+
* Getting the particular product id
|
202 |
+
* @param int $storeId
|
203 |
+
* @return array as json message as string and success rate count
|
204 |
+
*/
|
205 |
+
public function rateSummary($productId, $storeId) {
|
206 |
+
// getting rate model
|
207 |
+
$summaryData = Mage::getModel ( 'review/review_summary' )->setStoreId ( $storeId )->load ( $productId )->getRatingSummary ();
|
208 |
+
// calculate overage for ratings
|
209 |
+
return strval ( $summaryData / 20 );
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Get product reviews and Rating
|
214 |
+
*
|
215 |
+
* @param int $productId
|
216 |
+
* @param int $storeId
|
217 |
+
*
|
218 |
+
* @return array $response
|
219 |
+
*/
|
220 |
+
public function getReviews($productId, $storeId, $page, $limit) {
|
221 |
+
// get only five revieews in product detail page
|
222 |
+
$reviewcoll = Mage::getModel ( 'review/review' )->getResourceCollection ()->addStoreFilter ( $storeId )->addEntityFilter ( 'product', $productId )->addStatusFilter ( Mage_Review_Model_Review::STATUS_APPROVED )->setDateOrder ( 'desc' )->setPageSize ( $limit )->setCurPage ( $page )->addRateVotes ();
|
223 |
+
|
224 |
+
$response = array ();
|
225 |
+
$reviews = array ();
|
226 |
+
|
227 |
+
if (count ( $reviewcoll ) > 0) {
|
228 |
+
$j = 0;
|
229 |
+
// get all reviews collection
|
230 |
+
foreach ( $reviewcoll->getItems () as $key => $review ) {
|
231 |
+
$reviews [$j] ['title'] = $review->getTitle ();
|
232 |
+
$reviews [$j] ['detail'] = $review->getDetail ();
|
233 |
+
$reviews [$j] ['author'] = $review->getNickname ();
|
234 |
+
$reviews [$j] ['date'] = date ( "Y-m-d", strtotime ( $review->getCreatedAt () ) );
|
235 |
+
|
236 |
+
$rateAvg = 0;
|
237 |
+
|
238 |
+
foreach ( $review->getRatingVotes () as $vote ) {
|
239 |
+
$rateAvg += $vote->getPercent ();
|
240 |
+
}
|
241 |
+
// get summary rating
|
242 |
+
$reviews [$j] [static::RATING] = floor ( $rateAvg / 60 );
|
243 |
+
|
244 |
+
$j ++;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
$response ['reviews'] = $reviews;
|
249 |
+
return $response;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Get product reviews and Rating
|
254 |
+
*
|
255 |
+
* @param int $productId
|
256 |
+
* @param int $storeId
|
257 |
+
*
|
258 |
+
* @return array $response
|
259 |
+
*/
|
260 |
+
public function getRatingResult($productId, $storeId) {
|
261 |
+
$reviewcoll = Mage::getModel ( 'review/review' )->getResourceCollection ()->addStoreFilter ( $storeId )->addEntityFilter ( 'product', $productId )->addStatusFilter ( Mage_Review_Model_Review::STATUS_APPROVED )->setDateOrder ()->addRateVotes ();
|
262 |
+
$response = array ();
|
263 |
+
|
264 |
+
$rate = array ();
|
265 |
+
if (count ( $reviewcoll ) > 0) {
|
266 |
+
$j = 0;
|
267 |
+
// get all reviews collection
|
268 |
+
foreach ( $reviewcoll->getItems () as $key => $review ) {
|
269 |
+
$rateAvg = 0;
|
270 |
+
foreach ( $review->getRatingVotes () as $vote ) {
|
271 |
+
$rateAvg += $vote->getPercent ();
|
272 |
+
}
|
273 |
+
// get summary rating
|
274 |
+
$rating [$j] = trim ( floor ( $rateAvg / 60 ) );
|
275 |
+
$j ++;
|
276 |
+
}
|
277 |
+
// get rating count summary
|
278 |
+
$rating = array_count_values ( $rating );
|
279 |
+
for($k = 1; $k <= 5; $k ++) {
|
280 |
+
$ratingCount ['star'] = $k;
|
281 |
+
$ratingCount ['count'] = ($rating [$k] > 0 ? $rating [$k] : 0);
|
282 |
+
$rate [] = $ratingCount;
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
$response [static::RATING] = $rate;
|
287 |
+
return $response;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Get stock detail for product
|
292 |
+
*
|
293 |
+
* @param object $product
|
294 |
+
* @return array $_proudct_data
|
295 |
+
*/
|
296 |
+
public function getStockDetail($product) {
|
297 |
+
$_proudct_data = array ();
|
298 |
+
|
299 |
+
/**
|
300 |
+
* get stock details for product
|
301 |
+
*
|
302 |
+
* @var $stockItem Mage_CatalogInventory_Model_Stock_Item
|
303 |
+
*/
|
304 |
+
$stockItem = Mage::getModel ( static::CATALOG_STOCK )->loadByProduct ( $product->getId () );
|
305 |
+
if ($product->getTypeId () != static::CONFIGURABLE) {
|
306 |
+
$_proudct_data [static::IS_SALABLE] = ($product->getIsSalable () > 0);
|
307 |
+
$_proudct_data [static::IS_STOCK] = ($stockItem->getIsInStock () > 0);
|
308 |
+
}
|
309 |
+
/**
|
310 |
+
* get stock details for product
|
311 |
+
*
|
312 |
+
* @var $stockItem Mage_CatalogInventory_Model_Stock_Item
|
313 |
+
*/
|
314 |
+
$instock_childrenisinstock = false;
|
315 |
+
|
316 |
+
if ($product->getTypeId () == static::CONFIGURABLE) {
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Get children products (all associated children products data)
|
320 |
+
*/
|
321 |
+
$childProducts = Mage::getModel ( 'catalog/product_type_configurable' )->getUsedProducts ( null, $product );
|
322 |
+
|
323 |
+
$stockItem = $product->getStockItem ();
|
324 |
+
|
325 |
+
// get associated product stock detail
|
326 |
+
$instock_childrenisinstock = $this->getChildStock ( $stockItem, $childProducts );
|
327 |
+
|
328 |
+
if (! $instock_childrenisinstock) {
|
329 |
+
$_proudct_data [static::IS_SALABLE] = false;
|
330 |
+
$_proudct_data [static::IS_STOCK] = false;
|
331 |
+
} else {
|
332 |
+
$_proudct_data [static::IS_SALABLE] = true;
|
333 |
+
$_proudct_data [static::IS_STOCK] = true;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
|
337 |
+
return $_proudct_data;
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Get associated product stock
|
342 |
+
*
|
343 |
+
* @param object $stockItem
|
344 |
+
* @param array $childProducts
|
345 |
+
* @return boolean true| false
|
346 |
+
*/
|
347 |
+
public function getChildStock($stockItem, $childProducts) {
|
348 |
+
$instock_childrenisinstock = false;
|
349 |
+
if ($stockItem->getIsInStock ()) {
|
350 |
+
/**
|
351 |
+
* All configurable products, which are in stock
|
352 |
+
*/
|
353 |
+
|
354 |
+
foreach ( $childProducts as $childProduct ) {
|
355 |
+
$child_stockItem = $childProduct->getStockItem ();
|
356 |
+
Mage::getModel ( static::CATALOG_STOCK )->loadByProduct ( $childProduct );
|
357 |
+
if ($child_stockItem->getIsInStock ()) {
|
358 |
+
$instock_childrenisinstock = true;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
return $instock_childrenisinstock;
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Get Cart Amount Details
|
367 |
+
*
|
368 |
+
* @param array $data
|
369 |
+
* @return array $response
|
370 |
+
*/
|
371 |
+
public function getCartTotal($data) {
|
372 |
+
// get customer id
|
373 |
+
$customerId = $data [static::CUSTOMERID];
|
374 |
+
// get category id
|
375 |
+
$storeId = $data [static::STOREID];
|
376 |
+
$quoteData = $this->getQuoteIdBycustomer ( $customerId, $storeId );
|
377 |
+
$quoteId = $quoteData [0] [static::ENTITYID];
|
378 |
+
$cartTotal = array ();
|
379 |
+
$quote = $this->_getQuote ( $quoteId, $storeId );
|
380 |
+
$totals = $quote->getTotals ();
|
381 |
+
if (isset ( $totals [static::DISCOUNT] )) {
|
382 |
+
$discount = number_format ( abs ( $totals [static::DISCOUNT]->getValue () ), 2, '.', '' );
|
383 |
+
} else {
|
384 |
+
$discount = '';
|
385 |
+
}
|
386 |
+
// get system/configuration -checkout - cart liks value
|
387 |
+
$cartLink = Mage::getStoreConfig ( static::CHECKOUT_CART_QTY, $storeId );
|
388 |
+
if (isset ( $quoteData ) && ! empty ( $quoteData )) {
|
389 |
+
|
390 |
+
if ($cartLink) {
|
391 |
+
// Display Cart Summary - Display item quantities
|
392 |
+
$itemCount = strval ( intval ( $quoteData [0] [static::ITEMS_QTY] ) );
|
393 |
+
} else {
|
394 |
+
// Display Cart Summary - Display no.of items in cart
|
395 |
+
$itemCount = strval ( $quoteData [0] [static::ITEMS_COUNT] );
|
396 |
+
}
|
397 |
+
|
398 |
+
$cartTotal [static::ITEM_COUNT] = $itemCount;
|
399 |
+
$cartTotal [static::GRAND_TOTAL] = number_format ( $quoteData [0] [static::GRAND_TOTAL], 2, '.', '' );
|
400 |
+
$cartTotal [static::SUBTOTAL] = number_format ( $quoteData [0] [static::SUBTOTAL], 2, '.', '' );
|
401 |
+
$cartTotal [static::DISCOUNT] = $discount;
|
402 |
+
$cartTotal [static::QUOTE_ID] = $quoteId;
|
403 |
+
$cartTotal [static::COUPON_CODE] = $quoteData [0] [static::COUPON_CODE];
|
404 |
+
$addressobj = $quote->getShippingAddress ();
|
405 |
+
$cartTotal [static::SHIPPING_AMT] = 0;
|
406 |
+
$cartTotal [static::TAX] = 0;
|
407 |
+
if ($addressobj) {
|
408 |
+
$cartTotal [static::SHIPPING_AMT] = $quote->getShippingAddress ()->getData ( static::SHIPPING_AMT );
|
409 |
+
$cartTotal [static::TAX] = $quote->getShippingAddress ()->getData ( 'tax_amount' );
|
410 |
+
$cartTotal [static::SHIPPING_AMT] = number_format ( $cartTotal [static::SHIPPING_AMT], 2, '.', '' );
|
411 |
+
$cartTotal [static::TAX] = number_format ( $cartTotal ['tax'], 2, '.', '' );
|
412 |
+
}
|
413 |
+
} else {
|
414 |
+
|
415 |
+
$message = 'No items in your cart.';
|
416 |
+
}
|
417 |
+
$response [static::ITEM_COUNT] = $itemCount;
|
418 |
+
$response ['result'] = $cartTotal;
|
419 |
+
$response [static::SUCCESS] = false;
|
420 |
+
$response [static::MESSAGE] = $message;
|
421 |
+
return $response;
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Get Quote data by customer
|
426 |
+
*
|
427 |
+
* @param int $customerId
|
428 |
+
* @param int $storeId
|
429 |
+
* @return array $quoteData
|
430 |
+
*/
|
431 |
+
public function getQuoteIdBycustomer($customerId, $storeId) {
|
432 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMERID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( static::IS_ACTIVE, '1' )->setOrder ( static::ENTITYID, 'desc' );
|
433 |
+
return $quote->getData ();
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
*
|
438 |
+
* @param integer $quoteId
|
439 |
+
* @param integer $storeId
|
440 |
+
* @return mixed array $quote
|
441 |
+
*/
|
442 |
+
protected function _getQuote($quoteId, $storeId) {
|
443 |
+
/**
|
444 |
+
*
|
445 |
+
* @var $quote Mage_Sales_Model_Quote
|
446 |
+
*/
|
447 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
448 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
449 |
+
return $quote;
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Get cart quote by customer
|
454 |
+
*
|
455 |
+
* @param int $customerId
|
456 |
+
* @param in $storeId
|
457 |
+
* @return object $$quote
|
458 |
+
*/
|
459 |
+
public function setSaleQuoteByCustomer($customerId, $storeId, $currencyCode) {
|
460 |
+
/**
|
461 |
+
*
|
462 |
+
* @var $quote Mage_Sales_Model_Quote
|
463 |
+
*/
|
464 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMERID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( static::IS_ACTIVE, '1' )->setOrder ( static::ENTITYID, 'desc' );
|
465 |
+
$quoteData = $quote->getData ();
|
466 |
+
if (empty ( $quoteData )) {
|
467 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
468 |
+
$customer = Mage::getModel ( static::CUSTOMER_CUSTOMER )->load ( $customerId );
|
469 |
+
// Check this customer id is in record
|
470 |
+
if ($customer->getId ()) {
|
471 |
+
$quote->assignCustomer ( $customer );
|
472 |
+
$quote->setStore_id ( $storeId );
|
473 |
+
|
474 |
+
$quote->setQuoteCurrencyCode ( $currencyCode );
|
475 |
+
$quote->setGlobalCurrencyCode ( $currencyCode )->setCustomerId ( $customerId )->setUpdatedAt ( now () )->setCreatedAt ( now () );
|
476 |
+
$quote->setCustomerEmail ( $customer->getEmail () )->setCustomerFirstname ( $customer->getFirstname () )->setCustomerLastname ( $customer->getLastname () )->setCustomerIsGuest ( 0 )->setCustomer ( $customer );
|
477 |
+
$quote->save ();
|
478 |
+
} else {
|
479 |
+
$quote = 0;
|
480 |
+
}
|
481 |
+
} else {
|
482 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
483 |
+
$quote->setStoreId ( $storeId )->load ( $quoteData [0] [static::ENTITYID] );
|
484 |
+
$quote->setUpdatedAt ( now () );
|
485 |
+
}
|
486 |
+
return $quote;
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
*
|
491 |
+
* @param Mage_Sales_Model_Quote $quote
|
492 |
+
* @param Mage_Catalog_Model_Product $product
|
493 |
+
* @param Varien_Object $requestInfo
|
494 |
+
* @return Varien_Object
|
495 |
+
*/
|
496 |
+
public function _getQuoteItemByProduct(Mage_Sales_Model_Quote $quote, Mage_Catalog_Model_Product $product, Varien_Object $requestInfo) {
|
497 |
+
$cartCandidates = $product->getTypeInstance ( TRUE )->prepareForCartAdvanced ( $requestInfo, $product, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL );
|
498 |
+
/**
|
499 |
+
* Error message
|
500 |
+
*/
|
501 |
+
if (is_string ( $cartCandidates )) {
|
502 |
+
throw Mage::throwException ( $cartCandidates );
|
503 |
+
}
|
504 |
+
|
505 |
+
/**
|
506 |
+
* If prepare process return one object
|
507 |
+
*/
|
508 |
+
if (! is_array ( $cartCandidates )) {
|
509 |
+
$cartCandidates = array (
|
510 |
+
$cartCandidates
|
511 |
+
);
|
512 |
+
}
|
513 |
+
|
514 |
+
/**
|
515 |
+
*
|
516 |
+
* @var $item Mage_Sales_Model_Quote_Item
|
517 |
+
*/
|
518 |
+
$item = NULL;
|
519 |
+
foreach ( $cartCandidates as $candidate ) {
|
520 |
+
if ($candidate->getParentProductId ()) {
|
521 |
+
Mage::log ( 'productID' . $candidate->getParentProductId () );
|
522 |
+
continue;
|
523 |
+
}
|
524 |
+
|
525 |
+
$item = $quote->getItemByProduct ( $candidate );
|
526 |
+
}
|
527 |
+
|
528 |
+
if (is_null ( $item )) {
|
529 |
+
$item = Mage::getModel ( 'sales/quote_item' );
|
530 |
+
}
|
531 |
+
|
532 |
+
return $item;
|
533 |
+
}
|
534 |
+
|
535 |
+
/**
|
536 |
+
*
|
537 |
+
* @param array $requestInfo
|
538 |
+
* @return Varien_Object
|
539 |
+
*/
|
540 |
+
public function _getProductRequest($requestInfo) {
|
541 |
+
if ($requestInfo instanceof Varien_Object) {
|
542 |
+
$request = $requestInfo;
|
543 |
+
} elseif (is_numeric ( $requestInfo )) {
|
544 |
+
Mage::log ( 'else in product request' );
|
545 |
+
$request = new Varien_Object ();
|
546 |
+
$request->setQty ( $requestInfo );
|
547 |
+
} else {
|
548 |
+
$request = new Varien_Object ( $requestInfo );
|
549 |
+
}
|
550 |
+
|
551 |
+
if (! $request->hasQty ()) {
|
552 |
+
$request->setQty ( 1 );
|
553 |
+
}
|
554 |
+
|
555 |
+
return $request;
|
556 |
+
}
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Get Cart product details
|
560 |
+
*
|
561 |
+
* @param array $data
|
562 |
+
* @return array $response
|
563 |
+
*/
|
564 |
+
public function getCartProducts($data) {
|
565 |
+
|
566 |
+
// get category id
|
567 |
+
$storeId = $data [static::STOREID];
|
568 |
+
// get customer id
|
569 |
+
$customerId = $data [static::CUSTOMERID];
|
570 |
+
|
571 |
+
$quoteData = $this->getQuoteIdBycustomer ( $customerId, $storeId );
|
572 |
+
$quoteId = $quoteData [0] [static::ENTITYID];
|
573 |
+
|
574 |
+
$quote = $this->_getQuote ( $quoteId, $storeId );
|
575 |
+
$totals = $quote->getTotals ();
|
576 |
+
if (isset ( $totals [static::DISCOUNT] )) {
|
577 |
+
$discount = number_format ( abs ( $totals [static::DISCOUNT]->getValue () ), 2, '.', '' );
|
578 |
+
} else {
|
579 |
+
$discount = '';
|
580 |
+
}
|
581 |
+
// get system/configuration -checkout - cart liks value
|
582 |
+
$cartLink = Mage::getStoreConfig ( static::CHECKOUT_CART_QTY, $storeId );
|
583 |
+
$returnArray = array ();
|
584 |
+
$returnArray ['items'] = array ();
|
585 |
+
$items = array ();
|
586 |
+
if (isset ( $quoteData ) && ! empty ( $quoteData )) {
|
587 |
+
|
588 |
+
$itemCount = $quoteData [0] [static::ITEMS_COUNT];
|
589 |
+
if ($itemCount > 0) {
|
590 |
+
|
591 |
+
if ($cartLink) {
|
592 |
+
// Display Cart Summary - Display item quantities
|
593 |
+
$itemCount = strval ( intval ( $quoteData [0] [static::ITEMS_QTY] ) );
|
594 |
+
} else {
|
595 |
+
// Display Cart Summary - Display no.of items in cart
|
596 |
+
$itemCount = strval ( $quoteData [0] [static::ITEMS_COUNT] );
|
597 |
+
}
|
598 |
+
|
599 |
+
$returnArray [static::ITEM_COUNT] = $itemCount;
|
600 |
+
$returnArray [static::SHIPPING_AMT] = 0;
|
601 |
+
$returnArray [static::TAX] = 0;
|
602 |
+
$returnArray [static::GRAND_TOTAL] = number_format ( $quoteData [0] [static::GRAND_TOTAL], 2, '.', '' );
|
603 |
+
$returnArray [static::SUBTOTAL] = number_format ( $quoteData [0] [static::SUBTOTAL], 2, '.', '' );
|
604 |
+
$returnArray [static::DISCOUNT] = $discount;
|
605 |
+
$returnArray [static::QUOTE_ID] = $quoteId;
|
606 |
+
$returnArray [static::COUPON_CODE] = $quoteData [0] [static::COUPON_CODE];
|
607 |
+
$addressobj = $quote->getShippingAddress ();
|
608 |
+
|
609 |
+
if ($addressobj) {
|
610 |
+
$returnArray [static::SHIPPING_AMT] = $quote->getShippingAddress ()->getData ( static::SHIPPING_AMT );
|
611 |
+
$returnArray [static::TAX] = $quote->getShippingAddress ()->getData ( 'tax_amount' );
|
612 |
+
$returnArray [static::SHIPPING_AMT] = number_format ( $returnArray [static::SHIPPING_AMT], 2, '.', '' );
|
613 |
+
$returnArray [static::TAX] = number_format ( $returnArray ['tax'], 2, '.', '' );
|
614 |
+
}
|
615 |
+
|
616 |
+
$i = 0;
|
617 |
+
|
618 |
+
foreach ( $quote->getAllVisibleItems () as $item ) {
|
619 |
+
$product = $item->getProduct ();
|
620 |
+
$product->setStoreId ( $storeId )->load ( $product->getId () );
|
621 |
+
$items [$i] ['type_id'] = $item->getProductType ();
|
622 |
+
$items [$i] ['item_id_test'] = $item->getItemId ();
|
623 |
+
// get product id
|
624 |
+
$items [$i] [static::ENTITYID] = $product->getEntityId ();
|
625 |
+
// get product name
|
626 |
+
$items [$i] ['name'] = $product->getName ();
|
627 |
+
// get product image
|
628 |
+
$items [$i] ['image_url'] = ( string ) Mage::helper ( 'catalog/image' )->init ( $product, 'small_image' );
|
629 |
+
// get product price
|
630 |
+
$items [$i] ['price'] = number_format ( $item->getPrice (), 2, '.', '' );
|
631 |
+
// get product qty
|
632 |
+
$items [$i] [static::QTY] = $item->getQty ();
|
633 |
+
// get product row total
|
634 |
+
$items [$i] ['row_total'] = number_format ( $item->getRowTotal (), 2, '.', '' );
|
635 |
+
|
636 |
+
$stockDetail = $this->getProductStock ( $product, $item );
|
637 |
+
$items [$i] [static::STOCK_QTY] = $stockDetail [static::STOCK_QTY];
|
638 |
+
$items [$i] [static::IS_STOCK] = $stockDetail [static::IS_STOCK];
|
639 |
+
$items [$i] ['config'] = Mage::getModel ( 'catalog/product_type_configurable' )->getOrderOptions ( $product );
|
640 |
+
$i ++;
|
641 |
+
}
|
642 |
+
|
643 |
+
$returnArray ['items'] = $items;
|
644 |
+
$returnArray ['address'] = $this->getAddressByCustomer ( $customerId );
|
645 |
+
$error = false;
|
646 |
+
$message = 'Quote fetched successfully.';
|
647 |
+
} else {
|
648 |
+
|
649 |
+
$error = false;
|
650 |
+
$message = static::NO_ITEM;
|
651 |
+
}
|
652 |
+
} else {
|
653 |
+
$error = true;
|
654 |
+
$message = static::NO_ITEM;
|
655 |
+
}
|
656 |
+
$response [static::ITEM_COUNT] = $itemCount;
|
657 |
+
$response [static::RESULT] = $returnArray;
|
658 |
+
$response [static::SUCCESS] = $error;
|
659 |
+
$response [static::MESSAGE] = $message;
|
660 |
+
return $response;
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Get product stock details
|
665 |
+
*
|
666 |
+
* @param object $product
|
667 |
+
* @param object $item
|
668 |
+
* @return array $items
|
669 |
+
*/
|
670 |
+
public function getProductStock($product, $item) {
|
671 |
+
$items = array ();
|
672 |
+
if ($product->getTypeId () != static::CONFIGURABLE) {
|
673 |
+
// get product availabile qty
|
674 |
+
$items [static::STOCK_QTY] = intval ( Mage::getModel ( static::CATALOG_STOCK )->loadByProduct ( $product )->getQty () );
|
675 |
+
$stockItem = $product->getStockItem ();
|
676 |
+
if (! $stockItem) {
|
677 |
+
$stockItem = Mage::getModel ( static::CATALOG_STOCK );
|
678 |
+
$stockItem->loadByProduct ( $product );
|
679 |
+
}
|
680 |
+
// get product stock status
|
681 |
+
$items [static::IS_STOCK] = ($stockItem->getIsInStock () > 0);
|
682 |
+
} else {
|
683 |
+
|
684 |
+
$asso_productId = intval ( preg_replace ( '/[^0-9]+/', '', json_encode ( $item->getQtyOptions () ) ), 10 );
|
685 |
+
// get simple product stock status
|
686 |
+
$stockLevel = Mage::getModel ( static::CATALOG_STOCK )->loadByProduct ( $asso_productId );
|
687 |
+
$items [static::STOCK_QTY] = intval ( $stockLevel->getQty () );
|
688 |
+
// get stock details for product
|
689 |
+
// get config product stock status
|
690 |
+
$stockItem = Mage::getModel ( static::CATALOG_STOCK )->loadByProduct ( $product->getId () );
|
691 |
+
if ($stockLevel->getIsInStock () == 1 && $stockItem->getIsInStock () == 1) {
|
692 |
+
$items [static::IS_STOCK] = true;
|
693 |
+
} else {
|
694 |
+
$items [static::IS_STOCK] = false;
|
695 |
+
}
|
696 |
+
}
|
697 |
+
return $items;
|
698 |
+
}
|
699 |
+
/**
|
700 |
+
* Get customer default billing and shipping address
|
701 |
+
*
|
702 |
+
* @param int $customerId
|
703 |
+
*/
|
704 |
+
public function getAddressByCustomer($customerId) {
|
705 |
+
$address = array ();
|
706 |
+
$customerObj = Mage::getModel ( 'customer/customer' )->load ( $customerId );
|
707 |
+
|
708 |
+
// get customer default billing address
|
709 |
+
$billingAddress = $customerObj->getDefaultBillingAddress ();
|
710 |
+
if ($billingAddress) {
|
711 |
+
$country = Mage::getModel ( 'directory/country' )->loadByCode ( $billingAddress->country_id );
|
712 |
+
$billingAddress->setData ( 'country_name', $country->getName () );
|
713 |
+
$address [static::BILLING] = $billingAddress->getData ();
|
714 |
+
$address [static::BILLING] ['street'] = $billingAddress->getStreet ();
|
715 |
+
$address [static::BILLING] ['region_code'] = $billingAddress->getRegionCode ();
|
716 |
+
$address ['is_billing'] = true;
|
717 |
+
} else {
|
718 |
+
$address ['is_billing'] = false;
|
719 |
+
}
|
720 |
+
// get customer default shipping address
|
721 |
+
$shippingAddress = $customerObj->getDefaultShippingAddress ();
|
722 |
+
if ($shippingAddress) {
|
723 |
+
$country = Mage::getModel ( 'directory/country' )->loadByCode ( $shippingAddress->country_id );
|
724 |
+
$shippingAddress->setData ( 'country_name', $country->getName () );
|
725 |
+
$address [static::SHIPPING] = $shippingAddress->getData ();
|
726 |
+
$address [static::SHIPPING] ['street'] = $shippingAddress->getStreet ();
|
727 |
+
$address [static::SHIPPING] ['region_code'] = $shippingAddress->getRegionCode ();
|
728 |
+
$address ['is_shipping'] = true;
|
729 |
+
} else {
|
730 |
+
$address ['is_shipping'] = false;
|
731 |
+
}
|
732 |
+
|
733 |
+
return $address;
|
734 |
+
}
|
735 |
+
|
736 |
+
|
737 |
+
}
|
app/code/local/ContusRestapi/Login/etc/api2.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="Login">
|
6 |
+
<title>Login API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<login translate="title" module="Login">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>login/api2_login</model>
|
14 |
+
<title>Customer Login</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
<delete>1</delete>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<create>1</create>
|
29 |
+
<retrieve>1</retrieve>
|
30 |
+
<delete>1</delete>
|
31 |
+
<update>1</update>
|
32 |
+
</guest>
|
33 |
+
</privileges>
|
34 |
+
<attributes module="api2">
|
35 |
+
<email>email</email>
|
36 |
+
<website_id>websiteid</website_id>
|
37 |
+
<action>action</action>
|
38 |
+
<password>password</password>
|
39 |
+
<success>success</success>
|
40 |
+
<message>message</message>
|
41 |
+
<name>name</name>
|
42 |
+
<userid>userid</userid>
|
43 |
+
<error>Error</error>
|
44 |
+
<device_token>Device Token</device_token>
|
45 |
+
<device_type>Device Type</device_type>
|
46 |
+
<customer_id>Customer Id</customer_id>
|
47 |
+
</attributes>
|
48 |
+
<routes>
|
49 |
+
<route_collection>
|
50 |
+
<route>/customer/login</route>
|
51 |
+
<action_type>collection</action_type>
|
52 |
+
</route_collection>
|
53 |
+
|
54 |
+
<gcmtoken_update>
|
55 |
+
<route>/customer/gcmtoken_update/</route>
|
56 |
+
<action_type>entity</action_type>
|
57 |
+
</gcmtoken_update>
|
58 |
+
</routes>
|
59 |
+
<versions>1</versions>
|
60 |
+
</login>
|
61 |
+
|
62 |
+
<customer translate="title" module="api2">
|
63 |
+
<attributes translate="password" module="api2">
|
64 |
+
<password>Password</password>
|
65 |
+
</attributes>
|
66 |
+
</customer>
|
67 |
+
<login_forgot_pass translate="title" module="Login">
|
68 |
+
<group>contusrestapi</group>
|
69 |
+
<model>login/api2_forgotpassword</model>
|
70 |
+
<!-- <working_model>restapi/api2_restapi</working_model> -->
|
71 |
+
<title>Customer Forgot Password</title>
|
72 |
+
<sort_order>12</sort_order>
|
73 |
+
<privileges>
|
74 |
+
<admin>
|
75 |
+
<create>1</create>
|
76 |
+
<retrieve>1</retrieve>
|
77 |
+
<delete>1</delete>
|
78 |
+
</admin>
|
79 |
+
<customer>
|
80 |
+
<create>1</create>
|
81 |
+
<retrieve>1</retrieve>
|
82 |
+
<delete>1</delete>
|
83 |
+
</customer>
|
84 |
+
<guest>
|
85 |
+
<create>1</create>
|
86 |
+
<retrieve>1</retrieve>
|
87 |
+
<delete>1</delete>
|
88 |
+
</guest>
|
89 |
+
</privileges>
|
90 |
+
<attributes module="api2">
|
91 |
+
<email>Email</email>
|
92 |
+
<status>status</status>
|
93 |
+
<message>message</message>
|
94 |
+
<website_id>Website Id</website_id>
|
95 |
+
<error>Error</error>
|
96 |
+
</attributes>
|
97 |
+
<routes>
|
98 |
+
<route_collection>
|
99 |
+
<route>/customer/forgotpassword</route>
|
100 |
+
<action_type>collection</action_type>
|
101 |
+
</route_collection>
|
102 |
+
</routes>
|
103 |
+
<versions>1</versions>
|
104 |
+
</login_forgot_pass>
|
105 |
+
|
106 |
+
|
107 |
+
</resources>
|
108 |
+
</api2>
|
109 |
+
</config>
|
app/code/local/ContusRestapi/Login/etc/config.xml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Login>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_Login>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<customer>
|
11 |
+
<rewrite>
|
12 |
+
<api2_customer_rest>ContusRestapi_Login_Model_Api2_Registration_Rest</api2_customer_rest>
|
13 |
+
<api2_customer_rest_customer_v1>ContusRestapi_Login_Model_Api2_Registration_Rest_Customer_V1</api2_customer_rest_customer_v1>
|
14 |
+
</rewrite>
|
15 |
+
</customer>
|
16 |
+
<login>
|
17 |
+
<class>ContusRestapi_Login_Model</class>
|
18 |
+
<resourceModel>login_resource</resourceModel>
|
19 |
+
</login>
|
20 |
+
|
21 |
+
<login_resource>
|
22 |
+
<class>ContusRestapi_Login_Model_Resource</class>
|
23 |
+
<entities>
|
24 |
+
<token>
|
25 |
+
<table>token</table>
|
26 |
+
</token>
|
27 |
+
</entities>
|
28 |
+
</login_resource>
|
29 |
+
</models>
|
30 |
+
<resources>
|
31 |
+
<login_setup>
|
32 |
+
<setup>
|
33 |
+
<module>ContusRestapi_Login</module>
|
34 |
+
<class>Mage_Core_Model_Resource_Setup</class>
|
35 |
+
</setup>
|
36 |
+
</login_setup>
|
37 |
+
</resources>
|
38 |
+
</global>
|
39 |
+
</config>
|
app/code/local/ContusRestapi/Login/sql/login_setup/install-0.0.1.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Token table installation script
|
4 |
+
*
|
5 |
+
* @category ContusRestapi
|
6 |
+
* @package ContusRestapi_Login
|
7 |
+
*/
|
8 |
+
/**
|
9 |
+
*
|
10 |
+
* @var $installer Mage_Core_Model_Resource_Setup
|
11 |
+
*/
|
12 |
+
|
13 |
+
$installer = $this;
|
14 |
+
|
15 |
+
$installer->run ( "DROP TABLE IF EXISTS " . $installer->getTable ( 'login/token' ) );
|
16 |
+
|
17 |
+
$token = $installer->getConnection ()->newTable ( $installer->getTable ( 'login/token' ) )->addColumn ( 'tokenid', Varien_Db_Ddl_Table::TYPE_INTEGER, NULL, array (
|
18 |
+
'unsigned' => TRUE,
|
19 |
+
'identity' => TRUE,
|
20 |
+
'nullable' => FALSE,
|
21 |
+
'primary' => TRUE
|
22 |
+
), 'Token Auto Id' )->addColumn ( 'userid', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array (
|
23 |
+
'unsigned' => TRUE,
|
24 |
+
'nullable' => FALSE
|
25 |
+
), 'Userid' )->addColumn ( 'token', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
|
26 |
+
'nullable' => TRUE,
|
27 |
+
'default' => NULL
|
28 |
+
), 'Token' )->addColumn ( 'devicetoken', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
|
29 |
+
'nullable' => TRUE,
|
30 |
+
'default' => NULL
|
31 |
+
), 'Devicetoken' )->addColumn ( 'devicetype', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array (
|
32 |
+
'nullable' => TRUE,
|
33 |
+
'default' => NULL
|
34 |
+
), 'Devicetype' )->addColumn ( 'created', Varien_Db_Ddl_Table::TYPE_DATETIME, NULL, array (), 'Created Date' )->addColumn ( 'status', Varien_Db_Ddl_Table::TYPE_INTEGER, 2, array (
|
35 |
+
'unsigned' => TRUE,
|
36 |
+
'nullable' => FALSE
|
37 |
+
), 'Status' );
|
38 |
+
|
39 |
+
$installer->getConnection ()->createTable ( $token );
|
app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi.php
ADDED
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Bulk Cart Api
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_MultiCartapi
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi extends Mage_Api2_Model_Resource {
|
32 |
+
// define staic variable
|
33 |
+
const STOREID = 'store_id';
|
34 |
+
const WEBSITEID = 'website_id';
|
35 |
+
const CUSTOMER_ID = 'customer_id';
|
36 |
+
const ENTITYID = 'entity_id';
|
37 |
+
const PRODUCT_ID = 'product_id';
|
38 |
+
const QUOTE_ID = 'quote_id';
|
39 |
+
const SLAES_QUOTE = 'sales/quote';
|
40 |
+
const SUCCESS = 'success';
|
41 |
+
const MESSAGE = 'message';
|
42 |
+
const ERROR = 'error';
|
43 |
+
const RESULT = 'result';
|
44 |
+
const TOKEN = 'token';
|
45 |
+
const ITEM_COUNT = 'item_count';
|
46 |
+
const ITEMS_COUNT = 'items_count';
|
47 |
+
const LINKS = 'links';
|
48 |
+
const LOGIN_TOKEN = 'login/token';
|
49 |
+
const VALID_TOKEN = 'isValidToken';
|
50 |
+
const AUTH_FAIL = 'Authentication failed.';
|
51 |
+
const CUSTOM_OPTION = 'custom_option';
|
52 |
+
const OPTIONS = 'options';
|
53 |
+
const SUPER_ATTR = 'super_attribute';
|
54 |
+
const SUPER_GRP = 'super_group';
|
55 |
+
const QTY = 'qty';
|
56 |
+
const UPDATED = 'updated';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* function that is called when post is done **
|
60 |
+
* Add product to cart
|
61 |
+
*
|
62 |
+
* @param array $data
|
63 |
+
* @return array json array
|
64 |
+
*/
|
65 |
+
protected function _create(array $data) {
|
66 |
+
$response = array ();
|
67 |
+
$messages = array ();
|
68 |
+
// Get website id
|
69 |
+
$websiteId = (isset ( $data [static::WEBSITEID] )) ? $data [static::WEBSITEID] : Mage::app ()->getWebsite ( 'base' )->getId ();
|
70 |
+
// get store id
|
71 |
+
$storeId = (isset ( $data [static::STOREID] )) ? $data [static::STOREID] : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
72 |
+
// get customer id
|
73 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
74 |
+
|
75 |
+
$products = $data ['detail'];
|
76 |
+
|
77 |
+
// get base currency code
|
78 |
+
$currencyCode = (isset ( $data ['currencyCode'] )) ? $data ['currencyCode'] : Mage::app ()->getStore ()->getBaseCurrencyCode ();
|
79 |
+
|
80 |
+
// get cart quote by customer
|
81 |
+
$quote = Mage::getModel ( static::LOGIN_TOKEN )->setSaleQuoteByCustomer ( $customerId, $storeId, $currencyCode );
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Check this customer has valid token or not
|
85 |
+
*
|
86 |
+
* @var $isValidToken Mage_Login_Model_Token
|
87 |
+
*/
|
88 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $data [static::TOKEN] );
|
89 |
+
$errors = array ();
|
90 |
+
try {
|
91 |
+
|
92 |
+
if (! $isValidToken) {
|
93 |
+
throw new Exception ( static::AUTH_FAIL );
|
94 |
+
}
|
95 |
+
$i = 0;
|
96 |
+
foreach ( $products as $item ) {
|
97 |
+
$product = $this->_getProduct ( $item [static::PRODUCT_ID], $storeId, 'id' );
|
98 |
+
if (is_null ( $product )) {
|
99 |
+
$error = $item [static::PRODUCT_ID] . ' - Can not specify the product.';
|
100 |
+
} else {
|
101 |
+
$error = $this->addToCart ( $product, $quote, $item [static::QTY], $item );
|
102 |
+
}
|
103 |
+
|
104 |
+
if (is_string ( $error )) {
|
105 |
+
$messages [$i] [static::MESSAGE] = $product->getName () . '- ' . $error;
|
106 |
+
$messages [$i] [static::SUCCESS] = 0;
|
107 |
+
} else {
|
108 |
+
$messages [$i] [static::MESSAGE] = $product->getName () . ' was added to your cart successfully.';
|
109 |
+
|
110 |
+
$messages [$i] [static::SUCCESS] = 1;
|
111 |
+
}
|
112 |
+
$i ++;
|
113 |
+
$success = 1;
|
114 |
+
$message = '';
|
115 |
+
$error_flag = true;
|
116 |
+
}
|
117 |
+
$quote->collectTotals ();
|
118 |
+
$quote->save ();
|
119 |
+
} catch ( Mage_Core_Exception $e ) {
|
120 |
+
|
121 |
+
$message = $e->getMessage ();
|
122 |
+
$success = 0;
|
123 |
+
$error_flag = false;
|
124 |
+
}
|
125 |
+
|
126 |
+
// get cart product list
|
127 |
+
$prodctsList = Mage::getModel ( static::LOGIN_TOKEN )->getCartProducts ( array (
|
128 |
+
static::STOREID => $storeId,
|
129 |
+
static::CUSTOMER_ID => $customerId
|
130 |
+
) );
|
131 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
132 |
+
$response [static::SUCCESS] = $success;
|
133 |
+
$response [static::ERROR] = $error_flag;
|
134 |
+
$response [static::MESSAGE] = implode ( ',', $errors );
|
135 |
+
$response [static::RESULT] = $prodctsList [static::RESULT];
|
136 |
+
$response [static::RESULT] ['errors'] = $messages;
|
137 |
+
|
138 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* function that is called when put is done **
|
144 |
+
* Update Cart products Qty
|
145 |
+
*
|
146 |
+
* @param array $data
|
147 |
+
* @return array json array
|
148 |
+
*/
|
149 |
+
protected function _update(array $data) {
|
150 |
+
$response = array ();
|
151 |
+
$messages = array ();
|
152 |
+
$message = '';
|
153 |
+
// get quote id from request
|
154 |
+
$quoteId = ( int ) $data [static::QUOTE_ID];
|
155 |
+
|
156 |
+
// get customer id from request
|
157 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
158 |
+
|
159 |
+
// Get website id
|
160 |
+
$websiteId = (isset ( $data [static::WEBSITEID] )) ? $data [static::WEBSITEID] : Mage::app ()->getWebsite ( 'base' )->getId ();
|
161 |
+
// get store id
|
162 |
+
$storeId = (isset ( $data [static::STOREID] )) ? $data [static::STOREID] : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
163 |
+
|
164 |
+
$products = $data ['detail'];
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Check this customer has valid token or not
|
168 |
+
*
|
169 |
+
* @var $isValidToken Mage_Login_Model_Token
|
170 |
+
*/
|
171 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $data [static::TOKEN] );
|
172 |
+
try {
|
173 |
+
|
174 |
+
if (! $isValidToken) {
|
175 |
+
throw new Exception ( static::AUTH_FAIL );
|
176 |
+
}
|
177 |
+
|
178 |
+
$i = 0;
|
179 |
+
$error_flag = true;
|
180 |
+
|
181 |
+
foreach ( $products as $item ) {
|
182 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
183 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
184 |
+
$productByItem = $this->_getProduct ( $item [static::PRODUCT_ID], $storeId, 'id' );
|
185 |
+
|
186 |
+
if (is_null ( $productByItem )) {
|
187 |
+
|
188 |
+
$messages [$i] [static::UPDATED] = 0;
|
189 |
+
$messages [$i] [static::MESSAGE] = 'Item is not available.';
|
190 |
+
$error_flag = false;
|
191 |
+
} else {
|
192 |
+
$productItem = $this->updateToCart ( $productByItem, $quote, $item [static::QTY], $item );
|
193 |
+
$quoteItem = Mage::getModel ( static::LOGIN_TOKEN )->_getQuoteItemByProduct ( $quote, $productByItem, Mage::getModel ( static::LOGIN_TOKEN )->_getProductRequest ( $productItem ) );
|
194 |
+
|
195 |
+
$update = $this->cartUpdate ( $quoteItem, $quote, $item [static::QTY] );
|
196 |
+
$messages [$i] [static::UPDATED] = $update [static::SUCCESS];
|
197 |
+
$messages [$i] [static::MESSAGE] = $productByItem->getName () . '- ' . $update [static::MESSAGE];
|
198 |
+
}
|
199 |
+
if ($messages [$i] [static::UPDATED] == 0) {
|
200 |
+
$error_flag = false;
|
201 |
+
}
|
202 |
+
|
203 |
+
$i ++;
|
204 |
+
$success = 1;
|
205 |
+
}
|
206 |
+
if ($error_flag) {
|
207 |
+
$success = 1;
|
208 |
+
$message = 'Cart updated successfully.';
|
209 |
+
} else {
|
210 |
+
$success = 0;
|
211 |
+
$message = 'Cart not updated.';
|
212 |
+
}
|
213 |
+
} catch ( Mage_Core_Exception $e ) {
|
214 |
+
|
215 |
+
$message = $e->getMessage ();
|
216 |
+
$success = 0;
|
217 |
+
}
|
218 |
+
// get cart product list
|
219 |
+
$prodctsList = Mage::getModel ( static::LOGIN_TOKEN )->getCartProducts ( array (
|
220 |
+
static::STOREID => $storeId,
|
221 |
+
static::CUSTOMER_ID => $customerId
|
222 |
+
) );
|
223 |
+
$response [static::ERROR] = false;
|
224 |
+
|
225 |
+
$response [static::SUCCESS] = $success;
|
226 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
227 |
+
$response [static::MESSAGE] = $message;
|
228 |
+
$response [static::RESULT] = $prodctsList [static::RESULT];
|
229 |
+
$response [static::RESULT] ['errors'] = $messages;
|
230 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
231 |
+
|
232 |
+
return;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Get product details
|
237 |
+
*
|
238 |
+
* @param integer $productId
|
239 |
+
* @param string $store
|
240 |
+
* @param string $identifierType
|
241 |
+
* @return NULL array
|
242 |
+
*/
|
243 |
+
public function _getProduct($productId, $store = NULL, $identifierType = NULL) {
|
244 |
+
|
245 |
+
/**
|
246 |
+
*
|
247 |
+
* @var $product Mage_Catalog_Model_Product
|
248 |
+
*/
|
249 |
+
$product = Mage::helper ( 'catalog/product' )->getProduct ( $productId, $store, $identifierType );
|
250 |
+
if (! $product->getId ()) {
|
251 |
+
return NULL;
|
252 |
+
}
|
253 |
+
|
254 |
+
return $product;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
*
|
259 |
+
* @param integer $quoteId
|
260 |
+
* @param integer $storeId
|
261 |
+
* @return mixed array $quote
|
262 |
+
*/
|
263 |
+
protected function _getQuote($quoteId, $storeId) {
|
264 |
+
/**
|
265 |
+
*
|
266 |
+
* @var $quote Mage_Sales_Model_Quote
|
267 |
+
*/
|
268 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE );
|
269 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
270 |
+
return $quote;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Get Quote data by customer
|
275 |
+
*
|
276 |
+
* @param int $customerId
|
277 |
+
* @param int $storeId
|
278 |
+
* @return array $quoteData
|
279 |
+
*/
|
280 |
+
public function getQuoteIdBycustomer($customerId, $storeId) {
|
281 |
+
$quote = Mage::getModel ( static::SLAES_QUOTE )->getCollection ()->addFieldToFilter ( static::CUSTOMER_ID, $customerId )->addFieldToFilter ( static::STOREID, $storeId )->addFieldToFilter ( 'is_active', '1' )->setOrder ( static::ENTITYID, 'desc' );
|
282 |
+
return $quote->getData ();
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Add product to cart
|
287 |
+
*
|
288 |
+
* @param object $product
|
289 |
+
* @param object $quote
|
290 |
+
* @param int $qty
|
291 |
+
* @return $result
|
292 |
+
*/
|
293 |
+
public function addToCart($product, $quote, $qty, $data) {
|
294 |
+
// get product type
|
295 |
+
$type = $product->getTypeId ();
|
296 |
+
switch ($type) {
|
297 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
298 |
+
$request_add = new Varien_Object ( array (
|
299 |
+
static::SUPER_GRP => $qty
|
300 |
+
) );
|
301 |
+
$result = $quote->addProduct ( $product, $request_add );
|
302 |
+
break;
|
303 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
304 |
+
$request_add = new Varien_Object ( array (
|
305 |
+
static::SUPER_ATTR => $data [static::SUPER_ATTR],
|
306 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
307 |
+
static::QTY => $qty
|
308 |
+
) );
|
309 |
+
$result = $quote->addProduct ( $product, $request_add );
|
310 |
+
break;
|
311 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
312 |
+
$request_add = new Varien_Object ( array (
|
313 |
+
static::LINKS => explode ( ',', $data [static::LINKS] ),
|
314 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
315 |
+
static::QTY => $qty
|
316 |
+
) );
|
317 |
+
$result = $quote->addProduct ( $product, $request_add );
|
318 |
+
break;
|
319 |
+
default :
|
320 |
+
if (isset ( $data [static::CUSTOM_OPTION] )) {
|
321 |
+
$request_add = new Varien_Object ( array (
|
322 |
+
static::OPTIONS => $data [static::CUSTOM_OPTION],
|
323 |
+
static::QTY => $qty
|
324 |
+
) );
|
325 |
+
}
|
326 |
+
$result = $quote->addProduct ( $product, $request_add );
|
327 |
+
break;
|
328 |
+
}
|
329 |
+
return $result;
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* Update product to cart
|
334 |
+
*
|
335 |
+
* @param object $productByItem
|
336 |
+
* @param object $quote
|
337 |
+
* @param int $qty
|
338 |
+
* @return $result
|
339 |
+
*/
|
340 |
+
public function updateToCart($productByItem, $quote, $qty, $data) {
|
341 |
+
$type = $productByItem->getTypeId ();
|
342 |
+
$updateProduct = '';
|
343 |
+
switch ($type) {
|
344 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
345 |
+
$updateProduct = new Varien_Object ( array (
|
346 |
+
static::SUPER_GRP => $qty
|
347 |
+
) );
|
348 |
+
$quote->addProduct ( $product, $request );
|
349 |
+
break;
|
350 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
351 |
+
if (isset ( $data [static::SUPER_ATTR] ) && $data [static::SUPER_ATTR] != '') {
|
352 |
+
$updateProduct = new Varien_Object ( array (
|
353 |
+
static::SUPER_ATTR => json_decode ( $data [static::SUPER_ATTR], true ),
|
354 |
+
static::OPTIONS => json_decode ( $data [static::CUSTOM_OPTION], true ),
|
355 |
+
static::QTY => $qty
|
356 |
+
) );
|
357 |
+
}
|
358 |
+
break;
|
359 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
360 |
+
if (isset ( $data [static::LINKS] ) && $data [static::LINKS] != '') {
|
361 |
+
$updateProduct = new Varien_Object ( array (
|
362 |
+
static::LINKS => explode ( ',', $data [static::LINKS] ),
|
363 |
+
static::OPTIONS => json_decode ( $data [static::CUSTOM_OPTION], true ),
|
364 |
+
static::QTY => $qty
|
365 |
+
) );
|
366 |
+
}
|
367 |
+
break;
|
368 |
+
default :
|
369 |
+
if (isset ( $data [static::CUSTOM_OPTION] ) && $data [static::CUSTOM_OPTION] != '') {
|
370 |
+
$updateProduct = new Varien_Object ( array (
|
371 |
+
static::OPTIONS => json_decode ( $data [static::CUSTOM_OPTION], true ),
|
372 |
+
static::QTY => $qty
|
373 |
+
) );
|
374 |
+
} else {
|
375 |
+
$updateProduct = '';
|
376 |
+
}
|
377 |
+
break;
|
378 |
+
}
|
379 |
+
|
380 |
+
return $updateProduct;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Update product in cart
|
385 |
+
*
|
386 |
+
* @param object $quoteItem
|
387 |
+
* @param object $quote
|
388 |
+
* @return array $response
|
389 |
+
*/
|
390 |
+
public function cartUpdate($quoteProduct, $quote, $qty) {
|
391 |
+
$response = array ();
|
392 |
+
if (empty ( $quoteProduct )) {
|
393 |
+
$success = 0;
|
394 |
+
$message = 'Item is not added in cart';
|
395 |
+
} else {
|
396 |
+
if ($qty > 0) {
|
397 |
+
$quoteProduct->setQty ( $qty );
|
398 |
+
} else {
|
399 |
+
$quote->removeItem ( $quoteProduct->getId () );
|
400 |
+
}
|
401 |
+
$quote->getBillingAddress ();
|
402 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( TRUE );
|
403 |
+
$quote->collectTotals ();
|
404 |
+
$quote->save ();
|
405 |
+
$success = 1;
|
406 |
+
$message = 'Cart updated successfully.';
|
407 |
+
}
|
408 |
+
|
409 |
+
$response [static::SUCCESS] = $success;
|
410 |
+
$response [static::MESSAGE] = $message;
|
411 |
+
return $response;
|
412 |
+
}
|
413 |
+
}
|
app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MultiCartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest extends ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MultiCartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest_Admin_V1 extends ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MultiCartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest_Customer_V1 extends ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MultiCartapi/Model/Api2/MultiCartapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MultiCartapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest_Guest_V1 extends ContusRestapi_MultiCartapi_Model_Api2_MultiCartapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MultiCartapi/etc/api2.xml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="MultiCartapi">
|
6 |
+
<title>Multi Cartapi</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<multiCartapi translate="title" module="MultiCartapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>multiCartapi/api2_multiCartapi</model>
|
14 |
+
<title>Add Multiple products to Cart</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
<update>1</update>
|
22 |
+
</admin>
|
23 |
+
<customer>
|
24 |
+
<create>1</create>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
<delete>1</delete>
|
27 |
+
<update>1</update>
|
28 |
+
</customer>
|
29 |
+
<guest>
|
30 |
+
<create>1</create>
|
31 |
+
<retrieve>1</retrieve>
|
32 |
+
<delete>1</delete>
|
33 |
+
<update>1</update>
|
34 |
+
</guest>
|
35 |
+
</privileges>
|
36 |
+
<attributes module="api2">
|
37 |
+
<website_id>Website id</website_id>
|
38 |
+
<store_id>Store Id</store_id>
|
39 |
+
<customer_id>customer Id</customer_id>
|
40 |
+
<product_id>product Id</product_id>
|
41 |
+
<quote_id>quote Id</quote_id>
|
42 |
+
<qty>qty</qty>
|
43 |
+
<super_attribute>super_attribute</super_attribute>
|
44 |
+
<custom_option>Custom Option</custom_option>
|
45 |
+
<links>Links</links>
|
46 |
+
<currencyCode>Currency code</currencyCode>
|
47 |
+
<result>Result</result>
|
48 |
+
<success>success</success>
|
49 |
+
<message>message</message>
|
50 |
+
<token>Token</token>
|
51 |
+
<isValidToken>Is Valid Token</isValidToken>
|
52 |
+
<items>Item</items>
|
53 |
+
<item_count>Item Count</item_count>
|
54 |
+
<items_qty>Item Qty</items_qty>
|
55 |
+
<grand_total>Grand Total</grand_total>
|
56 |
+
<subtotal>SubTotal</subtotal>
|
57 |
+
<discount>Discount</discount>
|
58 |
+
<coupon_code>Coupon Code</coupon_code>
|
59 |
+
<shipping_amount>Shipping Amount</shipping_amount>
|
60 |
+
<address>Address</address>
|
61 |
+
<tax>Tax</tax>
|
62 |
+
<detail>Detail</detail>
|
63 |
+
<errors>Errors</errors>
|
64 |
+
</attributes>
|
65 |
+
<routes>
|
66 |
+
<route_collection>
|
67 |
+
<route>/cart/bulk_add</route>
|
68 |
+
<action_type>collection</action_type>
|
69 |
+
</route_collection>
|
70 |
+
<!-- Cart products collection -->
|
71 |
+
|
72 |
+
<cart_delete>
|
73 |
+
<route>/cart/bulk_delete/links/:links/super_attribute/:super_attribute/custom_option/:custom_option/quote_id/:quote_id/product_id/:product_id/customer_id/:customer_id/store_id/:store_id/website_id/:website_id/token/:token
|
74 |
+
</route> <!-- qid = quote_id, pid = product_id -->
|
75 |
+
<action_type>entity</action_type>
|
76 |
+
</cart_delete>
|
77 |
+
|
78 |
+
<cart_update>
|
79 |
+
<route>/cart/bulk_update/</route>
|
80 |
+
<action_type>entity</action_type>
|
81 |
+
</cart_update>
|
82 |
+
|
83 |
+
</routes>
|
84 |
+
<versions>1</versions>
|
85 |
+
</multiCartapi>
|
86 |
+
|
87 |
+
</resources>
|
88 |
+
</api2>
|
89 |
+
</config>
|
app/code/local/ContusRestapi/MultiCartapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_MultiCartapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_MultiCartapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<multiCartapi>
|
11 |
+
<class>ContusRestapi_MultiCartapi_Model</class>
|
12 |
+
</multiCartapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi.php
ADDED
@@ -0,0 +1,427 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the EULA
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://www.apptha.com/LICENSE.txt
|
12 |
+
*
|
13 |
+
* ==============================================================
|
14 |
+
* MAGENTO EDITION USAGE NOTICE
|
15 |
+
* ==============================================================
|
16 |
+
* This package designed for Magento COMMUNITY edition
|
17 |
+
* Apptha does not guarantee correct work of this extension
|
18 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
19 |
+
* Apptha does not provide extension support in case of
|
20 |
+
* incorrect edition usage.
|
21 |
+
* ==============================================================
|
22 |
+
*
|
23 |
+
* @category Contus
|
24 |
+
* @package ContusRestapi_MyOrders
|
25 |
+
* @author Contus Team <developers@contus.in>
|
26 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
27 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
28 |
+
* @since 1.0
|
29 |
+
*/
|
30 |
+
class ContusRestapi_MyOrders_Model_Api2_MyOrderapi extends Mage_Sales_Model_Api2_Order_Rest {
|
31 |
+
|
32 |
+
// Declaring the string literals variable
|
33 |
+
const STOREID = 'store_id';
|
34 |
+
const CUSTOMERID = 'customer_id';
|
35 |
+
const ATTR_INFO = 'attributes_info';
|
36 |
+
const OPTIONS = 'options';
|
37 |
+
const SHIPPING_ADDR = 'shipping_address';
|
38 |
+
const RESULT = 'result';
|
39 |
+
const SUCCESS = 'success';
|
40 |
+
const MESSAGE = 'message';
|
41 |
+
const ERROR = 'error';
|
42 |
+
const VALID_TOKEN = 'isValidToken';
|
43 |
+
const LOGIN_TOKEN = 'login/token';
|
44 |
+
const TOKEN = 'token';
|
45 |
+
const TOTAL_COUNT = 'total_count';
|
46 |
+
const AUTH_ERR_MSG = 'Authentication failed.';
|
47 |
+
const SALES_ORDER = 'sales/order';
|
48 |
+
const ORDER_ID = 'order_id';
|
49 |
+
const STATUS = 'status';
|
50 |
+
const ITEM_ID = 'item_id';
|
51 |
+
const PURCHASE_ID = 'purchased_id';
|
52 |
+
const ORDER_ITEM_ID = 'order_item_id';
|
53 |
+
const CREATED_AT = 'created_at';
|
54 |
+
const PRODUCT_ID = 'product_id';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Retrieve information about specified order item
|
58 |
+
*
|
59 |
+
* @throws Mage_Api2_Exception
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
protected function _retrieve() {
|
63 |
+
$response = array ();
|
64 |
+
$ordersData = array ();
|
65 |
+
$orderId = $this->getRequest ()->getParam ( 'id' );
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Check this customer has valid token or not
|
69 |
+
*
|
70 |
+
* @var $isValidToken Mage_Login_Model_Token
|
71 |
+
*/
|
72 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( Mage::app ()->getRequest ()->getParam ( static::CUSTOMERID ), Mage::app ()->getRequest ()->getParam ( static::TOKEN ) );
|
73 |
+
try {
|
74 |
+
|
75 |
+
/**
|
76 |
+
*
|
77 |
+
* @var $order Mage_Sales_Model_Order
|
78 |
+
*/
|
79 |
+
if (! $isValidToken) {
|
80 |
+
throw new Exception ( static::AUTH_ERR_MSG );
|
81 |
+
}
|
82 |
+
|
83 |
+
$order = Mage::getModel ( static::SALES_ORDER )->loadByIncrementId ( $orderId );
|
84 |
+
if ($order->getIncrementId () != '') {
|
85 |
+
// get order id
|
86 |
+
$ordersData [static::ORDER_ID] = $order->getIncrementId ();
|
87 |
+
$ordersData [static::STATUS] = ucfirst ( strtolower ( $order->getStatusLabel () ) );
|
88 |
+
$ordersData ['order_date'] = $order->getCreatedAt ();
|
89 |
+
$ordersData ['item_count'] = $order->getTotalItemCount ();
|
90 |
+
$ordersData ['grand_total'] = number_format ( $order->getGrandTotal (), 2, '.', '' );
|
91 |
+
// get shipping address
|
92 |
+
$shipping_address = $order->getShippingAddress ();
|
93 |
+
if ($shipping_address) {
|
94 |
+
$shippingAddresDetail = $shipping_address->getData ();
|
95 |
+
// get shipping address details
|
96 |
+
$ordersData [static::SHIPPING_ADDR] ['firstname'] = $shippingAddresDetail ['firstname'];
|
97 |
+
$ordersData [static::SHIPPING_ADDR] ['lastname'] = $shippingAddresDetail ['lastname'];
|
98 |
+
$ordersData [static::SHIPPING_ADDR] ['street'] = explode ( "\n", $shippingAddresDetail ['street'] );
|
99 |
+
$ordersData [static::SHIPPING_ADDR] ['city'] = $shippingAddresDetail ['city'];
|
100 |
+
$ordersData [static::SHIPPING_ADDR] ['region'] = $shippingAddresDetail ['region'];
|
101 |
+
$ordersData [static::SHIPPING_ADDR] ['country_id'] = $shippingAddresDetail ['country_id'];
|
102 |
+
// get country name by country id
|
103 |
+
$country = Mage::getModel ( 'directory/country' )->loadByCode ( $shipping_address->country_id );
|
104 |
+
$ordersData [static::SHIPPING_ADDR] ['country_name'] = $country->getName ();
|
105 |
+
$ordersData [static::SHIPPING_ADDR] ['telephone'] = $shippingAddresDetail ['telephone'];
|
106 |
+
$ordersData [static::SHIPPING_ADDR] ['postcode'] = $shippingAddresDetail ['postcode'];
|
107 |
+
}
|
108 |
+
$orderCurrencyCode = $order->getOrderCurrencyCode ();
|
109 |
+
$ordersData ['currency_symbol'] = Mage::app ()->getLocale ()->currency ( $orderCurrencyCode )->getSymbol ();
|
110 |
+
// get shipping method
|
111 |
+
$ordersData ['shipping_method'] = $order->getShippingDescription ();
|
112 |
+
// get payment method
|
113 |
+
$ordersData ['payment_method'] = $order->getPayment ()->getMethodInstance ()->getTitle ();
|
114 |
+
|
115 |
+
$orderItems = $order->getItemsCollection ();
|
116 |
+
// get item collection
|
117 |
+
$ordersData ['items'] = $this->getOrderedItemDetail ( $orderItems );
|
118 |
+
// get shipping amount
|
119 |
+
$ordersData ['shipping_amount'] = number_format ( $order ['base_shipping_amount'], 2, '.', '' );
|
120 |
+
$ordersData ['discount_amount'] = number_format ( $order ['base_discount_amount'], 2, '.', '' );
|
121 |
+
$ordersData ['tax_amount'] = number_format ( $order ['base_tax_amount'], 2, '.', '' );
|
122 |
+
$ordersData ['sub_amount'] = number_format ( $order ['base_subtotal'], 2, '.', '' );
|
123 |
+
$ordersData ['total_amount'] = number_format ( $order ['base_grand_total'], 2, '.', '' );
|
124 |
+
$success = 1;
|
125 |
+
$message = 'Get order details.';
|
126 |
+
} else {
|
127 |
+
$success = 0;
|
128 |
+
$message = 'No data found.';
|
129 |
+
}
|
130 |
+
} catch ( Exception $e ) {
|
131 |
+
$success = 0;
|
132 |
+
$message = $e->getMessage ();
|
133 |
+
}
|
134 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
135 |
+
$response [static::ERROR] = false;
|
136 |
+
$response [static::SUCCESS] = $success;
|
137 |
+
$response [static::MESSAGE] = $message;
|
138 |
+
$response [static::RESULT] = $ordersData;
|
139 |
+
return json_encode ( $response );
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get orders list
|
144 |
+
*
|
145 |
+
* @return array
|
146 |
+
*/
|
147 |
+
protected function _retrieveCollection() {
|
148 |
+
$response = array ();
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Check this customer has valid token or not
|
152 |
+
*
|
153 |
+
* @var $isValidToken Mage_Login_Model_Token
|
154 |
+
*/
|
155 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( Mage::app ()->getRequest ()->getParam ( static::CUSTOMERID ), Mage::app ()->getRequest ()->getParam ( static::TOKEN ) );
|
156 |
+
|
157 |
+
if ($isValidToken) {
|
158 |
+
|
159 |
+
$response = $this->_getCollectionForRetrieve ();
|
160 |
+
} else {
|
161 |
+
$success = 0;
|
162 |
+
$message = static::AUTH_ERR_MSG;
|
163 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
164 |
+
$response [static::ERROR] = false;
|
165 |
+
$response [static::SUCCESS] = $success;
|
166 |
+
$response [static::MESSAGE] = $message;
|
167 |
+
$response [static::TOTAL_COUNT] = 0;
|
168 |
+
|
169 |
+
$response [static::RESULT] = array ();
|
170 |
+
}
|
171 |
+
|
172 |
+
return json_encode ( $response );
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Retrieve collection instance for orders list
|
177 |
+
*
|
178 |
+
* @return Mage_Sales_Model_Resource_Order_Collection
|
179 |
+
*/
|
180 |
+
protected function _getCollectionForRetrieve() {
|
181 |
+
|
182 |
+
// get website id from request
|
183 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( 'website_id' );
|
184 |
+
if ($websiteId <= 0) {
|
185 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
186 |
+
}
|
187 |
+
// get store id from request
|
188 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
189 |
+
if ($storeId <= 0) {
|
190 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
191 |
+
}
|
192 |
+
|
193 |
+
// get page from request
|
194 |
+
$page = ( int ) $this->getRequest ()->getParam ( 'page' );
|
195 |
+
// get page from request
|
196 |
+
$limit = ( int ) $this->getRequest ()->getParam ( 'limit' );
|
197 |
+
|
198 |
+
/**
|
199 |
+
*
|
200 |
+
* @var $collection Mage_Sales_Model_Resource_Order_Collection
|
201 |
+
*/
|
202 |
+
$collection = Mage::getResourceModel ( 'sales/order_collection' );
|
203 |
+
if (isset ( $_GET ) && Mage::app ()->getRequest ()->getParam ( static::CUSTOMERID )) {
|
204 |
+
$collection->addFieldToFilter ( static::CUSTOMERID, Mage::app ()->getRequest ()->getParam ( static::CUSTOMERID ) )->addFieldToFilter ( static::STOREID, $storeId );
|
205 |
+
$collection->setPage ( $page, $limit );
|
206 |
+
$collection->setOrder ( static::CREATED_AT, 'DESC' );
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($this->_isPaymentMethodAllowed ()) {
|
210 |
+
$this->_addPaymentMethodInfo ( $collection );
|
211 |
+
}
|
212 |
+
if ($this->_isGiftMessageAllowed ()) {
|
213 |
+
$this->_addGiftMessageInfo ( $collection );
|
214 |
+
}
|
215 |
+
$this->_addTaxInfo ( $collection );
|
216 |
+
$this->_applyCollectionModifiers ( $collection );
|
217 |
+
|
218 |
+
$ordersData = array ();
|
219 |
+
$i = 0;
|
220 |
+
$collection->getSelectSql ( true );
|
221 |
+
|
222 |
+
// get total orders count
|
223 |
+
$totalOrders = $collection->getSize ();
|
224 |
+
$last_page = ceil ( $totalOrders / $limit );
|
225 |
+
if ($last_page < $page) {
|
226 |
+
$success = 1;
|
227 |
+
$message = 'No Orders Found';
|
228 |
+
$ordersData = array();
|
229 |
+
} else {
|
230 |
+
|
231 |
+
$collection = $collection->getItems ();
|
232 |
+
foreach ( $collection as $order ) {
|
233 |
+
$name = '';
|
234 |
+
/**
|
235 |
+
*
|
236 |
+
* @var $order Mage_Sales_Model_Order
|
237 |
+
*/
|
238 |
+
$order = Mage::getModel ( static::SALES_ORDER )->load ( $order->getId () );
|
239 |
+
$shipping_address = $order->getShippingAddress ();
|
240 |
+
$billing_address = $order->getBillingAddress ();
|
241 |
+
if ($shipping_address) {
|
242 |
+
$name = $shipping_address->getFirstname () . ' ' . $shipping_address->getLastname ();
|
243 |
+
} else {
|
244 |
+
$name = $billing_address->getFirstname () . ' ' . $billing_address->getLastname ();
|
245 |
+
}
|
246 |
+
|
247 |
+
$ordersData [$i] [static::ORDER_ID] = $order->getIncrementId ();
|
248 |
+
$ordersData [$i] [static::STATUS] = ucfirst ( strtolower ( $order->getStatusLabel () ) );
|
249 |
+
$ordersData [$i] ['order_date'] = $order->getCreatedAt ();
|
250 |
+
$ordersData [$i] ['item_count'] = $order->getTotalItemCount ();
|
251 |
+
|
252 |
+
$ordersData [$i] ['grand_total'] = number_format ( $order->getGrandTotal (), 2, '.', '' );
|
253 |
+
|
254 |
+
$ordersData [$i] ['ship_name'] = $name;
|
255 |
+
$orderCurrencyCode = $order->getOrderCurrencyCode ();
|
256 |
+
$ordersData [$i] ['currency_symbol'] = Mage::app ()->getLocale ()->currency ( $orderCurrencyCode )->getSymbol ();
|
257 |
+
$i ++;
|
258 |
+
}
|
259 |
+
$success = 1;
|
260 |
+
$message = 'Orders listed successfully.';
|
261 |
+
}
|
262 |
+
|
263 |
+
$response [static::VALID_TOKEN] = true;
|
264 |
+
$response [static::ERROR] = false;
|
265 |
+
$response [static::SUCCESS] = $success;
|
266 |
+
$response [static::MESSAGE] = $message;
|
267 |
+
$response [static::TOTAL_COUNT] = $totalOrders;
|
268 |
+
$response [static::RESULT] = $ordersData;
|
269 |
+
return $response;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Get ordered item collection
|
274 |
+
*
|
275 |
+
* @param array $orderItems
|
276 |
+
* @return $items
|
277 |
+
*/
|
278 |
+
public function getOrderedItemDetail($orderItems) {
|
279 |
+
$items = array ();
|
280 |
+
foreach ( $orderItems as $item ) {
|
281 |
+
$product = array ();
|
282 |
+
if ($item ['parent_item_id'] == '') {
|
283 |
+
$product ['entity_id'] = $item->product_id;
|
284 |
+
$product ['price'] = number_format ( $item->getPrice (), 2, '.', '' );
|
285 |
+
$product ['name'] = $item->getName ();
|
286 |
+
$_product = Mage::getModel ( 'catalog/product' )->load ( $item->product_id );
|
287 |
+
$product ['image_url'] = ( string ) Mage::helper ( 'catalog/image' )->init ( $_product, 'thumbnail' );
|
288 |
+
$product ['qty'] = intval ( $item ['qty_ordered'] );
|
289 |
+
$product ['row_total'] = number_format ( $item ['base_row_total'], 2, '.', '' );
|
290 |
+
|
291 |
+
$product_options = $item ['product_options'];
|
292 |
+
$super_attribute = unserialize ( $product_options );
|
293 |
+
if (isset ( $super_attribute [static::ATTR_INFO] )) {
|
294 |
+
$product [static::ATTR_INFO] = $super_attribute ['attributes_info'];
|
295 |
+
} else {
|
296 |
+
$product [static::ATTR_INFO] = array ();
|
297 |
+
}
|
298 |
+
if (isset ( $super_attribute [static::OPTIONS] )) {
|
299 |
+
$product [static::OPTIONS] = $super_attribute ['options'];
|
300 |
+
} else {
|
301 |
+
$product [static::OPTIONS] = array ();
|
302 |
+
}
|
303 |
+
|
304 |
+
$items [] = $product;
|
305 |
+
}
|
306 |
+
}
|
307 |
+
return $items;
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* (non-PHPdoc)
|
312 |
+
*
|
313 |
+
* @see Mage_Api2_Model_Resource::_create($filteredData)
|
314 |
+
*/
|
315 |
+
public function _create(array $data) {
|
316 |
+
$response = array ();
|
317 |
+
$download_items = array ();
|
318 |
+
// get customer id from request
|
319 |
+
$customerId = ( int ) $data [static::CUSTOMERID];
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Check this customer has valid token or not
|
323 |
+
*
|
324 |
+
* @var $isValidToken Mage_Login_Model_Token
|
325 |
+
*/
|
326 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $data [static::TOKEN] );
|
327 |
+
|
328 |
+
try {
|
329 |
+
// check customer token
|
330 |
+
if (! $isValidToken) {
|
331 |
+
throw new Exception ( static::AUTH_ERR_MSG );
|
332 |
+
}
|
333 |
+
|
334 |
+
$purchased = Mage::getResourceModel ( 'downloadable/link_purchased_collection' )->addFieldToFilter ( static::CUSTOMERID, $customerId )->addOrder ( static::CREATED_AT, 'desc' );
|
335 |
+
|
336 |
+
$purchasedIds = array ();
|
337 |
+
// form array
|
338 |
+
foreach ( $purchased as $_item ) {
|
339 |
+
$purchasedIds [] = $_item->getId ();
|
340 |
+
}
|
341 |
+
if (empty ( $purchasedIds )) {
|
342 |
+
$purchasedIds = array (
|
343 |
+
null
|
344 |
+
);
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* $purchasedItems Mage_Downloadble_Model_Link_Purchase_Item_Collection
|
349 |
+
*/
|
350 |
+
$purchasedItems = Mage::getResourceModel ( 'downloadable/link_purchased_item_collection' )->addFieldToFilter ( static::PURCHASE_ID, array (
|
351 |
+
'in' => $purchasedIds
|
352 |
+
) )->addFieldToFilter ( static::STATUS, array (
|
353 |
+
'nin' => array (
|
354 |
+
Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING_PAYMENT,
|
355 |
+
Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PAYMENT_REVIEW
|
356 |
+
)
|
357 |
+
) )->setOrder ( static::ITEM_ID, 'desc' );
|
358 |
+
|
359 |
+
$success = 1;
|
360 |
+
$message = '';
|
361 |
+
$download_items = $this->getdownloadItemsLik ( $purchasedItems->getData () );
|
362 |
+
} catch ( Exception $e ) {
|
363 |
+
$success = 0;
|
364 |
+
$message = $e->getMessage ();
|
365 |
+
}
|
366 |
+
|
367 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
368 |
+
$response [static::ERROR] = false;
|
369 |
+
$response [static::SUCCESS] = $success;
|
370 |
+
$response [static::MESSAGE] = $message;
|
371 |
+
$response [static::RESULT] = $download_items;
|
372 |
+
|
373 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
374 |
+
return;
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Get Downloadable product collection
|
379 |
+
*
|
380 |
+
* @param array $items
|
381 |
+
* @return array:
|
382 |
+
*/
|
383 |
+
public function getdownloadItemsLik($items) {
|
384 |
+
$data = array ();
|
385 |
+
$j = 0;
|
386 |
+
foreach ( $items as $item ) {
|
387 |
+
$data [$j] [static::ITEM_ID] = $item [static::ITEM_ID];
|
388 |
+
$data [$j] [static::PURCHASE_ID] = $item [static::PURCHASE_ID];
|
389 |
+
$data [$j] [static::ORDER_ITEM_ID] = $item [static::ORDER_ITEM_ID];
|
390 |
+
// get product id
|
391 |
+
$data [$j] [static::PRODUCT_ID] = $item [static::PRODUCT_ID];
|
392 |
+
// get download link id
|
393 |
+
$data [$j] ['link_id'] = $item ['link_id'];
|
394 |
+
// get download title
|
395 |
+
$data [$j] ['link_title'] = $item ['link_title'];
|
396 |
+
// get media url
|
397 |
+
$mediaUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_MEDIA );
|
398 |
+
// get download url
|
399 |
+
$data [$j] ['link_file'] = $mediaUrl . "downloadable/files/links" . $item ['link_file'];
|
400 |
+
// get status
|
401 |
+
$data [$j] [static::STATUS] = $item [static::STATUS];
|
402 |
+
// number_of_downloads_bought 0 ->unlimited
|
403 |
+
$data [$j] ['number_of_downloads_bought'] = $item ['number_of_downloads_bought'];
|
404 |
+
$data [$j] ['number_of_downloads_used'] = $item ['number_of_downloads_used'];
|
405 |
+
$data [$j] [static::CREATED_AT] = $item [static::CREATED_AT];
|
406 |
+
|
407 |
+
/**
|
408 |
+
*
|
409 |
+
* @var $orderItem Mage_Sales_Model_Order_Item
|
410 |
+
*/
|
411 |
+
$orderItem = Mage::getModel ( 'sales/order_item' )->getCollection ()->addFieldToFilter ( 'item_id', $item [static::ORDER_ITEM_ID] )->getFirstItem ();
|
412 |
+
|
413 |
+
/**
|
414 |
+
*
|
415 |
+
* @var $order Mage_Sales_Model_Order
|
416 |
+
*/
|
417 |
+
$order = Mage::getModel ( static::SALES_ORDER )->getCollection ()->addFieldToFilter ( 'entity_id', $orderItem->getOrderId () )->getFirstItem ();
|
418 |
+
|
419 |
+
$data [$j] [static::ORDER_ID] = $order->getIncrementId ();
|
420 |
+
|
421 |
+
$productModel = Mage::getModel ( 'catalog/product' )->load ( $item [static::PRODUCT_ID] );
|
422 |
+
$data [$j] ['name'] = $productModel->getName ();
|
423 |
+
$j ++;
|
424 |
+
}
|
425 |
+
return $data;
|
426 |
+
}
|
427 |
+
}
|
app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MyOrders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest extends ContusRestapi_MyOrders_Model_Api2_MyOrderapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MyOrders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest_Admin_V1 extends ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MyOrders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest_Customer_V1 extends ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MyOrders/Model/Api2/MyOrderapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_MyOrders
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest_Guest_V1 extends ContusRestapi_MyOrders_Model_Api2_MyOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/MyOrders/etc/api2.xml
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="MyOrders">
|
6 |
+
<title>MyOrders Module Api</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<myOrders translate="title" module="MyOrders">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>myOrders/api2_myOrderapi</model>
|
14 |
+
<working_model>customer/address</working_model>
|
15 |
+
<title>MyOrders Api</title>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<privileges>
|
18 |
+
<admin>
|
19 |
+
<create>1</create>
|
20 |
+
<retrieve>1</retrieve>
|
21 |
+
<delete>1</delete>
|
22 |
+
<update>1</update>
|
23 |
+
</admin>
|
24 |
+
<customer>
|
25 |
+
<create>1</create>
|
26 |
+
<retrieve>1</retrieve>
|
27 |
+
<delete>1</delete>
|
28 |
+
<update>1</update>
|
29 |
+
</customer>
|
30 |
+
<guest>
|
31 |
+
<create>1</create>
|
32 |
+
<retrieve>1</retrieve>
|
33 |
+
<delete>1</delete>
|
34 |
+
<update>1</update>
|
35 |
+
</guest>
|
36 |
+
</privileges>
|
37 |
+
<attributes
|
38 |
+
translate="entity_id increment_id created_at status shipping_description _payment_method base_currency_code store_currency_code store_name remote_ip store_to_order_rate subtotal subtotal_incl_tax discount_amount base_grand_total grand_total shipping_amount shipping_tax_amount shipping_incl_tax tax_amount _tax_name _tax_rate coupon_code base_discount_amount base_subtotal base_shipping_amount base_shipping_tax_amount base_tax_amount total_paid base_total_paid total_refunded base_total_refunded base_subtotal_incl_tax base_total_due total_due shipping_discount_amount base_shipping_discount_amount discount_description customer_balance_amount base_customer_balance_amount base_customer_balance_amount _gift_message _order_comments customer_id"
|
39 |
+
module="api2">
|
40 |
+
<website_id>Website id</website_id>
|
41 |
+
<store_id>Store Id</store_id>
|
42 |
+
<customer_id>customer Id</customer_id>
|
43 |
+
<address_id>Addrss ID</address_id>
|
44 |
+
<result>Result</result>
|
45 |
+
<success>success</success>
|
46 |
+
<message>message</message>
|
47 |
+
<entity_id>Customer Address ID</entity_id>
|
48 |
+
<is_default_billing>Is Default Billing Address</is_default_billing>
|
49 |
+
<is_default_shipping>Is Default Shipping Address
|
50 |
+
</is_default_shipping>
|
51 |
+
<street>Street</street>
|
52 |
+
<city>City</city>
|
53 |
+
<firstname>first name</firstname>
|
54 |
+
<lastname>Last name</lastname>
|
55 |
+
<country_id>Country id</country_id>
|
56 |
+
<postcode>Postal Code</postcode>
|
57 |
+
<telephone>Telephone</telephone>
|
58 |
+
<company>Company</company>
|
59 |
+
<region>region</region>
|
60 |
+
<fax>Fax</fax>
|
61 |
+
<result>Result</result>
|
62 |
+
<token>Token</token>
|
63 |
+
</attributes>
|
64 |
+
|
65 |
+
<routes>
|
66 |
+
<!-- Orders detail -->
|
67 |
+
<order_detail>
|
68 |
+
<route>/myorder_detail/</route>
|
69 |
+
<action_type>entity</action_type>
|
70 |
+
</order_detail>
|
71 |
+
|
72 |
+
<!-- Orders collection -->
|
73 |
+
<order_collection>
|
74 |
+
<route>/myorders/</route>
|
75 |
+
<action_type>collection</action_type>
|
76 |
+
</order_collection>
|
77 |
+
|
78 |
+
<!-- Downloadable Products collection -->
|
79 |
+
<downloadable_collection>
|
80 |
+
<route>/my_download/products/</route>
|
81 |
+
<action_type>collection</action_type>
|
82 |
+
</downloadable_collection>
|
83 |
+
</routes>
|
84 |
+
|
85 |
+
<include_attributes>
|
86 |
+
<customer>
|
87 |
+
<read>
|
88 |
+
<entity_id>1</entity_id>
|
89 |
+
<increment_id>1</increment_id>
|
90 |
+
<created_at>1</created_at>
|
91 |
+
<status>1</status>
|
92 |
+
<shipping_description>1</shipping_description>
|
93 |
+
<_payment_method>1</_payment_method>
|
94 |
+
<base_currency_code>1</base_currency_code>
|
95 |
+
<store_currency_code>1</store_currency_code>
|
96 |
+
<subtotal>1</subtotal>
|
97 |
+
<subtotal_incl_tax>1</subtotal_incl_tax>
|
98 |
+
<discount_amount>1</discount_amount>
|
99 |
+
<base_grand_total>1</base_grand_total>
|
100 |
+
<grand_total>1</grand_total>
|
101 |
+
<shipping_amount>1</shipping_amount>
|
102 |
+
<shipping_tax_amount>1</shipping_tax_amount>
|
103 |
+
<shipping_incl_tax>1</shipping_incl_tax>
|
104 |
+
<tax_amount>1</tax_amount>
|
105 |
+
<_tax_name>1</_tax_name>
|
106 |
+
<_tax_rate>1</_tax_rate>
|
107 |
+
<_gift_message>1</_gift_message>
|
108 |
+
<_order_comments>1</_order_comments>
|
109 |
+
<order_date>Order Created date</order_date>
|
110 |
+
<item_count>Item Count</item_count>
|
111 |
+
<grand_total> Total Amount</grand_total>
|
112 |
+
<result> Result </result>
|
113 |
+
<items>Order Items</items>
|
114 |
+
</read>
|
115 |
+
</customer>
|
116 |
+
<guest>
|
117 |
+
<read>
|
118 |
+
<entity_id>1</entity_id>
|
119 |
+
<increment_id>1</increment_id>
|
120 |
+
<created_at>1</created_at>
|
121 |
+
<status>1</status>
|
122 |
+
<shipping_description>1</shipping_description>
|
123 |
+
<_payment_method>1</_payment_method>
|
124 |
+
<base_currency_code>1</base_currency_code>
|
125 |
+
<store_currency_code>1</store_currency_code>
|
126 |
+
<subtotal>1</subtotal>
|
127 |
+
<subtotal_incl_tax>1</subtotal_incl_tax>
|
128 |
+
<discount_amount>1</discount_amount>
|
129 |
+
<base_grand_total>1</base_grand_total>
|
130 |
+
<grand_total>1</grand_total>
|
131 |
+
<shipping_amount>1</shipping_amount>
|
132 |
+
<shipping_tax_amount>1</shipping_tax_amount>
|
133 |
+
<shipping_incl_tax>1</shipping_incl_tax>
|
134 |
+
<tax_amount>1</tax_amount>
|
135 |
+
<_tax_name>1</_tax_name>
|
136 |
+
<_tax_rate>1</_tax_rate>
|
137 |
+
<_gift_message>1</_gift_message>
|
138 |
+
<_order_comments>1</_order_comments>
|
139 |
+
</read>
|
140 |
+
</guest>
|
141 |
+
</include_attributes>
|
142 |
+
<force_attributes>
|
143 |
+
<customer>
|
144 |
+
<payment_method>1</payment_method>
|
145 |
+
<addresses>1</addresses>
|
146 |
+
<order_items>1</order_items>
|
147 |
+
<gift_message_from>1</gift_message_from>
|
148 |
+
<gift_message_to>1</gift_message_to>
|
149 |
+
<gift_message_body>1</gift_message_body>
|
150 |
+
<order_comments>1</order_comments>
|
151 |
+
<tax_name>1</tax_name>
|
152 |
+
<tax_rate>1</tax_rate>
|
153 |
+
</customer>
|
154 |
+
<admin>
|
155 |
+
<payment_method>1</payment_method>
|
156 |
+
<addresses>1</addresses>
|
157 |
+
<order_items>1</order_items>
|
158 |
+
<gift_message_from>1</gift_message_from>
|
159 |
+
<gift_message_to>1</gift_message_to>
|
160 |
+
<gift_message_body>1</gift_message_body>
|
161 |
+
<order_comments>1</order_comments>
|
162 |
+
<tax_name>1</tax_name>
|
163 |
+
<tax_rate>1</tax_rate>
|
164 |
+
</admin>
|
165 |
+
<guest>
|
166 |
+
<payment_method>1</payment_method>
|
167 |
+
<addresses>1</addresses>
|
168 |
+
<order_items>1</order_items>
|
169 |
+
<gift_message_from>1</gift_message_from>
|
170 |
+
<gift_message_to>1</gift_message_to>
|
171 |
+
<gift_message_body>1</gift_message_body>
|
172 |
+
<order_comments>1</order_comments>
|
173 |
+
<tax_name>1</tax_name>
|
174 |
+
<tax_rate>1</tax_rate>
|
175 |
+
</guest>
|
176 |
+
</force_attributes>
|
177 |
+
<versions>1</versions>
|
178 |
+
</myOrders>
|
179 |
+
|
180 |
+
|
181 |
+
|
182 |
+
</resources>
|
183 |
+
</api2>
|
184 |
+
</config>
|
app/code/local/ContusRestapi/MyOrders/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_MyOrders>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</ContusRestapi_MyOrders>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<myOrders>
|
11 |
+
<class>ContusRestapi_MyOrders_Model</class>
|
12 |
+
</myOrders>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi.php
ADDED
@@ -0,0 +1,322 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_PlaceOrderapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi extends Mage_Api2_Model_Resource {
|
30 |
+
const MESSAGE = 'message';
|
31 |
+
const SUCCESS = 'success';
|
32 |
+
const ORDER_ID = 'order_id';
|
33 |
+
const URL = 'url';
|
34 |
+
const SUCCESS_MSG = 'Order was placed successfully.';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Place order using Cash on delivery
|
38 |
+
*
|
39 |
+
* @return array json array
|
40 |
+
*/
|
41 |
+
protected function _create(array $data) {
|
42 |
+
$response = array ();
|
43 |
+
|
44 |
+
// get customer id
|
45 |
+
$customerId = ( int ) $data ['customer_id'];
|
46 |
+
// get quote id
|
47 |
+
$quoteId = ( int ) $data ['quote_id'];
|
48 |
+
|
49 |
+
// get website id
|
50 |
+
$websiteId = ( int ) $data ['website_id'];
|
51 |
+
if ($websiteId <= 0) {
|
52 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
53 |
+
}
|
54 |
+
// get website id from request
|
55 |
+
$storeId = ( int ) $data ['store_id'];
|
56 |
+
if ($storeId <= 0) {
|
57 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Check this customer has valid token or not
|
62 |
+
*
|
63 |
+
* @var $isValidToken Mage_Login_Model_Token
|
64 |
+
*/
|
65 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
66 |
+
|
67 |
+
try {
|
68 |
+
$paymentMethod = $data ['payment_method'];
|
69 |
+
$shippingMethod = $data ['shipping_method'];
|
70 |
+
$quoteObj = Mage::getModel ( 'sales/quote' );
|
71 |
+
$quoteObj->setStoreId ( $storeId )->load ( $quoteId );
|
72 |
+
// check customer token
|
73 |
+
if (! $isValidToken) {
|
74 |
+
throw new Exception ( 'Authentication failed.' );
|
75 |
+
}
|
76 |
+
// check quote id in valid
|
77 |
+
$active = $quoteObj->getIsActive ();
|
78 |
+
if (! $active) {
|
79 |
+
throw new Exception ( 'Quote is invalid!.' );
|
80 |
+
}
|
81 |
+
$quoteObj->getAllItems ();
|
82 |
+
$quoteObj->reserveOrderId ();
|
83 |
+
$orderObj = $this->SetQuoteObject ( $quoteObj, $shippingMethod, $paymentMethod );
|
84 |
+
|
85 |
+
if ($paymentMethod == 'paypal_standard') {
|
86 |
+
$result = $this->paypalStandard ( $quoteObj, $orderObj );
|
87 |
+
$response [static::MESSAGE] = $result [static::MESSAGE];
|
88 |
+
$response [static::ORDER_ID] = $result [static::ORDER_ID];
|
89 |
+
$response [static::SUCCESS] = $result [static::SUCCESS];
|
90 |
+
$response [static::URL] = $result [static::URL];
|
91 |
+
} else {
|
92 |
+
$orderObj->place ();
|
93 |
+
$orderObj->save ();
|
94 |
+
$orderObj->sendNewOrderEmail ();
|
95 |
+
$quoteObj->setIsActive ( 0 )->save ();
|
96 |
+
$response [static::MESSAGE] = static::SUCCESS_MSG;
|
97 |
+
$response [static::ORDER_ID] = $quoteObj->getreservedOrderId ();
|
98 |
+
$response [static::SUCCESS] = 1;
|
99 |
+
$response [static::URL] = '';
|
100 |
+
}
|
101 |
+
} catch ( Exception $e ) {
|
102 |
+
$response [static::SUCCESS] = 0;
|
103 |
+
$response [static::MESSAGE] = $e->getMessage ();
|
104 |
+
}
|
105 |
+
$response ['isValidToken'] = $isValidToken;
|
106 |
+
$response ['error'] = false;
|
107 |
+
|
108 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Place order using paypal standard payment
|
114 |
+
*
|
115 |
+
* @param object $quoteObj
|
116 |
+
* @param object $orderObj
|
117 |
+
* @return array
|
118 |
+
*/
|
119 |
+
public function paypalStandard($quoteObj, $orderObj) {
|
120 |
+
$response = array ();
|
121 |
+
$transaction = Mage::getModel ( 'core/resource_transaction' );
|
122 |
+
if ($quoteObj->getCustomerId ()) {
|
123 |
+
$transaction->addObject ( $quoteObj->getCustomer () );
|
124 |
+
}
|
125 |
+
|
126 |
+
$transaction->addObject ( $orderObj );
|
127 |
+
$transaction->addCommitCallback ( array (
|
128 |
+
$orderObj,
|
129 |
+
'place'
|
130 |
+
) );
|
131 |
+
$transaction->addCommitCallback ( array (
|
132 |
+
$orderObj,
|
133 |
+
'save'
|
134 |
+
) );
|
135 |
+
try {
|
136 |
+
$transaction->save ();
|
137 |
+
} catch ( Exception $e ) {
|
138 |
+
// Set error message if the place order get failed transaction.
|
139 |
+
$response [static::SUCCESS] = 0;
|
140 |
+
$response [static::MESSAGE] = $e->getMessage ();
|
141 |
+
}
|
142 |
+
|
143 |
+
Mage::dispatchEvent ( 'checkout_type_onepage_save_order_after', array (
|
144 |
+
'order' => $orderObj,
|
145 |
+
'quote' => $quoteObj
|
146 |
+
) );
|
147 |
+
$quoteObj->setIsActive ( 0 )->save ();
|
148 |
+
|
149 |
+
$response [static::MESSAGE] = static::SUCCESS_MSG;
|
150 |
+
$response [static::ORDER_ID] = $quoteObj->getreservedOrderId ();
|
151 |
+
$response [static::SUCCESS] = 1;
|
152 |
+
$resourcePath = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_WEB ) . 'paypal/';
|
153 |
+
$redirectUrl = $resourcePath . 'redirect.php?id=' . $response [static::ORDER_ID];
|
154 |
+
$response [static::URL] = $redirectUrl;
|
155 |
+
|
156 |
+
return $response;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Place order using paypal stanadard
|
161 |
+
*
|
162 |
+
* @return array json array
|
163 |
+
*/
|
164 |
+
protected function _retrieveCollection() {
|
165 |
+
$response = array ();
|
166 |
+
$redirectUrl = '';
|
167 |
+
// get website id from request
|
168 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( 'website_id' );
|
169 |
+
if ($websiteId <= 0) {
|
170 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
171 |
+
}
|
172 |
+
// get website id from request
|
173 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( 'store_id' );
|
174 |
+
if ($storeId <= 0) {
|
175 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
176 |
+
}
|
177 |
+
// get quote id
|
178 |
+
$quoteId = ( int ) $this->getRequest ()->getParam ( 'quote_id' );
|
179 |
+
// get customer id
|
180 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( 'customer_id' );
|
181 |
+
|
182 |
+
/**
|
183 |
+
* Check this customer has valid token or not
|
184 |
+
*
|
185 |
+
* @var $isValidToken Mage_Login_Model_Token
|
186 |
+
*/
|
187 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $this->getRequest ()->getParam ( 'token' ) );
|
188 |
+
try {
|
189 |
+
$paymentMethod = $this->getRequest ()->getParam ( 'payment_method' );
|
190 |
+
$shippingMethod = $this->getRequest ()->getParam ( 'shipping_method' );
|
191 |
+
|
192 |
+
if (! $isValidToken) {
|
193 |
+
throw new Exception ( 'Authentication failed.' );
|
194 |
+
}
|
195 |
+
|
196 |
+
$quoteObj = Mage::getModel ( 'sales/quote' );
|
197 |
+
$quoteObj->setStoreId ( $storeId )->load ( $quoteId );
|
198 |
+
$active = $quoteObj->getIsActive ();
|
199 |
+
if (! $active) {
|
200 |
+
throw new Exception ( 'Quote is invalid!.' );
|
201 |
+
}
|
202 |
+
|
203 |
+
$quoteObj->reserveOrderId ();
|
204 |
+
$transactionModel = Mage::getModel ( 'core/resource_transaction' );
|
205 |
+
if ($quoteObj->getCustomerId ()) {
|
206 |
+
$transactionModel->addObject ( $quoteObj->getCustomer () );
|
207 |
+
}
|
208 |
+
$transactionModel->addObject ( $quoteObj );
|
209 |
+
$quoteObj->getAllItems ();
|
210 |
+
$orderObj = $this->SetQuoteObject ( $quoteObj, $shippingMethod, $paymentMethod );
|
211 |
+
|
212 |
+
$transactionModel->addObject ( $orderObj );
|
213 |
+
$transactionModel->addCommitCallback ( array (
|
214 |
+
$orderObj,
|
215 |
+
'place'
|
216 |
+
) );
|
217 |
+
$transactionModel->addCommitCallback ( array (
|
218 |
+
$orderObj,
|
219 |
+
'save'
|
220 |
+
) );
|
221 |
+
try {
|
222 |
+
$transactionModel->save ();
|
223 |
+
} catch ( Exception $e ) {
|
224 |
+
// Set error message if the place order get failed transaction.
|
225 |
+
$response [static::SUCCESS] = 0;
|
226 |
+
$response [static::MESSAGE] = $e->getMessage ();
|
227 |
+
}
|
228 |
+
|
229 |
+
Mage::dispatchEvent ( 'checkout_type_onepage_save_order_after', array (
|
230 |
+
'order' => $orderObj,
|
231 |
+
'quote' => $quoteObj
|
232 |
+
) );
|
233 |
+
$quoteObj->setIsActive ( 0 )->save ();
|
234 |
+
|
235 |
+
$response [static::MESSAGE] = static::SUCCESS_MSG;
|
236 |
+
$response [static::ORDER_ID] = $quoteObj->getreservedOrderId ();
|
237 |
+
$response [static::SUCCESS] = 1;
|
238 |
+
$resourcePath = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_WEB ) . 'paypal/';
|
239 |
+
$redirectUrl = $resourcePath . 'redirect.php?id=' . $response [static::ORDER_ID];
|
240 |
+
} catch ( Exception $e ) {
|
241 |
+
$response [static::SUCCESS] = 0;
|
242 |
+
$response [static::MESSAGE] = $e->getMessage ();
|
243 |
+
}
|
244 |
+
$response [static::URL] = $redirectUrl;
|
245 |
+
$response ['isValidToken'] = $isValidToken;
|
246 |
+
$response ['error'] = false;
|
247 |
+
return $response;
|
248 |
+
}
|
249 |
+
public function SetQuoteObject($quoteObj, $shippingMethod, $paymentMethod) {
|
250 |
+
// set shipping method
|
251 |
+
$quoteObj->getShippingAddress ()->setShippingMethod ( $shippingMethod );
|
252 |
+
$quoteObj->getShippingAddress ()->setCollectShippingRates ( TRUE );
|
253 |
+
$quoteObj->getShippingAddress ()->collectShippingRates ();
|
254 |
+
|
255 |
+
$items = $quoteObj->getAllItems ();
|
256 |
+
// set payment method
|
257 |
+
$quotePaymentObj = $quoteObj->getPayment ();
|
258 |
+
// Mage_Sales_Model_Quote_Payment
|
259 |
+
$quotePaymentObj->setMethod ( $paymentMethod );
|
260 |
+
$quoteObj->setPayment ( $quotePaymentObj );
|
261 |
+
$quoteObj->collectTotals ();
|
262 |
+
$quoteObj->save ();
|
263 |
+
|
264 |
+
// convert quote to order
|
265 |
+
$convertQuoteObj = Mage::getSingleton ( 'sales/convert_quote' );
|
266 |
+
$orderObj = $convertQuoteObj->addressToOrder ( $quoteObj->getShippingAddress () );
|
267 |
+
$convertQuoteObj->paymentToOrderPayment ( $quotePaymentObj );
|
268 |
+
|
269 |
+
// convert quote addresses
|
270 |
+
$orderObj->setBillingAddress ( $convertQuoteObj->addressToOrderAddress ( $quoteObj->getBillingAddress () ) );
|
271 |
+
$orderObj->setShippingAddress ( $convertQuoteObj->addressToOrderAddress ( $quoteObj->getShippingAddress () ) );
|
272 |
+
|
273 |
+
// set payment options
|
274 |
+
$orderObj->setPayment ( $convertQuoteObj->paymentToOrderPayment ( $quoteObj->getPayment () ) );
|
275 |
+
|
276 |
+
// convert quote items
|
277 |
+
$orderObj = $this->addQuoteProduct ( $items, $convertQuoteObj, $orderObj );
|
278 |
+
|
279 |
+
$orderObj->setCanShipPartiallyItem ( TRUE );
|
280 |
+
|
281 |
+
return $orderObj;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
*
|
286 |
+
* @param array $items
|
287 |
+
* @param object $convertQuoteObj
|
288 |
+
* @param object $orderObj
|
289 |
+
* @return object $orderObj
|
290 |
+
*/
|
291 |
+
public function addQuoteProduct($items, $convertQuoteObj, $orderObj) {
|
292 |
+
// convert quote items
|
293 |
+
foreach ( $items as $item ) {
|
294 |
+
$itemDesc = $item->getItemDescription ();
|
295 |
+
$orderItem = $convertQuoteObj->itemToOrderItem ( $item );
|
296 |
+
$options = array ();
|
297 |
+
|
298 |
+
if ($productOptions = $item->getProduct ()->getTypeInstance ( TRUE )->getOrderOptions ( $item->getProduct () )) {
|
299 |
+
$options = $productOptions;
|
300 |
+
}
|
301 |
+
|
302 |
+
if ($addOptions = $item->getOptionByCode ( 'additional_options' )) {
|
303 |
+
$options ['additional_options'] = unserialize ( $addOptions->getValue () );
|
304 |
+
}
|
305 |
+
|
306 |
+
if ($options) {
|
307 |
+
$orderItem->setProductOptions ( $options );
|
308 |
+
}
|
309 |
+
|
310 |
+
if ($itemDesc) {
|
311 |
+
$orderItem->setName ( $itemDesc );
|
312 |
+
}
|
313 |
+
|
314 |
+
if ($item->getParentItem ()) {
|
315 |
+
$orderItem->setParentItem ( $orderObj->getItemByQuoteItemId ( $item->getParentItem ()->getId () ) );
|
316 |
+
}
|
317 |
+
$orderObj->addItem ( $orderItem );
|
318 |
+
Mage::getSingleton('cataloginventory/stock')->registerItemSale($orderItem);
|
319 |
+
}
|
320 |
+
return $orderObj;
|
321 |
+
}
|
322 |
+
}
|
app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_PlaceOrder
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest extends ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_PlaceOrder
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest_Admin_V1 extends ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_PlaceOrder
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest_Customer_V1 extends ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/PlaceOrder/Model/Api2/PlaceOrderapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_PlaceOrder
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest_Guest_V1 extends ContusRestapi_PlaceOrder_Model_Api2_PlaceOrderapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/PlaceOrder/etc/api2.xml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="PlaceOrder">
|
6 |
+
<title>Place Order API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<placeOrder translate="title" module="PlaceOrder">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>placeOrder/api2_placeOrderapi</model>
|
14 |
+
<title>Cart Address</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
</customer>
|
26 |
+
<guest>
|
27 |
+
<create>1</create>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes module="api2">
|
32 |
+
<website_id>websiteid</website_id>
|
33 |
+
<store_id>Associate to Store</store_id>
|
34 |
+
<quote_id>Shopping cart Id</quote_id>
|
35 |
+
<customer_id>Customer Id</customer_id>
|
36 |
+
<payment_method>Payment Method</payment_method>
|
37 |
+
<shipping_method>Shipping Method</shipping_method>
|
38 |
+
<token> Token </token>
|
39 |
+
<success>success</success>
|
40 |
+
<message>message</message>
|
41 |
+
<order_id>Order Id</order_id>
|
42 |
+
<payment_url>Payment Url</payment_url>
|
43 |
+
</attributes>
|
44 |
+
<routes>
|
45 |
+
<!-- Place order using Knet -->
|
46 |
+
<route_collection>
|
47 |
+
<route>/paypal_standard/place_order/</route>
|
48 |
+
<action_type>collection</action_type>
|
49 |
+
</route_collection>
|
50 |
+
<!-- Place order using Cash on delivery -->
|
51 |
+
<place_order>
|
52 |
+
<route>/place_order/</route>
|
53 |
+
<action_type>collection</action_type>
|
54 |
+
</place_order>
|
55 |
+
|
56 |
+
</routes>
|
57 |
+
<versions>1</versions>
|
58 |
+
</placeOrder>
|
59 |
+
|
60 |
+
</resources>
|
61 |
+
</api2>
|
62 |
+
</config>
|
app/code/local/ContusRestapi/PlaceOrder/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_PlaceOrder>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_PlaceOrder>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<placeOrder>
|
11 |
+
<class>ContusRestapi_PlaceOrder_Model</class>
|
12 |
+
</placeOrder>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest.php
ADDED
@@ -0,0 +1,770 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Overwrite Catalog Core Rest API Methods
|
5 |
+
*
|
6 |
+
* Contus
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* NOTICE OF LICENSE
|
10 |
+
*
|
11 |
+
* This source file is subject to the EULA
|
12 |
+
* that is bundled with this package in the file LICENSE.txt.
|
13 |
+
* It is also available through the world-wide-web at this URL:
|
14 |
+
* http://www.apptha.com/LICENSE.txt
|
15 |
+
*
|
16 |
+
* ==============================================================
|
17 |
+
* MAGENTO EDITION USAGE NOTICE
|
18 |
+
* ==============================================================
|
19 |
+
* This package designed for Magento COMMUNITY edition
|
20 |
+
* Apptha does not guarantee correct work of this extension
|
21 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
22 |
+
* Apptha does not provide extension support in case of
|
23 |
+
* incorrect edition usage.
|
24 |
+
* ==============================================================
|
25 |
+
*
|
26 |
+
* @category Contus
|
27 |
+
* @package ContusRestapi_ProductList
|
28 |
+
* @author Contus Team <developers@contus.in>
|
29 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
30 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
31 |
+
* @since 1.0
|
32 |
+
*/
|
33 |
+
class ContusRestapi_ProductList_Model_Api2_ProductList_Rest extends Mage_Catalog_Model_Api2_Product_Rest {
|
34 |
+
|
35 |
+
// Declaring the string literals variable
|
36 |
+
const ENTITYID = 'entity_id';
|
37 |
+
const NAME = 'name';
|
38 |
+
const IMGURL = 'image_url';
|
39 |
+
const REGULARPRICE = 'regular_price';
|
40 |
+
const FINALPRICE = 'final_price';
|
41 |
+
const PRODUCTTYPE = 'product_type';
|
42 |
+
const PROCOLLECTION = 'collection';
|
43 |
+
const VISIBILITY = 'visibility';
|
44 |
+
const STATUS = 'status';
|
45 |
+
const CATIMG = 'catalog/image';
|
46 |
+
const SMALLIMG = 'small_image';
|
47 |
+
const PRICE = 'price';
|
48 |
+
const TIERPRICE = 'tier_price';
|
49 |
+
const ISWISHLIST = 'is_wishlist';
|
50 |
+
const RATING = 'rating';
|
51 |
+
const OPTIONS = 'options';
|
52 |
+
const CATSTOCK = 'cataloginventory/stock_item';
|
53 |
+
const ISSTOCK = 'is_stock';
|
54 |
+
const OPTIONID = 'option_id';
|
55 |
+
const TITLE = 'title';
|
56 |
+
const WEBSITE_ID = 'website_id';
|
57 |
+
const STORE_ID = 'store_id';
|
58 |
+
const LOGIN_TOKEN = 'login/token';
|
59 |
+
const IS_IN_STOCK = 'is_in_stock';
|
60 |
+
const E_ENTITY_ID = 'e.entity_id';
|
61 |
+
const AVAILABILITY = 'availability';
|
62 |
+
const IS_SALEABLE = 'is_saleable';
|
63 |
+
const MEDIA = 'media';
|
64 |
+
const MOBILEAPP = 'mobileapp';
|
65 |
+
const RESIZED = 'resized';
|
66 |
+
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Retrieve product data
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
protected function _retrieve() {
|
74 |
+
$response = array ();
|
75 |
+
|
76 |
+
// get website id from request
|
77 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITE_ID );
|
78 |
+
if ($websiteId <= 0) {
|
79 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
80 |
+
}
|
81 |
+
|
82 |
+
// get store id from request
|
83 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STORE_ID );
|
84 |
+
if ($storeId <= 0) {
|
85 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
86 |
+
}
|
87 |
+
|
88 |
+
$productDetail = array ();
|
89 |
+
// get default product details
|
90 |
+
$product = $this->_getProduct ();
|
91 |
+
// load producs based on store id
|
92 |
+
$product->setStoreId ( $storeId )->load ( $product->getId () );
|
93 |
+
$productDetail = $this->_prepareProductForResponse ( $product );
|
94 |
+
|
95 |
+
// get product description
|
96 |
+
$productDetail ['description'] = $product->getDescription ();
|
97 |
+
// get product short description
|
98 |
+
$productDetail ['short_description'] = $product->getShortDescription ();
|
99 |
+
|
100 |
+
// get additional images for product
|
101 |
+
$productDetail ['images'] = $this->getProductImages ( $product );
|
102 |
+
|
103 |
+
// Getting ratings/reviews
|
104 |
+
// get only five revieews in product detail page
|
105 |
+
$reviews = Mage::getModel ( static::LOGIN_TOKEN )->getReviews ( $product->getId (), $storeId, 1, 5 );
|
106 |
+
$productDetail ['reviews'] = $reviews ['reviews'];
|
107 |
+
// get product rating count summary
|
108 |
+
$ratings = Mage::getModel ( static::LOGIN_TOKEN )->getRatingResult ( $product->getId (), $storeId );
|
109 |
+
$productDetail [static::RATING] = $ratings [static::RATING];
|
110 |
+
|
111 |
+
$type = $product->getTypeId ();
|
112 |
+
$options = array ();
|
113 |
+
$super_group = array ();
|
114 |
+
$links = array ();
|
115 |
+
switch ($type) {
|
116 |
+
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED :
|
117 |
+
$super_group = $this->getGroupedProductOptions ( $product );
|
118 |
+
break;
|
119 |
+
|
120 |
+
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE :
|
121 |
+
$options = $this->getConfigurableProductOptions ( $product, $storeId );
|
122 |
+
break;
|
123 |
+
|
124 |
+
case Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE :
|
125 |
+
$links = $this->getDownloadableLinks ( $product );
|
126 |
+
break;
|
127 |
+
|
128 |
+
default :
|
129 |
+
break;
|
130 |
+
}
|
131 |
+
// get configurable product options
|
132 |
+
if (! empty ( $options )) {
|
133 |
+
$productDetail [static::OPTIONS] = $options;
|
134 |
+
}
|
135 |
+
// get grouped product options
|
136 |
+
if (! empty ( $super_group )) {
|
137 |
+
$productDetail ['group_options'] = $super_group;
|
138 |
+
}
|
139 |
+
|
140 |
+
// get downloadble product links
|
141 |
+
if (! empty ( $links )) {
|
142 |
+
$productDetail ['links'] = $links;
|
143 |
+
}
|
144 |
+
|
145 |
+
// get custom options
|
146 |
+
$customOptions = $this->getCustomOptions ( $product );
|
147 |
+
$productDetail ['custom_options'] = $customOptions;
|
148 |
+
$response ['error'] = false;
|
149 |
+
$response ['success'] = 1;
|
150 |
+
$response ['result'] = $productDetail;
|
151 |
+
return $response;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Get product Images
|
156 |
+
*
|
157 |
+
* @param object $product
|
158 |
+
* @return array $product_images
|
159 |
+
*/
|
160 |
+
public function getProductImages($product) {
|
161 |
+
$_images = $product->getMediaGalleryImages ();
|
162 |
+
$product_images = array ();
|
163 |
+
// get image size for resize
|
164 |
+
$imageSize = ( int ) $this->getRequest ()->getParam ( 'image_size' );
|
165 |
+
|
166 |
+
if (isset ( $_images )) {
|
167 |
+
$i = 0;
|
168 |
+
foreach ( $_images as $_image ) {
|
169 |
+
if ($imageSize <= 0) {
|
170 |
+
$product_images [$i] = $_image->url;
|
171 |
+
} else {
|
172 |
+
$product_images [$i] = $this->imageResize ( $_image->url, $imageSize );
|
173 |
+
}
|
174 |
+
|
175 |
+
$i ++;
|
176 |
+
}
|
177 |
+
}
|
178 |
+
return $product_images;
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* Image resize and store
|
182 |
+
*
|
183 |
+
* @param string $imageUrl
|
184 |
+
* @param int $imageSize
|
185 |
+
* @return string image url
|
186 |
+
*/
|
187 |
+
public function imageResize($imageUrl, $imageSize) {
|
188 |
+
if (! file_exists ( Mage::getBaseDir ( static::MEDIA ) . DS . static::MOBILEAPP . DS . static::RESIZED )){
|
189 |
+
mkdir ( Mage::getBaseDir ( static::MEDIA ) . DS . static::MOBILEAPP . DS . static::RESIZED , 0777 );
|
190 |
+
}
|
191 |
+
|
192 |
+
$imageName = substr ( strrchr ( $imageUrl, "/" ), 1 );
|
193 |
+
$imageResized = Mage::getBaseDir ( static::MEDIA ) . DS . static::MOBILEAPP . DS . static::RESIZED . DS . $imageName;
|
194 |
+
$dirImg = Mage::getBaseDir () . str_replace ( "/", DS, strstr ( $imageUrl, '/'.static::MEDIA ) );
|
195 |
+
if (! file_exists ( $imageResized ) && file_exists ( $dirImg )) :
|
196 |
+
$imageObj = new Varien_Image ( $dirImg );
|
197 |
+
$imageObj->constrainOnly ( true );
|
198 |
+
$imageObj->keepAspectRatio ( true );
|
199 |
+
$imageObj->keepFrame ( false );
|
200 |
+
$imageObj->resize ( $imageSize, null );
|
201 |
+
$imageObj->save ( $imageResized );
|
202 |
+
|
203 |
+
endif;
|
204 |
+
return Mage::getBaseUrl ( static::MEDIA ) . static::MOBILEAPP."/". static::RESIZED ."/" . $imageName;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Grouped Product Options - Get Associated products
|
209 |
+
*
|
210 |
+
* @param object $product
|
211 |
+
* @return array $options
|
212 |
+
*/
|
213 |
+
public function getGroupedProductOptions($product) {
|
214 |
+
$options = array ();
|
215 |
+
$associatedProducts = $product->getTypeInstance ( true )->getAssociatedProducts ( $product );
|
216 |
+
|
217 |
+
if (count ( $associatedProducts )) {
|
218 |
+
foreach ( $associatedProducts as $product ) {
|
219 |
+
|
220 |
+
// get stock data
|
221 |
+
$stockItem = Mage::getModel ( static::CATSTOCK )->loadByProduct ( $product->getId () );
|
222 |
+
$options [] = array (
|
223 |
+
static::OPTIONID => $product->getId (),
|
224 |
+
'option_value' => $product->getName (),
|
225 |
+
'option_title' => $product->getName (),
|
226 |
+
'option_regular_price' => number_format ( $product->getPrice (), 2, '.', '' ),
|
227 |
+
'option_final_price' => number_format ( $product->getFinalPrice (), 2, '.', '' ),
|
228 |
+
'option_image' => $product->getThumbnailUrl ( 105, 80 ),
|
229 |
+
static::ISSTOCK => ($stockItem->getIsInStock () > 0)
|
230 |
+
);
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
return $options;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Get Custom options of Simple Product
|
239 |
+
*
|
240 |
+
* @param object $product
|
241 |
+
* @return array $options
|
242 |
+
*/
|
243 |
+
public function getCustomOptions($product) {
|
244 |
+
$options = array ();
|
245 |
+
$optionsData = $product->getOptions ();
|
246 |
+
foreach ( $optionsData as $option ) {
|
247 |
+
$optionVal = array ();
|
248 |
+
$optionValues = $option->getValues ();
|
249 |
+
foreach ( $optionValues as $optVal ) {
|
250 |
+
$optionVal [] = array (
|
251 |
+
static::OPTIONID => $optVal->getOptionId (),
|
252 |
+
'option_type_id' => $optVal->getOptionTypeId (),
|
253 |
+
'sku' => $optVal->getSku (),
|
254 |
+
'sort_order' => $optVal->getSortOrder (),
|
255 |
+
static::TITLE => $optVal->getTitle (),
|
256 |
+
static::PRICE => $optVal->getPrice (),
|
257 |
+
'price_type' => $optVal->getPriceType ()
|
258 |
+
);
|
259 |
+
}
|
260 |
+
|
261 |
+
$options [] = array (
|
262 |
+
'type' => $option->getType (),
|
263 |
+
static::OPTIONID => $option->getOptionId (),
|
264 |
+
'product_id' => $option->getProductId (),
|
265 |
+
'type' => $option->getType (),
|
266 |
+
'is_require' => $option->getIsRequire (),
|
267 |
+
'sort_order' => $option->getSortOrder (),
|
268 |
+
static::TITLE => $option->getTitle (),
|
269 |
+
static::PRICE => $option->getPrice (),
|
270 |
+
'price_type' => $option->getPriceType (),
|
271 |
+
'option_value' => $optionVal
|
272 |
+
);
|
273 |
+
}
|
274 |
+
|
275 |
+
return $options;
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Get config options for configurable product
|
280 |
+
*
|
281 |
+
* @param object $product
|
282 |
+
* @param int $storeId
|
283 |
+
* @return array $result
|
284 |
+
*/
|
285 |
+
public function getConfigurableProductOptions($product, $storeId) {
|
286 |
+
// get product price
|
287 |
+
$finalPrice = $product->getFinalPrice ();
|
288 |
+
|
289 |
+
// Load all used configurable attributes
|
290 |
+
$configurableAttributeCollection = $product->getTypeInstance ( true )->getConfigurableAttributes ( $product );
|
291 |
+
|
292 |
+
$allProducts = $product->getTypeInstance ( true )->getUsedProducts ( null, $product );
|
293 |
+
foreach ( $allProducts as $product ) {
|
294 |
+
$products [] = $product;
|
295 |
+
}
|
296 |
+
|
297 |
+
$options = array ();
|
298 |
+
$result = array ();
|
299 |
+
$i = 0;
|
300 |
+
foreach ( $configurableAttributeCollection as $productAttribute ) {
|
301 |
+
$options [$i] [static::TITLE] = $productAttribute ['label'];
|
302 |
+
$options [$i] ['code'] = $productAttribute->getProductAttribute ()->getAttributeCode ();
|
303 |
+
$options [$i] ['attribute_id'] = $productAttribute ['attribute_id'];
|
304 |
+
$i ++;
|
305 |
+
}
|
306 |
+
$result ['config'] = $options;
|
307 |
+
$resultattr = array ();
|
308 |
+
// Get combinations
|
309 |
+
foreach ( $products as $product ) {
|
310 |
+
$attr = array ();
|
311 |
+
// get produt stock qty for simple product
|
312 |
+
/**
|
313 |
+
*
|
314 |
+
* @var $stockItem Mage_CatalogInventory_Model_Stock_Item
|
315 |
+
*/
|
316 |
+
$stockItem = $product->getStockItem ();
|
317 |
+
if (! $stockItem) {
|
318 |
+
$stockItem = Mage::getModel ( static::CATSTOCK );
|
319 |
+
$stockItem->loadByProduct ( $product );
|
320 |
+
}
|
321 |
+
$stockQty = floor ( $stockItem->getQty () );
|
322 |
+
$is_stock = $stockItem->getIsInStock ();
|
323 |
+
$j = 0;
|
324 |
+
foreach ( $configurableAttributeCollection as $attribute ) {
|
325 |
+
|
326 |
+
$productAttribute = $attribute->getProductAttribute ();
|
327 |
+
$attrCode = $productAttribute->getAttributeCode ();
|
328 |
+
$attributeValue = $product->getData ( $attrCode );
|
329 |
+
|
330 |
+
/* getting option text value */
|
331 |
+
if ($productAttribute->usesSource ()) {
|
332 |
+
$label = $productAttribute->setStoreId ( $storeId )->getSource ()->getOptionText ( $attributeValue );
|
333 |
+
} else {
|
334 |
+
$label = '';
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get price for associated product
|
339 |
+
*/
|
340 |
+
$prices = $attribute->getPrices ();
|
341 |
+
$value = $product->getData ( $attribute->getProductAttribute ()->getAttributeCode () );
|
342 |
+
|
343 |
+
$valuearry ['label'] = $label;
|
344 |
+
$valuearry ['code'] = $attrCode;
|
345 |
+
$valuearry ['config_id'] = $attributeValue;
|
346 |
+
$valuearry [static::ISSTOCK] = $is_stock;
|
347 |
+
$valuearry ['stock_qty'] = $stockQty;
|
348 |
+
$valuearry [static::PRICE] = $this->calculateCustumPrice ( $prices, $value, $finalPrice );
|
349 |
+
|
350 |
+
$val [$options [$j] ['code']] = $attributeValue;
|
351 |
+
$j ++;
|
352 |
+
array_push ( $attr, $valuearry );
|
353 |
+
}
|
354 |
+
// get configurable product options
|
355 |
+
$attr = $this->getAttrColl ( $val, $attr );
|
356 |
+
|
357 |
+
$resultattr = array_merge ( $resultattr, $attr );
|
358 |
+
}
|
359 |
+
$result ['attr'] = $resultattr;
|
360 |
+
return $result;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Get price for config options
|
365 |
+
*
|
366 |
+
* @param array $prices
|
367 |
+
* @param string $value
|
368 |
+
* @param float $finalPrice
|
369 |
+
* @return string $totalPrice
|
370 |
+
*/
|
371 |
+
public function calculateCustumPrice($prices, $value, $finalPrice) {
|
372 |
+
$totalPrice = 0;
|
373 |
+
foreach ( $prices as $price ) {
|
374 |
+
if ($price ['is_percent']) {
|
375 |
+
// if the price is specified in percents
|
376 |
+
$pricesByAttributeValues [$price ['value_index']] = ( float ) $price ['pricing_value'] * $finalPrice / 100;
|
377 |
+
} else {
|
378 |
+
// if the price is absolute value
|
379 |
+
$pricesByAttributeValues [$price ['value_index']] = ( float ) $price ['pricing_value'];
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
if (isset ( $pricesByAttributeValues [$value] )) {
|
384 |
+
$totalPrice = $pricesByAttributeValues [$value];
|
385 |
+
}
|
386 |
+
return strval ( $totalPrice );
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Collect configurable product options
|
391 |
+
*
|
392 |
+
* @param array $val
|
393 |
+
* @param array $attr
|
394 |
+
* @return array $attr
|
395 |
+
*/
|
396 |
+
public function getAttrColl($val, $attr) {
|
397 |
+
$attr [0] ['attr_id'] = array ();
|
398 |
+
foreach ( $val as $key => $value ) {
|
399 |
+
|
400 |
+
for($k = 0; $k < count ( $attr ); $k ++) {
|
401 |
+
$attrValue = array ();
|
402 |
+
if ($attr [$k] ['code'] != $key) {
|
403 |
+
$attrValue ['value'] = $value;
|
404 |
+
$attrValue ['code'] = $key;
|
405 |
+
|
406 |
+
$attr [$k] ['attr_id'] [] = $attrValue;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
}
|
410 |
+
return $attr;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Get Downloadable product
|
415 |
+
*
|
416 |
+
* @param object $product
|
417 |
+
* @return array $links
|
418 |
+
*/
|
419 |
+
public function getDownloadableLinks($product) {
|
420 |
+
$productAttributeLinks = $product->getTypeInstance ( true )->getLinks ( $product );
|
421 |
+
$i = 0;
|
422 |
+
foreach ( $productAttributeLinks as $productLinks ) {
|
423 |
+
$links [$i] ['link_id'] = $productLinks->getLinkId ();
|
424 |
+
$links [$i] [static::ENTITYID] = $productLinks->getProductId ();
|
425 |
+
$links [$i] ['is_require'] = $product->getLinksPurchasedSeparately ();
|
426 |
+
$links [$i] [static::PRICE] = $productLinks->getPrice ();
|
427 |
+
$links [$i] [static::TITLE] = $productLinks->getTitle ();
|
428 |
+
$i ++;
|
429 |
+
}
|
430 |
+
return $links;
|
431 |
+
}
|
432 |
+
|
433 |
+
/**
|
434 |
+
* Retrieve list of products
|
435 |
+
*
|
436 |
+
* @return array
|
437 |
+
*/
|
438 |
+
protected function _retrieveCollection() {
|
439 |
+
$response = array ();
|
440 |
+
$productArray = array ();
|
441 |
+
// get website id from request
|
442 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITE_ID );
|
443 |
+
if ($websiteId <= 0) {
|
444 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
445 |
+
}
|
446 |
+
// get store id from request
|
447 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STORE_ID );
|
448 |
+
if ($storeId <= 0) {
|
449 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
450 |
+
}
|
451 |
+
// get page from request
|
452 |
+
$page = $this->getRequest ()->getParam ( 'page' );
|
453 |
+
// get page from request
|
454 |
+
$limit = $this->getRequest ()->getParam ( 'limit' );
|
455 |
+
// get these type of products only
|
456 |
+
$productType = array (
|
457 |
+
"simple",
|
458 |
+
"configurable"
|
459 |
+
);
|
460 |
+
|
461 |
+
/**
|
462 |
+
*
|
463 |
+
* @var $collection Mage_Catalog_Model_Resource_Product_Collection
|
464 |
+
*/
|
465 |
+
$collection = Mage::getResourceModel ( 'catalog/product_collection' );
|
466 |
+
$collection->addStoreFilter ( $storeId )->addPriceData ( $this->_getCustomerGroupId (), $websiteId )->addAttributeToSelect ( static::NAME, static::PRICE )->addAttributeToFilter ( 'visibility', array (
|
467 |
+
'neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
468 |
+
) )->addAttributeToFilter ( 'status', array (
|
469 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
470 |
+
) )->addAttributeToFilter ( 'type_id', array (
|
471 |
+
'in' => $productType
|
472 |
+
) );
|
473 |
+
$this->_applyCategoryFilter ( $collection );
|
474 |
+
$this->_applyCollectionModifiers ( $collection );
|
475 |
+
|
476 |
+
|
477 |
+
// sort and filetr product collection
|
478 |
+
$collection = $this->_getProductByFilter ( $collection, $storeId );
|
479 |
+
// get total products count
|
480 |
+
$totalProducts = $collection->getSize ();
|
481 |
+
$products = $collection->load ();
|
482 |
+
|
483 |
+
// get total pages with limit
|
484 |
+
$last_page = ceil ( $totalProducts / $limit );
|
485 |
+
if ($last_page < $page) {
|
486 |
+
$productArray = array ();
|
487 |
+
} else {
|
488 |
+
|
489 |
+
$productArray = $this->getProductsList ( $products, $storeId );
|
490 |
+
}
|
491 |
+
$response ['success'] = 1;
|
492 |
+
$response ['error'] = false;
|
493 |
+
$response ['total_count'] = $totalProducts;
|
494 |
+
$response ['result'] = $productArray;
|
495 |
+
return json_encode ( $response );
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
*
|
500 |
+
* @param array $products
|
501 |
+
* @param int $storeId
|
502 |
+
* @return array $productArray
|
503 |
+
*/
|
504 |
+
public function getProductsList($products, $storeId) {
|
505 |
+
$productArray = array ();
|
506 |
+
|
507 |
+
// @var Mage_Catalog_Model_Product $product
|
508 |
+
$productColl = array ();
|
509 |
+
foreach ( $products as $product ) {
|
510 |
+
|
511 |
+
$product->setStoreId ( $storeId )->load ( $product->getId () );
|
512 |
+
$this->_setProduct ( $product );
|
513 |
+
$productColl = $this->_prepareProductForResponse ( $product );
|
514 |
+
|
515 |
+
$productArray [] = $productColl;
|
516 |
+
}
|
517 |
+
|
518 |
+
return $productArray;
|
519 |
+
}
|
520 |
+
|
521 |
+
/**
|
522 |
+
* Add special fields to product get response
|
523 |
+
*
|
524 |
+
* @param Mage_Catalog_Model_Product $product
|
525 |
+
*/
|
526 |
+
protected function _prepareProductForResponse(Mage_Catalog_Model_Product $product) {
|
527 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITE_ID );
|
528 |
+
if ($websiteId <= 0) {
|
529 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
530 |
+
}
|
531 |
+
// get store id from request
|
532 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STORE_ID );
|
533 |
+
if ($storeId <= 0) {
|
534 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
535 |
+
}
|
536 |
+
// get customer id from request
|
537 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( 'customer_id' );
|
538 |
+
|
539 |
+
// get image size for resize
|
540 |
+
$imageSize = ( int ) $this->getRequest ()->getParam ( 'image_size' );
|
541 |
+
|
542 |
+
/**
|
543 |
+
*
|
544 |
+
* @var $productHelper Mage_Catalog_Helper_Product
|
545 |
+
*/
|
546 |
+
$productHelper = Mage::helper ( 'catalog/product' );
|
547 |
+
|
548 |
+
$productData [static::ENTITYID] = $product->getEntity_id ();
|
549 |
+
$productData [static::NAME] = $product->getName ();
|
550 |
+
$productData ['type_id'] = $product->getTypeId ();
|
551 |
+
$product->setWebsiteId ( $websiteId );
|
552 |
+
// customer group is required in product for correct prices calculation
|
553 |
+
$product->setCustomerGroupId ( $this->_getCustomerGroupId () );
|
554 |
+
// calculate prices
|
555 |
+
$finalPrice = $product->getFinalPrice ();
|
556 |
+
if ($product->getTypeId () == 'grouped') {
|
557 |
+
$productData ['regular_price_with_tax'] = number_format ( $product->getMinimalPrice (), 2, '.', '' );
|
558 |
+
$productData ['final_price_with_tax'] = number_format ( $product->getMinimalPrice (), 2, '.', '' );
|
559 |
+
} else {
|
560 |
+
$productData ['regular_price_with_tax'] = number_format ( $this->_applyTaxToPrice ( $product->getPrice (), true ), 2, '.', '' );
|
561 |
+
$productData ['regular_price_without_tax'] = number_format ( $this->_applyTaxToPrice ( $product->getPrice (), false ), 2, '.', '' );
|
562 |
+
$productData ['final_price_with_tax'] = number_format ( $this->_applyTaxToPrice ( $finalPrice, true ), 2, '.', '' );
|
563 |
+
$productData ['final_price_without_tax'] = number_format ( $this->_applyTaxToPrice ( $finalPrice, false ), 2, '.', '' );
|
564 |
+
}
|
565 |
+
|
566 |
+
// get product stock details
|
567 |
+
$stockDetail = Mage::getModel ( static::LOGIN_TOKEN )->getStockDetail ( $product );
|
568 |
+
$productData [static::IS_SALEABLE] = $stockDetail [static::IS_SALEABLE];
|
569 |
+
$productData [static::ISSTOCK] = $stockDetail ['is_stock'];
|
570 |
+
// get product image
|
571 |
+
if ($imageSize <= 0) {
|
572 |
+
$productData [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, static::SMALLIMG );
|
573 |
+
} else {
|
574 |
+
$productData [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, static::SMALLIMG )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
575 |
+
}
|
576 |
+
|
577 |
+
// get rating
|
578 |
+
$productData ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $product->getId (), $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $product->getId (), $storeId ) : '0';
|
579 |
+
|
580 |
+
// get wishlisted products by customer
|
581 |
+
$wishListIds = array ();
|
582 |
+
if ($customerId > 0) {
|
583 |
+
$wishListIds = Mage::getModel ( static::LOGIN_TOKEN )->getWishlistByCustomer ( $customerId );
|
584 |
+
}
|
585 |
+
// Check to see the product is in wishlist
|
586 |
+
if (in_array ( $product->getId (), $wishListIds )) {
|
587 |
+
$productData [static::ISWISHLIST] = true;
|
588 |
+
} else {
|
589 |
+
$productData [static::ISWISHLIST] = false;
|
590 |
+
}
|
591 |
+
if ($this->getActionType () == static::ACTION_TYPE_ENTITY) {
|
592 |
+
// define URLs
|
593 |
+
$productData ['url'] = $productHelper->getProductUrl ( $product->getId () );
|
594 |
+
if ($imageSize <= 0) {
|
595 |
+
$productData [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, 'image' );
|
596 |
+
} else {
|
597 |
+
$productData [static::IMGURL] = ( string ) Mage::helper ( static::CATIMG )->init ( $product, 'image' )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
598 |
+
}
|
599 |
+
/**
|
600 |
+
*
|
601 |
+
* @var $cartHelper Mage_Checkout_Helper_Cart
|
602 |
+
*/
|
603 |
+
$cartHelper = Mage::helper ( 'checkout/cart' );
|
604 |
+
$productData ['buy_now_url'] = $cartHelper->getAddUrl ( $product );
|
605 |
+
|
606 |
+
/**
|
607 |
+
*
|
608 |
+
* @var $reviewModel Mage_Review_Model_Review
|
609 |
+
*/
|
610 |
+
$reviewModel = Mage::getModel ( 'review/review' );
|
611 |
+
$productData ['total_reviews_count'] = $reviewModel->getTotalReviews ( $product->getId (), true, $storeId );
|
612 |
+
|
613 |
+
$productData [static::TIERPRICE] = number_format ( $this->_getTierPrices (), 2, '.', '' );
|
614 |
+
// get product has custom options or not
|
615 |
+
$productData ['has_custom_options'] = count ( $product->getOptions () ) > 0;
|
616 |
+
} else {
|
617 |
+
// remove tier price from response
|
618 |
+
$product->unsetData ( static::TIERPRICE );
|
619 |
+
unset ( $productData [static::TIERPRICE] );
|
620 |
+
}
|
621 |
+
return $productData;
|
622 |
+
}
|
623 |
+
|
624 |
+
/**
|
625 |
+
* Filter products collection
|
626 |
+
*
|
627 |
+
* @param object $collection
|
628 |
+
* @param int $storeId
|
629 |
+
* @return mixed object
|
630 |
+
*/
|
631 |
+
public function _getProductByFilter($collection, $storeId) {
|
632 |
+
|
633 |
+
// get filter types attributes
|
634 |
+
$filters = json_decode ( $this->getRequest ()->getParam ( 'filters' ), true );
|
635 |
+
|
636 |
+
if (array_key_exists ( static::PRICE, $filters )) {
|
637 |
+
|
638 |
+
// get price range
|
639 |
+
$priceRange = $filters [static::PRICE];
|
640 |
+
unset ( $filters [static::PRICE] );
|
641 |
+
}
|
642 |
+
// get availability tag
|
643 |
+
if (array_key_exists ( static::AVAILABILITY, $filters )) {
|
644 |
+
$availability = $filters [static::AVAILABILITY];
|
645 |
+
unset ( $filters [static::AVAILABILITY] );
|
646 |
+
}
|
647 |
+
// get the table preix value
|
648 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
649 |
+
|
650 |
+
$collection = $this->_getProductBySort ( $collection, $storeId );
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Filter collection Based on stock availability
|
654 |
+
*
|
655 |
+
* @param boolean $availability
|
656 |
+
* 0 | 1 input for stock in or stock out
|
657 |
+
*/
|
658 |
+
if ($availability != '') {
|
659 |
+
Mage::getSingleton ( 'cataloginventory/stock' )->addInStockFilterToCollection ( $collection );
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Filter collection Based on minimun and maximum price
|
664 |
+
*
|
665 |
+
* @param integer $minPrice
|
666 |
+
* @param integer $maxPrice
|
667 |
+
*/
|
668 |
+
if ($priceRange [0] != '' && $priceRange [1] != '') {
|
669 |
+
$collection->getSelect ()->join ( array (
|
670 |
+
'price1' => $prefix . 'catalog_product_index_price'
|
671 |
+
), 'cat_pro.product_id = price1.entity_id', array (
|
672 |
+
static::FINALPRICE => 'price1.final_price'
|
673 |
+
) )->where ( 'price1.customer_group_id =1' )->where ( "price1.final_price >= $priceRange[0] and price1.final_price <= $priceRange[1]" );
|
674 |
+
$collection->getSelectSql ( true );
|
675 |
+
}
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Filter collection Based on attribute code
|
679 |
+
*
|
680 |
+
* @param string $filters
|
681 |
+
* input for brand array filter products
|
682 |
+
*/
|
683 |
+
if (is_array ( $filters )) {
|
684 |
+
foreach ( $filters as $attrCode => $attrValueId ) {
|
685 |
+
$attributeid = $this->getAttributeId ( $attrCode );
|
686 |
+
if ($attrValueId != '') {
|
687 |
+
$attrValueId = implode ( ",", $attrValueId );
|
688 |
+
$collection->getSelect ()->join ( array (
|
689 |
+
$attrCode => Mage::getModel ( 'core/resource' )->getTableName ( 'catalog_product_index_eav' )
|
690 |
+
), "e.entity_id = " . $attrCode . ".entity_id AND " . $attrCode . ".attribute_id = " . $attributeid . " AND " . $attrCode . ".value IN(" . $attrValueId . ")", array (
|
691 |
+
'value'
|
692 |
+
) );
|
693 |
+
$collection->getSelectSql ( true );
|
694 |
+
}
|
695 |
+
}
|
696 |
+
}
|
697 |
+
$collection->getSelect ()->group ( static::E_ENTITY_ID );
|
698 |
+
return $collection;
|
699 |
+
}
|
700 |
+
|
701 |
+
/**
|
702 |
+
* Sort Products Collection
|
703 |
+
*
|
704 |
+
* @param object $collection
|
705 |
+
* @param int $storeId
|
706 |
+
* @return mixed object
|
707 |
+
*/
|
708 |
+
public function _getProductBySort($collection, $storeId) {
|
709 |
+
// get sort by for products from request
|
710 |
+
$sortBy = $this->getRequest ()->getParam ( 'sortby' );
|
711 |
+
// get orderby for products from request
|
712 |
+
$orderBy = $this->getRequest ()->getParam ( 'orderby' );
|
713 |
+
|
714 |
+
// get page from request
|
715 |
+
$page = ( int ) $this->getRequest ()->getParam ( 'page' );
|
716 |
+
if ($page <= 0) {
|
717 |
+
$page = 1;
|
718 |
+
}
|
719 |
+
// get page from request
|
720 |
+
$limit = ( int ) $this->getRequest ()->getParam ( 'limit' );
|
721 |
+
if ($limit <= 0) {
|
722 |
+
$limit = 10;
|
723 |
+
}
|
724 |
+
// get the table preix value
|
725 |
+
$prefix = Mage::getConfig ()->getTablePrefix ();
|
726 |
+
|
727 |
+
// sorting products by name
|
728 |
+
if ($sortBy == static::NAME) {
|
729 |
+
$collection->setPage ( $page, $limit );
|
730 |
+
$collection->setOrder ( static::NAME, $orderBy );
|
731 |
+
} else if ($sortBy == static::PRICE) {
|
732 |
+
// sorting products by price
|
733 |
+
$collection->setPage ( $page, $limit );
|
734 |
+
$collection->getSelect ()->join ( array (
|
735 |
+
static::PRICE => $prefix . 'catalog_product_index_price'
|
736 |
+
), 'cat_pro.product_id = price.entity_id', array (
|
737 |
+
static::FINALPRICE => 'price.final_price'
|
738 |
+
) )->where ( 'price.customer_group_id =1' )->group ( static::E_ENTITY_ID )->order ( "price.final_price $orderBy" );
|
739 |
+
} else if ($sortBy == static::RATING) {
|
740 |
+
// sorting products by rating
|
741 |
+
$collection->setPage ( $page, $limit );
|
742 |
+
$collection->getSelect ()->joinLeft ( array (
|
743 |
+
'rating' => $prefix . 'rating_option_vote_aggregated'
|
744 |
+
), 'rating.entity_pk_value = cat_pro.product_id and rating.store_id =' . $storeId, array (
|
745 |
+
'percent_approved' => 'rating.percent_approved'
|
746 |
+
) )->group ( static::E_ENTITY_ID )->order ( "rating.percent_approved $orderBy" );
|
747 |
+
$collection->getSelectSql ( true );
|
748 |
+
} else {
|
749 |
+
$collection->setPage ( 1, 10 );
|
750 |
+
$collection->setOrder ( static::NAME, 'asc' );
|
751 |
+
}
|
752 |
+
return $collection;
|
753 |
+
}
|
754 |
+
|
755 |
+
/**
|
756 |
+
* Get attribute id by attribute code
|
757 |
+
*
|
758 |
+
* @param string $code
|
759 |
+
* Getting the particular attribute id
|
760 |
+
*
|
761 |
+
* @return int $id
|
762 |
+
*/
|
763 |
+
public function getAttributeId($code = '') {
|
764 |
+
if (! $code) {
|
765 |
+
return;
|
766 |
+
}
|
767 |
+
$attributeInfo = Mage::getResourceModel ( 'eav/entity_attribute_collection' )->setCodeFilter ( $code )->getFirstItem ();
|
768 |
+
return $attributeInfo->getId ();
|
769 |
+
}
|
770 |
+
}
|
app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Overwrite Customer Admin V1 class
|
4 |
+
*
|
5 |
+
* Contus
|
6 |
+
*
|
7 |
+
*
|
8 |
+
* NOTICE OF LICENSE
|
9 |
+
*
|
10 |
+
* This source file is subject to the EULA
|
11 |
+
* that is bundled with this package in the file LICENSE.txt.
|
12 |
+
* It is also available through the world-wide-web at this URL:
|
13 |
+
* http://www.apptha.com/LICENSE.txt
|
14 |
+
*
|
15 |
+
* ==============================================================
|
16 |
+
* MAGENTO EDITION USAGE NOTICE
|
17 |
+
* ==============================================================
|
18 |
+
* This package designed for Magento COMMUNITY edition
|
19 |
+
* Apptha does not guarantee correct work of this extension
|
20 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
21 |
+
* Apptha does not provide extension support in case of
|
22 |
+
* incorrect edition usage.
|
23 |
+
* ==============================================================
|
24 |
+
*
|
25 |
+
* @category Contus
|
26 |
+
* @package ContusRestapi_ProductList
|
27 |
+
* @author Contus Team <developers@contus.in>
|
28 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
29 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
30 |
+
* @since 1.0
|
31 |
+
*/
|
32 |
+
class ContusRestapi_ProductList_Model_Api2_ProductList_Rest_Admin_V1 extends ContusRestapi_ProductList_Model_Api2_ProductList_Rest {
|
33 |
+
}
|
app/code/local/ContusRestapi/ProductList/Model/Api2/ProductList/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Overwrite Customer Admin V1 class
|
4 |
+
*
|
5 |
+
* Contus
|
6 |
+
*
|
7 |
+
*
|
8 |
+
* NOTICE OF LICENSE
|
9 |
+
*
|
10 |
+
* This source file is subject to the EULA
|
11 |
+
* that is bundled with this package in the file LICENSE.txt.
|
12 |
+
* It is also available through the world-wide-web at this URL:
|
13 |
+
* http://www.apptha.com/LICENSE.txt
|
14 |
+
*
|
15 |
+
* ==============================================================
|
16 |
+
* MAGENTO EDITION USAGE NOTICE
|
17 |
+
* ==============================================================
|
18 |
+
* This package designed for Magento COMMUNITY edition
|
19 |
+
* Apptha does not guarantee correct work of this extension
|
20 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
21 |
+
* Apptha does not provide extension support in case of
|
22 |
+
* incorrect edition usage.
|
23 |
+
* ==============================================================
|
24 |
+
*
|
25 |
+
* @category Contus
|
26 |
+
* @package ContusRestapi_ProductList
|
27 |
+
* @author Contus Team <developers@contus.in>
|
28 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
29 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
30 |
+
* @since 1.0
|
31 |
+
*/
|
32 |
+
class ContusRestapi_ProductList_Model_Api2_ProductList_Rest_Guest_V1 extends ContusRestapi_ProductList_Model_Api2_ProductList_Rest {
|
33 |
+
}
|
app/code/local/ContusRestapi/ProductList/etc/api2.xml
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="ContusRestapi_ProductList">
|
6 |
+
<title>Product List</title>
|
7 |
+
<sort_order>20</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<product translate="title" module="api2">
|
12 |
+
<group>catalog_product</group>
|
13 |
+
<model>catalog/api2_product</model>
|
14 |
+
<working_model>catalog/product</working_model>
|
15 |
+
<title>Catalog Product</title>
|
16 |
+
<sort_order>10</sort_order>
|
17 |
+
<privileges>
|
18 |
+
<admin>
|
19 |
+
<create>1</create>
|
20 |
+
<retrieve>1</retrieve>
|
21 |
+
<update>1</update>
|
22 |
+
<delete>1</delete>
|
23 |
+
</admin>
|
24 |
+
<customer>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes translate="entity_id type_id attribute_set_id stock_data image_url is_saleable total_reviews_count url buy_now_url has_custom_options is_in_stock regular_price_with_tax regular_price_without_tax final_price_with_tax final_price_without_tax use_config_gift_message_available use_config_gift_wrapping_available url_key_create_redirect" module="api2">
|
32 |
+
<entity_id>Product ID</entity_id>
|
33 |
+
<type_id>Product Type</type_id>
|
34 |
+
<attribute_set_id>Attribute Set</attribute_set_id>
|
35 |
+
<stock_data>Inventory Data</stock_data>
|
36 |
+
<image_url>Default Image</image_url>
|
37 |
+
<is_saleable>Salability Status</is_saleable>
|
38 |
+
<total_reviews_count>Total Reviews Count</total_reviews_count>
|
39 |
+
<url>Product URL</url>
|
40 |
+
<buy_now_url>Buy Now URL</buy_now_url>
|
41 |
+
<has_custom_options>Has Custom Options</has_custom_options>
|
42 |
+
<is_in_stock>Stock Status</is_in_stock>
|
43 |
+
<regular_price_with_tax>Regular Price With Tax</regular_price_with_tax>
|
44 |
+
<regular_price_without_tax>Regular Price Without Tax</regular_price_without_tax>
|
45 |
+
<final_price_with_tax>Final Price With Tax</final_price_with_tax>
|
46 |
+
<final_price_without_tax>Final Price Without Tax</final_price_without_tax>
|
47 |
+
<use_config_gift_message_available>Use Config Settings for Allow Gift Message</use_config_gift_message_available>
|
48 |
+
<use_config_gift_wrapping_available>Use Config Settings for Allow Gift Wrapping</use_config_gift_wrapping_available>
|
49 |
+
<url_key_create_redirect>Create Permanent Redirect for old URL</url_key_create_redirect>
|
50 |
+
<ratings>Rating Average</ratings>
|
51 |
+
<stock>Stock Status</stock>
|
52 |
+
<wishlist>Wishlist</wishlist>
|
53 |
+
<result>Result</result>
|
54 |
+
<count>Product Count</count>
|
55 |
+
<code> Code </code>
|
56 |
+
<success> Success </success>
|
57 |
+
<filter_attr>Filter attribute</filter_attr>
|
58 |
+
<filters>Filters</filters>
|
59 |
+
<error>Error</error>
|
60 |
+
</attributes>
|
61 |
+
<entity_only_attributes>
|
62 |
+
<customer>
|
63 |
+
<read>
|
64 |
+
<has_custom_options>1</has_custom_options>
|
65 |
+
<tier_price>1</tier_price>
|
66 |
+
<total_reviews_count>1</total_reviews_count>
|
67 |
+
<url>1</url>
|
68 |
+
<buy_now_url>1</buy_now_url>
|
69 |
+
<has_custom_options>1</has_custom_options>
|
70 |
+
<is_in_stock>1</is_in_stock>
|
71 |
+
</read>
|
72 |
+
</customer>
|
73 |
+
<guest>
|
74 |
+
<read>
|
75 |
+
<has_custom_options>1</has_custom_options>
|
76 |
+
<tier_price>1</tier_price>
|
77 |
+
<total_reviews_count>1</total_reviews_count>
|
78 |
+
<url>1</url>
|
79 |
+
<buy_now_url>1</buy_now_url>
|
80 |
+
<has_custom_options>1</has_custom_options>
|
81 |
+
<is_in_stock>1</is_in_stock>
|
82 |
+
</read>
|
83 |
+
</guest>
|
84 |
+
</entity_only_attributes>
|
85 |
+
<exclude_attributes>
|
86 |
+
<customer>
|
87 |
+
<read>
|
88 |
+
<attribute_set_id>1</attribute_set_id>
|
89 |
+
<stock_data>1/</stock_data>
|
90 |
+
<use_config_gift_message_available>1</use_config_gift_message_available>
|
91 |
+
<use_config_gift_wrapping_available>1</use_config_gift_wrapping_available>
|
92 |
+
<url_key_create_redirect>1</url_key_create_redirect>
|
93 |
+
</read>
|
94 |
+
</customer>
|
95 |
+
<guest>
|
96 |
+
<read>
|
97 |
+
<attribute_set_id>1</attribute_set_id>
|
98 |
+
<stock_data>1</stock_data>
|
99 |
+
<use_config_gift_message_available>1</use_config_gift_message_available>
|
100 |
+
<use_config_gift_wrapping_available>1</use_config_gift_wrapping_available>
|
101 |
+
<url_key_create_redirect>1</url_key_create_redirect>
|
102 |
+
</read>
|
103 |
+
</guest>
|
104 |
+
<admin>
|
105 |
+
<read>
|
106 |
+
<allow_open_amount>1</allow_open_amount>
|
107 |
+
<giftcard_amounts>1</giftcard_amounts>
|
108 |
+
<open_amount_min>1</open_amount_min>
|
109 |
+
<open_amount_max>1</open_amount_max>
|
110 |
+
<image>1</image>
|
111 |
+
<is_recurring>1</is_recurring>
|
112 |
+
<gallery>1</gallery>
|
113 |
+
<media_gallery>1</media_gallery>
|
114 |
+
<price_view>1</price_view>
|
115 |
+
<small_image>1</small_image>
|
116 |
+
<image_url>1</image_url>
|
117 |
+
<is_saleable>1</is_saleable>
|
118 |
+
<total_reviews_count>1</total_reviews_count>
|
119 |
+
<url>1</url>
|
120 |
+
<buy_now_url>1</buy_now_url>
|
121 |
+
<has_custom_options>1</has_custom_options>
|
122 |
+
<is_in_stock>1</is_in_stock>
|
123 |
+
<regular_price_with_tax>1</regular_price_with_tax>
|
124 |
+
<regular_price_without_tax>1</regular_price_without_tax>
|
125 |
+
<final_price_with_tax>1</final_price_with_tax>
|
126 |
+
<final_price_without_tax>1</final_price_without_tax>
|
127 |
+
<recurring_profile>1</recurring_profile>
|
128 |
+
<thumbnail>1</thumbnail>
|
129 |
+
<url_key_create_redirect>1</url_key_create_redirect>
|
130 |
+
</read>
|
131 |
+
<write>
|
132 |
+
<allow_open_amount>1</allow_open_amount>
|
133 |
+
<giftcard_amounts>1</giftcard_amounts>
|
134 |
+
<open_amount_min>1</open_amount_min>
|
135 |
+
<open_amount_max>1</open_amount_max>
|
136 |
+
<image>1</image>
|
137 |
+
<is_recurring>1</is_recurring>
|
138 |
+
<gallery>1</gallery>
|
139 |
+
<media_gallery>1</media_gallery>
|
140 |
+
<price_view>1</price_view>
|
141 |
+
<small_image>1</small_image>
|
142 |
+
<image_url>1</image_url>
|
143 |
+
<is_saleable>1</is_saleable>
|
144 |
+
<total_reviews_count>1</total_reviews_count>
|
145 |
+
<url>1</url>
|
146 |
+
<buy_now_url>1</buy_now_url>
|
147 |
+
<has_custom_options>1</has_custom_options>
|
148 |
+
<is_in_stock>1</is_in_stock>
|
149 |
+
<regular_price_with_tax>1</regular_price_with_tax>
|
150 |
+
<regular_price_without_tax>1</regular_price_without_tax>
|
151 |
+
<final_price_with_tax>1</final_price_with_tax>
|
152 |
+
<final_price_without_tax>1</final_price_without_tax>
|
153 |
+
<recurring_profile>1</recurring_profile>
|
154 |
+
<thumbnail>1</thumbnail>
|
155 |
+
<entity_id>1</entity_id>
|
156 |
+
</write>
|
157 |
+
</admin>
|
158 |
+
</exclude_attributes>
|
159 |
+
<routes>
|
160 |
+
<route_entity>
|
161 |
+
<route>/product_detail/</route>
|
162 |
+
<action_type>entity</action_type>
|
163 |
+
</route_entity>
|
164 |
+
<route_entity_with_store>
|
165 |
+
<route>/products/:id/store/:store</route>
|
166 |
+
<action_type>entity</action_type>
|
167 |
+
</route_entity_with_store>
|
168 |
+
<route_collection>
|
169 |
+
<route>/products</route>
|
170 |
+
<action_type>collection</action_type>
|
171 |
+
</route_collection>
|
172 |
+
<route_collection_with_store>
|
173 |
+
<route>/products/store/:store</route>
|
174 |
+
<action_type>collection</action_type>
|
175 |
+
</route_collection_with_store>
|
176 |
+
<route_collection_with_category>
|
177 |
+
<route>/products/category/:category_id</route>
|
178 |
+
<action_type>collection</action_type>
|
179 |
+
</route_collection_with_category>
|
180 |
+
<route_collection_with_store_and_category>
|
181 |
+
<route>/products/store/:store/category/:category_id</route>
|
182 |
+
<action_type>collection</action_type>
|
183 |
+
</route_collection_with_store_and_category>
|
184 |
+
<route_collection_with_category_and_store>
|
185 |
+
<route>/products_list/</route>
|
186 |
+
<action_type>collection</action_type>
|
187 |
+
</route_collection_with_category_and_store>
|
188 |
+
</routes>
|
189 |
+
<versions>1</versions>
|
190 |
+
</product>
|
191 |
+
|
192 |
+
</resources>
|
193 |
+
</api2>
|
194 |
+
</config>
|
app/code/local/ContusRestapi/ProductList/etc/config.xml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ProductList>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</ContusRestapi_ProductList>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<catalog>
|
11 |
+
<rewrite>
|
12 |
+
<api2_product_rest>ContusRestapi_ProductList_Model_Api2_ProductList_Rest</api2_product_rest>
|
13 |
+
<api2_product_rest_guest_v1>ContusRestapi_ProductList_Model_Api2_ProductList_Rest_Guest_V1</api2_product_rest_guest_v1>
|
14 |
+
<api2_product_rest_admin_v1>ContusRestapi_ProductList_Model_Api2_ProductList_Rest_Admin_V1</api2_product_rest_admin_v1>
|
15 |
+
|
16 |
+
</rewrite>
|
17 |
+
</catalog>
|
18 |
+
|
19 |
+
<productList>
|
20 |
+
<class>ContusRestapi_ProductList_Model</class>
|
21 |
+
</productList>
|
22 |
+
</models>
|
23 |
+
</global>
|
24 |
+
</config>
|
app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Registration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_ChangePassword_Rest extends Mage_Customer_Model_Api2_Customer_Rest {
|
30 |
+
const CUSTOMERMODEL = 'customer/customer';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* function that is called when post is done **
|
34 |
+
*
|
35 |
+
* Change Customer Password
|
36 |
+
*
|
37 |
+
* @param array $data
|
38 |
+
*
|
39 |
+
* @return array json array
|
40 |
+
*/
|
41 |
+
protected function _create(array $data) {
|
42 |
+
$response = array();
|
43 |
+
$validate = 0;
|
44 |
+
$message = '';
|
45 |
+
$customerId = $data ['customer_id'];
|
46 |
+
$customer = Mage::getModel ( static::CUSTOMERMODEL );
|
47 |
+
$customer->load ( $customerId );
|
48 |
+
|
49 |
+
// get website id value
|
50 |
+
if ($data ['website_id']) {
|
51 |
+
$websiteId = $data ['website_id'];
|
52 |
+
} else {
|
53 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check this customer has valid token or not
|
58 |
+
*
|
59 |
+
* @var $isValidToken Mage_Login_Model_Token
|
60 |
+
*/
|
61 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
62 |
+
$response ['isValidToken'] = true;
|
63 |
+
try {
|
64 |
+
$loginCheck = Mage::getModel ( static::CUSTOMERMODEL )->setWebsiteId ( $websiteId )->authenticate ( $customer ['email'], $data ['old_password'] );
|
65 |
+
$validate = 1;
|
66 |
+
|
67 |
+
if (! $isValidToken) {
|
68 |
+
$response ['isValidToken'] = false;
|
69 |
+
throw new Exception ( 'Authentication failed.' );
|
70 |
+
}
|
71 |
+
} catch ( Exception $ex ) {
|
72 |
+
$validate = 0;
|
73 |
+
$message = $ex->getMessage ();
|
74 |
+
$loginCheck = false;
|
75 |
+
}
|
76 |
+
|
77 |
+
//If old password wrong return this error message.
|
78 |
+
if(!$loginCheck){
|
79 |
+
$message = 'Your old password is wrong. Please check your credentials.';
|
80 |
+
}
|
81 |
+
|
82 |
+
if ($validate == 1) {
|
83 |
+
try {
|
84 |
+
$customer = Mage::getModel ( static::CUSTOMERMODEL )->load ( $customerId );
|
85 |
+
$customer->setPassword ( $data ['new_password'] );
|
86 |
+
$customer->save ();
|
87 |
+
$message = 'Your Password has been Changed Successfully';
|
88 |
+
} catch ( Exception $ex ) {
|
89 |
+
$message = $ex->getMessage ();
|
90 |
+
}
|
91 |
+
}
|
92 |
+
$response ['error'] = false;
|
93 |
+
$response ['success'] = $validate;
|
94 |
+
$response [message] = $message;
|
95 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
96 |
+
return;
|
97 |
+
}
|
98 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Registration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_ChangePassword_Rest_Admin_V1 extends ContusRestapi_Registration_Model_Api2_ChangePassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Registration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_ChangePassword_Rest_Customer_V1 extends ContusRestapi_Registration_Model_Api2_ChangePassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/ChangePassword/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Registration
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_ChangePassword_Rest_Guest_V1 extends ContusRestapi_Registration_Model_Api2_ChangePassword_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest.php
ADDED
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_Registration_Rest extends Mage_Customer_Model_Api2_Customer_Rest {
|
30 |
+
const STOREID = 'store_id';
|
31 |
+
const PASSWORD = 'password';
|
32 |
+
const WEBSITEID = 'website_id';
|
33 |
+
const FIRSTNAME = 'firstname';
|
34 |
+
const LASTNAME = 'lastname';
|
35 |
+
const NEWSLETTER = 'newsletter';
|
36 |
+
const ENTITYID = 'entity_id';
|
37 |
+
const CUSTOMERID = 'customer_id';
|
38 |
+
const EMAIL = 'email';
|
39 |
+
const SUCCESS = 'success';
|
40 |
+
const MESSAGE = 'message';
|
41 |
+
const TOKEN = 'token';
|
42 |
+
const LOGIN_TOKEN = 'login/token';
|
43 |
+
const VALID_TOKEN = 'isValidToken';
|
44 |
+
const ERROR = 'error';
|
45 |
+
const RESULT = 'result';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* function that is called when post is done **
|
49 |
+
*
|
50 |
+
* Customer Registration
|
51 |
+
*
|
52 |
+
* @param array $data
|
53 |
+
*
|
54 |
+
* @return array json array
|
55 |
+
*/
|
56 |
+
protected function _create(array $data) {
|
57 |
+
$response = array ();
|
58 |
+
$is_error = 0;
|
59 |
+
// getting the device token
|
60 |
+
$deviceToken = $data ['device_token'];
|
61 |
+
// getting the device type
|
62 |
+
$deviceType = $data ['device_type'];
|
63 |
+
$params = $this->getParams ( $data );
|
64 |
+
$newsletterid = $params [static::NEWSLETTER];
|
65 |
+
$websiteid = $params [static::WEBSITEID];
|
66 |
+
$storeId = $params [static::STOREID];
|
67 |
+
|
68 |
+
/**
|
69 |
+
*
|
70 |
+
* @var $validator Mage_Api2_Model_Resource_Validator_Eav
|
71 |
+
*/
|
72 |
+
$validator = Mage::getResourceModel ( 'api2/validator_eav', array (
|
73 |
+
'resource' => $this
|
74 |
+
) );
|
75 |
+
$passArray = array ();
|
76 |
+
if (array_key_exists ( static::PASSWORD, $data )) {
|
77 |
+
$passArray = $data;
|
78 |
+
}
|
79 |
+
|
80 |
+
$data = $validator->filter ( $data );
|
81 |
+
if (! $validator->isValidData ( $data )) {
|
82 |
+
foreach ( $validator->getErrors () as $error ) {
|
83 |
+
$error_message = $error;
|
84 |
+
$is_error = 1;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
*
|
90 |
+
* @var $customer Mage_Customer_Model_Customer
|
91 |
+
*/
|
92 |
+
$customer = Mage::getModel ( 'customer/customer' );
|
93 |
+
$customer->setData ( $data );
|
94 |
+
if (array_key_exists ( static::PASSWORD, $passArray )) {
|
95 |
+
$customer->setPassword ( $passArray [static::PASSWORD] );
|
96 |
+
$customer->setConfirmation ( null );
|
97 |
+
// set newsletter subscription for customer
|
98 |
+
$customer->setIsSubscribed ( $newsletterid );
|
99 |
+
}
|
100 |
+
|
101 |
+
try {
|
102 |
+
|
103 |
+
if ($is_error) {
|
104 |
+
throw new Exception ( $error_message );
|
105 |
+
}
|
106 |
+
// set customer website id
|
107 |
+
$customer->setWebsiteId ( $websiteid );
|
108 |
+
// set store id for customer
|
109 |
+
$customer->setStoreId ( $storeId );
|
110 |
+
$customer->save ();
|
111 |
+
$customer->sendNewAccountEmail ();
|
112 |
+
// get customer data
|
113 |
+
$customerData = $customer->getData ();
|
114 |
+
$success = 1;
|
115 |
+
$register_message = 'You are successfully logged in.';
|
116 |
+
|
117 |
+
$tokenvalue = Mage::getModel ( static::LOGIN_TOKEN )->getRandomString ( 6 );
|
118 |
+
$tokenObj = Mage::getModel ( static::LOGIN_TOKEN )->load ( $customerData [static::ENTITYID], 'userid' );
|
119 |
+
$tokenObj->setUserid ( $customerData [static::ENTITYID] );
|
120 |
+
$tokenObj->setToken ( $tokenvalue );
|
121 |
+
$tokenObj->setCreated ( date ( 'Y-m-d H:i:s' ) );
|
122 |
+
$tokenObj->setStatus ( 1 );
|
123 |
+
$tokenObj->save ();
|
124 |
+
//Update device token and type in token table
|
125 |
+
Mage::getModel ( 'login/methods_functions' )->updateDeviceToken ( $customerData [static::ENTITYID], $deviceToken, $deviceType );
|
126 |
+
|
127 |
+
$response [static::RESULT] = Mage::getModel ( static::LOGIN_TOKEN )->getCustomerDetail ( $customerData [static::ENTITYID] );
|
128 |
+
$response [static::RESULT] [static::TOKEN] = $tokenvalue;
|
129 |
+
$response [static::RESULT] ['cart_count'] = 0;
|
130 |
+
} catch ( Mage_Core_Exception $e ) {
|
131 |
+
$success = 0;
|
132 |
+
$register_message = $e->getMessage ();
|
133 |
+
} catch ( Exception $e ) {
|
134 |
+
$success = 0;
|
135 |
+
$register_message = $e->getMessage ();
|
136 |
+
}
|
137 |
+
$response [static::ERROR] = false;
|
138 |
+
$response [static::SUCCESS] = $success;
|
139 |
+
$response [static::MESSAGE] = $register_message;
|
140 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* function that is called when post is done **
|
146 |
+
*
|
147 |
+
* Customer Registration
|
148 |
+
*
|
149 |
+
* @param array $data
|
150 |
+
*
|
151 |
+
* @return array json array
|
152 |
+
*/
|
153 |
+
protected function _update(array $data) {
|
154 |
+
$response = array ();
|
155 |
+
|
156 |
+
$params = $this->getParams ( $data );
|
157 |
+
$newsletter = $params [static::NEWSLETTER];
|
158 |
+
$storeId = $params [static::STOREID];
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Check this customer has valid token or not
|
162 |
+
*
|
163 |
+
* @var $isValidToken Mage_Login_Model_Token
|
164 |
+
*/
|
165 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $this->getRequest ()->getParam ( 'id' ), $data ['token'] );
|
166 |
+
|
167 |
+
/**
|
168 |
+
*
|
169 |
+
* @var $customer Mage_Customer_Model_Customer
|
170 |
+
*/
|
171 |
+
$customer = $this->_loadCustomerById ( $this->getRequest ()->getParam ( 'id' ) );
|
172 |
+
|
173 |
+
/**
|
174 |
+
*
|
175 |
+
* @var $validator Mage_Api2_Model_Resource_Validator_Eav
|
176 |
+
*/
|
177 |
+
$validator = Mage::getResourceModel ( 'api2/validator_eav', array (
|
178 |
+
'resource' => $this
|
179 |
+
) );
|
180 |
+
|
181 |
+
$data = $validator->filter ( $data );
|
182 |
+
// website is not allowed to change
|
183 |
+
unset ( $data [static::WEBSITEID] );
|
184 |
+
|
185 |
+
if (! $validator->isValidData ( $data, true )) {
|
186 |
+
foreach ( $validator->getErrors () as $error ) {
|
187 |
+
$error_message = $error;
|
188 |
+
$is_error = 1;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
$customer->addData ( $data );
|
193 |
+
|
194 |
+
$response [static::VALID_TOKEN] = true;
|
195 |
+
|
196 |
+
try {
|
197 |
+
|
198 |
+
if (! $isValidToken) {
|
199 |
+
$response [static::VALID_TOKEN] = false;
|
200 |
+
throw new Exception ( 'Authentication failed.' );
|
201 |
+
}
|
202 |
+
|
203 |
+
if ($is_error) {
|
204 |
+
throw new Exception ( $error_message );
|
205 |
+
}
|
206 |
+
// set store id for customer
|
207 |
+
$customer->setStoreId ( $storeId );
|
208 |
+
// set newsletter subscription for customer
|
209 |
+
$customer->setIsSubscribed ( $newsletter );
|
210 |
+
$customer->save ();
|
211 |
+
// get customer data
|
212 |
+
$customerData = $customer->getData ();
|
213 |
+
$success = 1;
|
214 |
+
$message = 'Customer information updated successfully';
|
215 |
+
|
216 |
+
$response [static::RESULT] = Mage::getModel ( static::LOGIN_TOKEN )->getCustomerDetail ( $customerData [static::ENTITYID] );
|
217 |
+
} catch ( Mage_Core_Exception $e ) {
|
218 |
+
$success = 0;
|
219 |
+
$message = $e->getMessage ();
|
220 |
+
} catch ( Exception $e ) {
|
221 |
+
$success = 0;
|
222 |
+
$message = $e->getMessage ();
|
223 |
+
}
|
224 |
+
|
225 |
+
$response [static::ERROR] = false;
|
226 |
+
$response [static::SUCCESS] = $success;
|
227 |
+
$response [static::MESSAGE] = $message;
|
228 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* function that is called when post is done
|
234 |
+
* Get customer details
|
235 |
+
*
|
236 |
+
* @see Mage_Api2_Model_Resource::_retrieve() **
|
237 |
+
*/
|
238 |
+
public function _retrieve() {
|
239 |
+
$result = array ();
|
240 |
+
$customerId = $this->getRequest ()->getParam ( 'id' );
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Check this customer has valid token or not
|
244 |
+
*
|
245 |
+
* @var $isValidToken Mage_Login_Model_Token
|
246 |
+
*/
|
247 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $this->getRequest ()->getParam ( static::TOKEN ) );
|
248 |
+
if ($isValidToken) {
|
249 |
+
|
250 |
+
$result ['result'] = Mage::getModel ( static::LOGIN_TOKEN )->getCustomerDetail ( $customerId );
|
251 |
+
$result [static::VALID_TOKEN] = true;
|
252 |
+
$result [static::SUCCESS] = 1;
|
253 |
+
$result [static::ERROR] = false;
|
254 |
+
} else {
|
255 |
+
$result [static::VALID_TOKEN] = false;
|
256 |
+
$result [static::SUCCESS] = 0;
|
257 |
+
$result [static::MESSAGE] = 'Authentication failed.';
|
258 |
+
}
|
259 |
+
|
260 |
+
return $result;
|
261 |
+
}
|
262 |
+
public function getParams($data) {
|
263 |
+
$result = array ();
|
264 |
+
// get newsletter value for customer
|
265 |
+
$result [static::NEWSLETTER] = (isset ( $data [static::NEWSLETTER] )) ? $data [static::NEWSLETTER] : 0;
|
266 |
+
// Get website id
|
267 |
+
$result [static::WEBSITEID] = (isset ( $data [static::WEBSITEID] )) ? $data [static::WEBSITEID] : Mage::app ()->getWebsite ( 'base' )->getId ();
|
268 |
+
// get store id
|
269 |
+
$result [static::STOREID] = (isset ( $data [static::STOREID] )) ? $data [static::STOREID] : Mage::app ()->getWebsite ( $result [static::WEBSITEID] )->getDefaultGroup ()->getDefaultStoreId ();
|
270 |
+
return $result;
|
271 |
+
}
|
272 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_Registration_Rest_Admin_V1 extends ContusRestapi_Registration_Model_Api2_Registration_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_Registration_Rest_Customer_V1 extends ContusRestapi_Registration_Model_Api2_Registration_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/Model/Api2/Registration/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Login
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Registration_Model_Api2_Registration_Rest_Guest_V1 extends ContusRestapi_Registration_Model_Api2_Registration_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Registration/etc/api2.xml
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="ContusRestapi_Registration">
|
6 |
+
<title>Register API Module</title>
|
7 |
+
<sort_order>20</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<registration translate="title" module="ContusRestapi_Registration">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>registration/api2_registration</model>
|
14 |
+
<title>Register</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
<update>1</update>
|
22 |
+
</admin>
|
23 |
+
<customer>
|
24 |
+
<create>1</create>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
<update>1</update>
|
27 |
+
</customer>
|
28 |
+
<guest>
|
29 |
+
<create>1</create>
|
30 |
+
<retrieve>1</retrieve>
|
31 |
+
<update>1</update>
|
32 |
+
</guest>
|
33 |
+
</privileges>
|
34 |
+
<attributes
|
35 |
+
translate="entity_id last_logged_in firstname lastname email website_id created_in group_id confirmation disable_auto_group_change"
|
36 |
+
module="api2">
|
37 |
+
<entity_id>Customer ID</entity_id>
|
38 |
+
<last_logged_in>Last Logged In</last_logged_in>
|
39 |
+
<firstname>First Name</firstname>
|
40 |
+
<lastname>Last Name</lastname>
|
41 |
+
<email>Email</email>
|
42 |
+
<website_id>Associate to Website</website_id>
|
43 |
+
<group_id>Group</group_id>
|
44 |
+
<confirmation>Is Confirmed</confirmation>
|
45 |
+
<store_id>Associate to Store</store_id>
|
46 |
+
<disable_auto_group_change>Disable automatic group change based on
|
47 |
+
VAT ID
|
48 |
+
</disable_auto_group_change>
|
49 |
+
<newsletter>Newsletter Subscribe</newsletter>
|
50 |
+
<dob>Date of Birth</dob>
|
51 |
+
<password>Password</password>
|
52 |
+
<token>Token</token>
|
53 |
+
<success>Success</success>
|
54 |
+
<message>Message</message>
|
55 |
+
<error>Error</error>
|
56 |
+
<isValidToken>IS valid Token</isValidToken>
|
57 |
+
<result>Result</result>
|
58 |
+
<device_token>Device Token</device_token>
|
59 |
+
<device_type>Device Type</device_type>
|
60 |
+
|
61 |
+
</attributes>
|
62 |
+
<routes>
|
63 |
+
|
64 |
+
<customer_update>
|
65 |
+
<route>/customer/update/:id</route>
|
66 |
+
<action_type>entity</action_type>
|
67 |
+
</customer_update>
|
68 |
+
<route_collection>
|
69 |
+
<route>/customer/register/</route>
|
70 |
+
<action_type>collection</action_type>
|
71 |
+
</route_collection>
|
72 |
+
|
73 |
+
<route_entity>
|
74 |
+
<route>/customer/detail/</route>
|
75 |
+
<action_type>entity</action_type>
|
76 |
+
</route_entity>
|
77 |
+
</routes>
|
78 |
+
<versions>1</versions>
|
79 |
+
|
80 |
+
<validators>
|
81 |
+
<eav>
|
82 |
+
<admin>
|
83 |
+
<entity_model>customer/customer</entity_model>
|
84 |
+
<form_model>customer/form</form_model>
|
85 |
+
<form_code>
|
86 |
+
<update>adminhtml_customer</update>
|
87 |
+
</form_code>
|
88 |
+
</admin>
|
89 |
+
<customer>
|
90 |
+
<entity_model>customer/customer</entity_model>
|
91 |
+
<form_model>customer/form</form_model>
|
92 |
+
<form_code>
|
93 |
+
<update>customer_account_edit</update>
|
94 |
+
</form_code>
|
95 |
+
</customer>
|
96 |
+
<guest>
|
97 |
+
<entity_model>customer/customer</entity_model>
|
98 |
+
<form_model>customer/form</form_model>
|
99 |
+
<form_code>
|
100 |
+
<update>customer_account_edit</update>
|
101 |
+
</form_code>
|
102 |
+
</guest>
|
103 |
+
</eav>
|
104 |
+
</validators>
|
105 |
+
</registration>
|
106 |
+
|
107 |
+
<registration_change_password translate="title"
|
108 |
+
module="ContusRestapi_Registration">
|
109 |
+
<group>contusrestapi</group>
|
110 |
+
<model>registration/api2_changePassword</model>
|
111 |
+
<!-- <working_model>restapi/api2_restapi</working_model> -->
|
112 |
+
<title>Update Customer</title>
|
113 |
+
<sort_order>12</sort_order>
|
114 |
+
<privileges>
|
115 |
+
<admin>
|
116 |
+
<create>1</create>
|
117 |
+
<retrieve>1</retrieve>
|
118 |
+
<delete>1</delete>
|
119 |
+
</admin>
|
120 |
+
<customer>
|
121 |
+
<create>1</create>
|
122 |
+
<retrieve>1</retrieve>
|
123 |
+
<update>1</update>
|
124 |
+
</customer>
|
125 |
+
<guest>
|
126 |
+
<create>1</create>
|
127 |
+
<retrieve>1</retrieve>
|
128 |
+
<update>1</update>
|
129 |
+
</guest>
|
130 |
+
</privileges>
|
131 |
+
<attributes
|
132 |
+
translate="entity_id customer_id email website_id store_id old_password new_password"
|
133 |
+
module="api2">
|
134 |
+
<entity_id>Customer ID</entity_id>
|
135 |
+
<customer_id>Customer ID</customer_id>
|
136 |
+
<email>Email</email>
|
137 |
+
<store_id>Associate to Store</store_id>
|
138 |
+
<old_password>Old Password</old_password>
|
139 |
+
<new_password>New Password</new_password>
|
140 |
+
<website_id>Website id</website_id>
|
141 |
+
<message>Message</message>
|
142 |
+
<status>Status</status>
|
143 |
+
<token>Token</token>
|
144 |
+
<error>Error</error>
|
145 |
+
<isValidToken>IS valid Token</isValidToken>
|
146 |
+
</attributes>
|
147 |
+
<routes>
|
148 |
+
<route_collection>
|
149 |
+
<route>/customer/changepassword/</route>
|
150 |
+
<action_type>collection</action_type>
|
151 |
+
</route_collection>
|
152 |
+
</routes>
|
153 |
+
<versions>1</versions>
|
154 |
+
</registration_change_password>
|
155 |
+
|
156 |
+
</resources>
|
157 |
+
</api2>
|
158 |
+
</config>
|
app/code/local/ContusRestapi/Registration/etc/config.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Registration>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</ContusRestapi_Registration>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
|
11 |
+
<registration>
|
12 |
+
<class>ContusRestapi_Registration_Model</class>
|
13 |
+
</registration>
|
14 |
+
</models>
|
15 |
+
</global>
|
16 |
+
</config>
|
app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Forgotpassword API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_ReviewRating
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_ReviewRating_Model_Api2_ReviewRating extends Mage_Api2_Model_Resource {
|
32 |
+
|
33 |
+
// define static variable.
|
34 |
+
const STOREID = 'store_id';
|
35 |
+
const WEBSITEID = 'website_id';
|
36 |
+
const CUSTOMER_ID = 'customer_id';
|
37 |
+
const PRODUCT_ID = 'product_id';
|
38 |
+
const SUCCESS = 'success';
|
39 |
+
const MESSAGE = 'message';
|
40 |
+
const ERROR = 'error';
|
41 |
+
const RESULT = 'result';
|
42 |
+
const TOKEN = 'token';
|
43 |
+
const LOGIN_TOKEN = 'login/token';
|
44 |
+
const VALID_TOKEN = 'isValidToken';
|
45 |
+
const REVIEWS = 'reviews';
|
46 |
+
const RATING = 'rating';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* function that is called when post is done **
|
50 |
+
*
|
51 |
+
* Add new review and rating and get all review by product id
|
52 |
+
*
|
53 |
+
* @param array $data
|
54 |
+
*
|
55 |
+
* @return array json array
|
56 |
+
*/
|
57 |
+
protected function _create(array $data) {
|
58 |
+
$response = array ();
|
59 |
+
// get customer id
|
60 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
61 |
+
// get product Id from request
|
62 |
+
$productId = ( int ) $data [static::PRODUCT_ID];
|
63 |
+
$websiteId = ( int ) $data [static::WEBSITEID];
|
64 |
+
if ($websiteId <= 0) {
|
65 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
66 |
+
}
|
67 |
+
// get store id from request
|
68 |
+
$storeId = ( int ) $data [static::STOREID];
|
69 |
+
if ($storeId <= 0) {
|
70 |
+
Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
71 |
+
}
|
72 |
+
// set review status as static 1 for approved. 2 for pending
|
73 |
+
$reviewStatus = 1;
|
74 |
+
// get rating value from request
|
75 |
+
$rating = $data [static::RATING];
|
76 |
+
// get token value from request
|
77 |
+
$token = $data [static::TOKEN];
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Check this customer has valid token or not
|
81 |
+
*
|
82 |
+
* @var $isValidToken Mage_Login_Model_Token
|
83 |
+
*/
|
84 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $token );
|
85 |
+
|
86 |
+
/**
|
87 |
+
*
|
88 |
+
* @var $review Mage_Review_Model_Review
|
89 |
+
*/
|
90 |
+
$review = Mage::getModel ( 'review/review' );
|
91 |
+
try {
|
92 |
+
// check customer token
|
93 |
+
if (! $isValidToken) {
|
94 |
+
throw new Exception ( 'Authentication failed.' );
|
95 |
+
}
|
96 |
+
$review->setEntityPkValue ( $productId );
|
97 |
+
$review->setStatusId ( $reviewStatus );
|
98 |
+
$review->setTitle ( $data ['review_title'] );
|
99 |
+
$review->setDetail ( $data ['review_description'] );
|
100 |
+
$review->setEntityId ( 1 );
|
101 |
+
$review->setStoreId ( $sotreId );
|
102 |
+
$review->setCustomerId ( $customerId );
|
103 |
+
$review->setNickname ( $data ['customer_name'] );
|
104 |
+
$review->setReviewId ( $review->getId () );
|
105 |
+
$review->setStores ( array (
|
106 |
+
$storeId
|
107 |
+
) );
|
108 |
+
$review->save ();
|
109 |
+
|
110 |
+
/**
|
111 |
+
*
|
112 |
+
* @var $customer Mage_Rating_Model_Rating
|
113 |
+
*/
|
114 |
+
$ratingModel = Mage::getModel ( 'rating/rating' )->setReviewId ( $review->getId () )->setCustomerId ( $customerId );
|
115 |
+
// save rating for quality
|
116 |
+
$ratingModel->setRatingId ( 1 )->addOptionVote ( $rating, $productId );
|
117 |
+
// save rating for value
|
118 |
+
$ratingModel->setRatingId ( 2 )->addOptionVote ( $rating + 5, $productId );
|
119 |
+
// save rating for price
|
120 |
+
$ratingModel->setRatingId ( 3 )->addOptionVote ( $rating + 10, $productId );
|
121 |
+
$review->aggregate ();
|
122 |
+
if ($review->save ()) {
|
123 |
+
$success = 1;
|
124 |
+
// Thank you for submitting a review. Your review is awaiting moderation. this is for pendind status
|
125 |
+
$message = 'Thank you for submitting a review. Your review is added successfully.';
|
126 |
+
} else {
|
127 |
+
$success = 0;
|
128 |
+
$message = 'Sorry, we are unable to add your review at this time.';
|
129 |
+
}
|
130 |
+
} catch ( Exception $e ) {
|
131 |
+
$success = 0;
|
132 |
+
$message = $e->getMessage ();
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Getting average of ratings/reviews
|
137 |
+
*/
|
138 |
+
$reviewRating = Mage::getModel ( static::LOGIN_TOKEN )->getRatingResult ( $productId, $storeId );
|
139 |
+
// get total reviews
|
140 |
+
$total_reviews_count = $review->getTotalReviews ( $productId, true, $storeId );
|
141 |
+
|
142 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
143 |
+
$response [static::ERROR] = false;
|
144 |
+
$response [static::SUCCESS] = $success;
|
145 |
+
$response [static::MESSAGE] = $message;
|
146 |
+
$response [static::RESULT] = $reviewRating;
|
147 |
+
$response [static::RESULT] ['review_status'] = $reviewStatus;
|
148 |
+
$response [static::RESULT] ['total_reviews_count'] = $total_reviews_count;
|
149 |
+
$response [static::RESULT] ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $productId, $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $productId, $storeId ) : '0';
|
150 |
+
|
151 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Get reviews ans rating colection fro Product
|
157 |
+
*
|
158 |
+
* @see Mage_Api2_Model_Resource::_retrieveCollection()
|
159 |
+
*/
|
160 |
+
protected function _retrieveCollection() {
|
161 |
+
$response = array ();
|
162 |
+
|
163 |
+
// get website id from request
|
164 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITEID );
|
165 |
+
if ($websiteId <= 0) {
|
166 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
167 |
+
}
|
168 |
+
|
169 |
+
// get store id
|
170 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
171 |
+
if ($storeId <= 0) {
|
172 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
173 |
+
}
|
174 |
+
// get product id
|
175 |
+
$productId = ( int ) $this->getRequest ()->getParam ( 'product_id' );
|
176 |
+
|
177 |
+
$page = ( int ) $this->getRequest ()->getParam ( 'page' );
|
178 |
+
if ($page <= 0) {
|
179 |
+
$page = 1;
|
180 |
+
}
|
181 |
+
$limit = ( int ) $this->getRequest ()->getParam ( 'limit' );
|
182 |
+
if ($limit <= 0) {
|
183 |
+
$limit = 10;
|
184 |
+
}
|
185 |
+
try {
|
186 |
+
/**
|
187 |
+
*
|
188 |
+
* @var $review Mage_Review_Model_Review
|
189 |
+
*/
|
190 |
+
$review = Mage::getModel ( 'review/review' );
|
191 |
+
// get total reviews
|
192 |
+
$total_reviews_count = $review->getTotalReviews ( $productId, true, $storeId );
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Getting average of ratings/reviews
|
196 |
+
*/
|
197 |
+
$last_page = ceil ( $total_reviews_count / $limit );
|
198 |
+
if ($last_page < $page) {
|
199 |
+
$reviewRating [static::REVIEWS] = array ();
|
200 |
+
$ratings [static::RATING] = array ();
|
201 |
+
} else {
|
202 |
+
$reviewRating = Mage::getModel ( static::LOGIN_TOKEN )->getReviews ( $productId, $storeId, $page, $limit );
|
203 |
+
// get product rating count summary
|
204 |
+
$ratings = Mage::getModel ( static::LOGIN_TOKEN )->getRatingResult ( $productId, $storeId );
|
205 |
+
}
|
206 |
+
$success = 1;
|
207 |
+
} catch ( Exception $e ) {
|
208 |
+
$success = 0;
|
209 |
+
}
|
210 |
+
|
211 |
+
$response [static::ERROR] = false;
|
212 |
+
$response [static::SUCCESS] = $success;
|
213 |
+
$response [static::RESULT] ['total_reviews_count'] = $total_reviews_count;
|
214 |
+
$response [static::RESULT] ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $productId, $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $productId, $storeId ) : '0';
|
215 |
+
$response [static::RESULT] [static::REVIEWS] = $reviewRating [static::REVIEWS];
|
216 |
+
// get product rating count summary
|
217 |
+
$response [static::RESULT] [static::RATING] = $ratings [static::RATING];
|
218 |
+
return $response;
|
219 |
+
}
|
220 |
+
}
|
app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ReviewRating
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest extends ContusRestapi_ReviewRating_Model_Api2_ReviewRating {
|
30 |
+
}
|
app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ReviewRating
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest_Admin_V1 extends ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ReviewRating
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest_Customer_V1 extends ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ReviewRating/Model/Api2/ReviewRating/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ReviewRating
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest_Guest_V1 extends ContusRestapi_ReviewRating_Model_Api2_ReviewRating_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ReviewRating/etc/api2.xml
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="ReviewRating">
|
6 |
+
<title>Reviews and Ratings</title>
|
7 |
+
<sort_order>14</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<reviewRating translate="title" module="ReviewRating">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>reviewRating/api2_reviewRating</model>
|
14 |
+
<title>Reviews and Ratings</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
<delete>1</delete>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<create>1</create>
|
29 |
+
<retrieve>1</retrieve>
|
30 |
+
<delete>1</delete>
|
31 |
+
</guest>
|
32 |
+
</privileges>
|
33 |
+
<attributes module="api2">
|
34 |
+
<website_id>websiteid</website_id>
|
35 |
+
<store_id>Associate to Store</store_id>
|
36 |
+
<customer_id>Customer Id</customer_id>
|
37 |
+
<customer_name>Customer Name</customer_name>
|
38 |
+
<product_id>Product Id</product_id>
|
39 |
+
<review_title>Review Title</review_title>
|
40 |
+
<review_description>Review Description</review_description>
|
41 |
+
<review_status>Review Status</review_status>
|
42 |
+
<rating>Rating count</rating>
|
43 |
+
<result>All Reviews</result>
|
44 |
+
<summary_rating>Over all Rating</summary_rating>
|
45 |
+
<success>Code</success>
|
46 |
+
<message>Message</message>
|
47 |
+
<token>Token</token>
|
48 |
+
<total_reviews_count>Total Reviews Count</total_reviews_count>
|
49 |
+
<reviews>Reviews</reviews>
|
50 |
+
</attributes>
|
51 |
+
<routes>
|
52 |
+
<route_collection>
|
53 |
+
<route>/add/reviews/</route>
|
54 |
+
<action_type>collection</action_type>
|
55 |
+
</route_collection>
|
56 |
+
<reviews_collection>
|
57 |
+
<route>/reviews/list/</route>
|
58 |
+
<action_type>collection</action_type>
|
59 |
+
</reviews_collection>
|
60 |
+
</routes>
|
61 |
+
<versions>1</versions>
|
62 |
+
</reviewRating>
|
63 |
+
|
64 |
+
</resources>
|
65 |
+
</api2>
|
66 |
+
</config>
|
app/code/local/ContusRestapi/ReviewRating/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ReviewRating>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_ReviewRating>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<reviewRating>
|
11 |
+
<class>ContusRestapi_ReviewRating_Model</class>
|
12 |
+
</reviewRating>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts.php
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Forgotpassword API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_SearchProducts
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_SearchProducts_Model_Api2_SearchProducts extends Mage_Api2_Model_Resource {
|
32 |
+
|
33 |
+
// Declaring the string literals variable
|
34 |
+
const STOREID = 'store_id';
|
35 |
+
const CUSTOMER_ID = 'customer_id';
|
36 |
+
const SEARCH_TERM = 'search_term';
|
37 |
+
const CATEGORY_ID = 'category_id';
|
38 |
+
const CATALOGSEARCH = 'catalogsearch';
|
39 |
+
const IS_SALABLE = 'is_saleable';
|
40 |
+
const LIMIT = 'limit';
|
41 |
+
const PAGE = 'page';
|
42 |
+
const LOGIN_TOKEN = 'login/token';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Search products based on posted value
|
46 |
+
*
|
47 |
+
* @return array json array
|
48 |
+
*/
|
49 |
+
protected function _retrieveCollection() {
|
50 |
+
|
51 |
+
// get website id
|
52 |
+
$websiteId = ( int ) Mage::app ()->getRequest ()->getParam ( 'website_id' );
|
53 |
+
if ($websiteId <= 0) {
|
54 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
55 |
+
}
|
56 |
+
|
57 |
+
// get store id from request
|
58 |
+
$storeId = ( int ) Mage::app ()->getRequest ()->getParam ( static::STOREID );
|
59 |
+
if ($storeId <= 0) {
|
60 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
61 |
+
}
|
62 |
+
// get search term from request
|
63 |
+
$searchterm = Mage::app ()->getRequest ()->getParam ( static::SEARCH_TERM );
|
64 |
+
// get category id from request
|
65 |
+
$categoryId = ( int ) Mage::app ()->getRequest ()->getParam ( static::CATEGORY_ID );
|
66 |
+
|
67 |
+
// get page from request
|
68 |
+
$page = ( int ) $this->getRequest ()->getParam ( static::PAGE );
|
69 |
+
if ($page <= 0) {
|
70 |
+
$page = 1;
|
71 |
+
}
|
72 |
+
|
73 |
+
// get page from request
|
74 |
+
$limit = ( int ) $this->getRequest ()->getParam ( static::LIMIT );
|
75 |
+
if ($limit <= 0) {
|
76 |
+
$limit = 10;
|
77 |
+
}
|
78 |
+
// get customer id from request
|
79 |
+
$customerId = ( int ) Mage::app ()->getRequest ()->getParam ( static::CUSTOMER_ID );
|
80 |
+
|
81 |
+
return $this->getCatalogSearch ( array (
|
82 |
+
static::SEARCH_TERM => $searchterm,
|
83 |
+
static::STOREID => $storeId,
|
84 |
+
static::CATEGORY_ID => $categoryId,
|
85 |
+
static::CUSTOMER_ID => $customerId,
|
86 |
+
static::PAGE => $page,
|
87 |
+
static::LIMIT => $limit
|
88 |
+
) );
|
89 |
+
}
|
90 |
+
/**
|
91 |
+
* Search products by given word
|
92 |
+
*
|
93 |
+
* @param array $data
|
94 |
+
* @return array
|
95 |
+
*/
|
96 |
+
public function getCatalogSearch($data) {
|
97 |
+
$response = array ();
|
98 |
+
$page = $data [static::PAGE];
|
99 |
+
$limit = $data [static::LIMIT];
|
100 |
+
// get category id
|
101 |
+
$categoryId = ( int ) $data [static::CATEGORY_ID];
|
102 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
103 |
+
|
104 |
+
$_helper = Mage::helper ( static::CATALOGSEARCH );
|
105 |
+
$queryParam = str_replace ( '%20', ' ', $data [static::SEARCH_TERM] );
|
106 |
+
Mage::app ()->getRequest ()->setParam ( $_helper->getQueryParamName (), $queryParam );
|
107 |
+
$query = $_helper->getQuery ();
|
108 |
+
$query->setStoreId ( $data [static::STOREID] );
|
109 |
+
$error = FALSE;
|
110 |
+
if ($query->getQueryText () != '') {
|
111 |
+
|
112 |
+
$this->searchQuery ( $query );
|
113 |
+
} else {
|
114 |
+
$error = TRUE;
|
115 |
+
$totalProducts = 0;
|
116 |
+
}
|
117 |
+
// get these type of products only
|
118 |
+
$productType = array (
|
119 |
+
"simple",
|
120 |
+
"configurable"
|
121 |
+
);
|
122 |
+
if (! $error) {
|
123 |
+
$collection = Mage::getResourceModel ( 'catalogsearch/fulltext_collection' );
|
124 |
+
$collection->addAttributeToSelect ( Mage::getSingleton ( 'catalog/config' )->getProductAttributes () )->addSearchFilter ( $data [static::SEARCH_TERM] )->setstore ( $data [static::STOREID] )->addAttributeToFilter ( 'type_id', array (
|
125 |
+
'in' => $productType
|
126 |
+
) )->addStoreFilter ()->addUrlRewrite ();
|
127 |
+
$collection->addMinimalPrice ()->addFinalPrice ()->addTaxPercents ();
|
128 |
+
Mage::getSingleton ( 'catalog/product_status' )->addVisibleFilterToCollection ( $collection );
|
129 |
+
Mage::getSingleton ( 'catalog/product_visibility' )->addVisibleInSearchFilterToCollection ( $collection );
|
130 |
+
// ge products by catgory id
|
131 |
+
if ($categoryId > 0) {
|
132 |
+
$collection->getSelect ()->join ( array (
|
133 |
+
'category' => $prefix . 'catalog_category_product_index'
|
134 |
+
), 'category.product_id = cat_index.product_id and category.category_id =' . $categoryId, array () )->group ( 'e.entity_id' );
|
135 |
+
}
|
136 |
+
// set pagination
|
137 |
+
$collection->setPage ( $page, $limit );
|
138 |
+
$collection->setOrder ( 'name', 'asc' );
|
139 |
+
// get total products count
|
140 |
+
$totalProducts = $collection->getSize ();
|
141 |
+
// get total pages with limit
|
142 |
+
$last_page = ceil ( $totalProducts / $limit );
|
143 |
+
if ($last_page < $page) {
|
144 |
+
$_proudct_data = array ();
|
145 |
+
} else {
|
146 |
+
$_proudct_data = $this->getSearchCollection ( $collection, $customerId, $data [static::STOREID] );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
$response ['success'] = 1;
|
150 |
+
$response ['error'] = false;
|
151 |
+
$response ['total_count'] = $totalProducts;
|
152 |
+
$response ['result'] = $_proudct_data;
|
153 |
+
|
154 |
+
return json_encode ( $response );
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Get product detail as collection
|
159 |
+
*
|
160 |
+
* @param array $collection
|
161 |
+
* @param int $customerId
|
162 |
+
* @param int $storeId
|
163 |
+
* @return array $_proudct_data
|
164 |
+
*/
|
165 |
+
public function getSearchCollection($collection, $customerId, $storeId) {
|
166 |
+
$_proudct_data = array ();
|
167 |
+
$i = 0;
|
168 |
+
// get image size for resize
|
169 |
+
$imageSize = ( int ) $this->getRequest ()->getParam ( 'image_size' );
|
170 |
+
|
171 |
+
foreach ( $collection as $product ) {
|
172 |
+
$product->setStoreId ( $storeId )->load ( $product->getId () );
|
173 |
+
$_proudct_data [$i] ['entity_id'] = $product->getId ();
|
174 |
+
// get product name
|
175 |
+
$_proudct_data [$i] ['name'] = $product->getName ();
|
176 |
+
$_proudct_data [$i] ['type_id'] = $product->getTypeId ();
|
177 |
+
// get the product final price
|
178 |
+
if ($product->getTypeId () == 'grouped') {
|
179 |
+
$_proudct_data [$i] ['regular_price_with_tax'] = number_format ( $product->getMinimalPrice (), 2, '.', '' );
|
180 |
+
$_proudct_data [$i] ['final_price_with_tax'] = number_format ( $product->getMinimalPrice (), 2, '.', '' );
|
181 |
+
} else {
|
182 |
+
$_proudct_data [$i] ['regular_price_with_tax'] = number_format ( $product->getPrice (), 2, '.', '' );
|
183 |
+
$_proudct_data [$i] ['final_price_with_tax'] = number_format ( $product->getFinalPrice (), 2, '.', '' );
|
184 |
+
}
|
185 |
+
// get product stock details
|
186 |
+
$stockDetail = Mage::getModel ( static::LOGIN_TOKEN )->getStockDetail ( $product );
|
187 |
+
$_proudct_data [$i] [static::IS_SALABLE] = $stockDetail [static::IS_SALABLE];
|
188 |
+
$_proudct_data [$i] ['is_stock'] = $stockDetail ['is_stock'];
|
189 |
+
// get product image
|
190 |
+
// get product image
|
191 |
+
if ($imageSize <= 0) {
|
192 |
+
$_proudct_data [$i] ['image_url'] = ( string ) Mage::helper ( 'catalog/image' )->init ( $product, 'small_image' );
|
193 |
+
} else {
|
194 |
+
$_proudct_data [$i] ['image_url'] = ( string ) Mage::helper ( 'catalog/image' )->init ( $product, 'small_image' )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
195 |
+
}
|
196 |
+
|
197 |
+
// get rating
|
198 |
+
$_proudct_data [$i] ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $product->getId (), $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $product->getId (), $storeId ) : '0';
|
199 |
+
|
200 |
+
// get wishlisted products by customer
|
201 |
+
$wishListIds = array ();
|
202 |
+
if ($customerId > 0) {
|
203 |
+
$wishListIds = Mage::getModel ( static::LOGIN_TOKEN )->getWishlistByCustomer ( $customerId );
|
204 |
+
}
|
205 |
+
// Check to see the product is in wishlist
|
206 |
+
if (in_array ( $product->getId (), $wishListIds )) {
|
207 |
+
$_proudct_data [$i] ['is_wishlist'] = true;
|
208 |
+
} else {
|
209 |
+
$_proudct_data [$i] ['is_wishlist'] = false;
|
210 |
+
}
|
211 |
+
|
212 |
+
$i ++;
|
213 |
+
}
|
214 |
+
|
215 |
+
return $_proudct_data;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Search Products
|
220 |
+
*
|
221 |
+
* @param object $query
|
222 |
+
*/
|
223 |
+
public function searchQuery($query) {
|
224 |
+
$check = FALSE;
|
225 |
+
if (Mage::helper ( static::CATALOGSEARCH )->isMinQueryLength ()) {
|
226 |
+
$query->setId ( 0 )->setIsActive ( 1 )->setIsProcessed ( 1 );
|
227 |
+
} else {
|
228 |
+
if ($query->getId ()) {
|
229 |
+
$query->setPopularity ( $query->getPopularity () + 1 );
|
230 |
+
} else {
|
231 |
+
$query->setPopularity ( 1 );
|
232 |
+
}
|
233 |
+
|
234 |
+
if ($query->getRedirect ()) {
|
235 |
+
$query->save ();
|
236 |
+
$check = TRUE;
|
237 |
+
} else {
|
238 |
+
$query->prepare ();
|
239 |
+
}
|
240 |
+
}
|
241 |
+
if (! $check) {
|
242 |
+
Mage::helper ( static::CATALOGSEARCH )->checkNotes ();
|
243 |
+
if (! Mage::helper ( static::CATALOGSEARCH )->isMinQueryLength ()) {
|
244 |
+
$query->save ();
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SearchProducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest extends ContusRestapi_SearchProducts_Model_Api2_SearchProducts {
|
30 |
+
}
|
app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SearchProducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest_Admin_V1 extends ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SearchProducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest_Customer_V1 extends ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SearchProducts/Model/Api2/SearchProducts/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SearchProducts
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest_Guest_V1 extends ContusRestapi_SearchProducts_Model_Api2_SearchProducts_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SearchProducts/etc/api2.xml
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="SearchProducts">
|
6 |
+
<title>Search Products</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<searchProducts translate="title" module="SearchProducts">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>searchProducts/api2_searchProducts</model>
|
14 |
+
<title>Search Products</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
<delete>1</delete>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<create>1</create>
|
29 |
+
<retrieve>1</retrieve>
|
30 |
+
<delete>1</delete>
|
31 |
+
</guest>
|
32 |
+
</privileges>
|
33 |
+
<attributes module="api2">
|
34 |
+
<website_id>websiteid</website_id>
|
35 |
+
<store_id>Associate to Store</store_id>
|
36 |
+
<category_id>Category Id</category_id>
|
37 |
+
<search_term>Search Word</search_term>
|
38 |
+
<page>page</page>
|
39 |
+
<limit>Limit</limit>
|
40 |
+
<result>Search Result</result>
|
41 |
+
<count>Page Count</count>
|
42 |
+
<total_products>Total Products Count</total_products>
|
43 |
+
</attributes>
|
44 |
+
<routes>
|
45 |
+
<route_collection>
|
46 |
+
<route>/search/products/</route>
|
47 |
+
<action_type>collection</action_type>
|
48 |
+
</route_collection>
|
49 |
+
</routes>
|
50 |
+
<versions>1</versions>
|
51 |
+
</searchProducts>
|
52 |
+
|
53 |
+
</resources>
|
54 |
+
</api2>
|
55 |
+
</config>
|
app/code/local/ContusRestapi/SearchProducts/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_SearchProducts>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_SearchProducts>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<searchProducts>
|
11 |
+
<class>ContusRestapi_SearchProducts_Model</class>
|
12 |
+
</searchProducts>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ShippingPaymentapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi extends Mage_Api2_Model_Resource {
|
30 |
+
|
31 |
+
// define static variables
|
32 |
+
const MESSAGE = 'message';
|
33 |
+
const SUCCESS = 'success';
|
34 |
+
/**
|
35 |
+
* Add Ahipping and Payment Methods to cart quote
|
36 |
+
*
|
37 |
+
* @return array json array
|
38 |
+
*/
|
39 |
+
protected function _create(array $data) {
|
40 |
+
$response = array ();
|
41 |
+
|
42 |
+
// get website id
|
43 |
+
$websiteId = ( int ) $data ['website_id'];
|
44 |
+
if ($websiteId <= 0) {
|
45 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
46 |
+
}
|
47 |
+
// get customer id
|
48 |
+
$customerId = ( int ) $data ['customer_id'];
|
49 |
+
// get quote id
|
50 |
+
$quoteId = ( int ) $data ['quote_id'];
|
51 |
+
// get website id from request
|
52 |
+
$storeId = ( int ) $data ['store_id'];
|
53 |
+
if ($storeId <= 0) {
|
54 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* Check this customer has valid token or not
|
58 |
+
*
|
59 |
+
* @var $isValidToken Mage_Login_Model_Token
|
60 |
+
*/
|
61 |
+
$isValidToken = Mage::getModel ( 'login/token' )->checkUserToken ( $customerId, $data ['token'] );
|
62 |
+
if ($quoteId) {
|
63 |
+
|
64 |
+
try {
|
65 |
+
|
66 |
+
$quote = Mage::getModel ( 'sales/quote' );
|
67 |
+
$quote->setStoreId ( $storeId )->load ( $quoteId );
|
68 |
+
$active = $quote->getIsActive ();
|
69 |
+
if (! $active) {
|
70 |
+
throw new Exception ( 'Quote is invalid!.' );
|
71 |
+
}
|
72 |
+
|
73 |
+
if (! $isValidToken) {
|
74 |
+
throw new Exception ( 'Authentication failed.' );
|
75 |
+
}
|
76 |
+
// set shipping method
|
77 |
+
|
78 |
+
$quote->getShippingAddress ()->setShippingMethod ( $data ['shipping_method'] );
|
79 |
+
$quote->getShippingAddress ()->setCollectShippingRates ( TRUE );
|
80 |
+
$quote->getShippingAddress ()->collectShippingRates ();
|
81 |
+
|
82 |
+
// Set Payment method
|
83 |
+
// Mage_Sales_Model_Quote_Payment
|
84 |
+
$quotePaymentObj = $quote->getPayment ();
|
85 |
+
$quotePaymentObj->setMethod ( $data ['payment_method'] );
|
86 |
+
$quote->setPayment ( $quotePaymentObj );
|
87 |
+
|
88 |
+
$quote->collectTotals ();
|
89 |
+
$quote->save ();
|
90 |
+
$response [static::SUCCESS] = 1;
|
91 |
+
$response [static::MESSAGE] = 'Shipping and payment methods added successfully.';
|
92 |
+
} catch ( exception $e ) {
|
93 |
+
$response [static::SUCCESS] = 0;
|
94 |
+
$response [static::MESSAGE] = $e->getMessage ();
|
95 |
+
}
|
96 |
+
} else {
|
97 |
+
$response [static::SUCCESS] = 0;
|
98 |
+
$response [static::MESSAGE] = "Quote id not exist.";
|
99 |
+
}
|
100 |
+
$response ['isValidToken'] = $isValidToken;
|
101 |
+
$response ['error'] = false;
|
102 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
103 |
+
return;
|
104 |
+
}
|
105 |
+
}
|
app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ShippingPaymentapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest extends ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi {
|
30 |
+
}
|
app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ShippingPaymentapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest_Admin_V1 extends ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ShippingPaymentapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest_Customer_V1 extends ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ShippingPaymentapi/Model/Api2/ShippingPaymentapi/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_ShippingPaymentapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest_Guest_V1 extends ContusRestapi_ShippingPaymentapi_Model_Api2_ShippingPaymentapi_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/ShippingPaymentapi/etc/api2.xml
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="ShippingPaymentapi">
|
6 |
+
<title>Home Page API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<shippingPaymentapi translate="title" module="ShippingPaymentapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>shippingPaymentapi/api2_shippingPaymentapi</model>
|
14 |
+
<title>Home api</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
</customer>
|
26 |
+
<guest>
|
27 |
+
<create>1</create>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes module="api2">
|
32 |
+
<website_id>websiteid</website_id>
|
33 |
+
<store_id>Associate to Store</store_id>
|
34 |
+
<quote_id>Shopping cart Id</quote_id>
|
35 |
+
<shipping_method>Shipping Method</shipping_method>
|
36 |
+
<payment_method>Payment Method</payment_method>
|
37 |
+
<status>status</status>
|
38 |
+
<message>message</message>
|
39 |
+
<token>Token</token>
|
40 |
+
<customer_id>Customer Id</customer_id>
|
41 |
+
</attributes>
|
42 |
+
<routes>
|
43 |
+
<route_collection>
|
44 |
+
<route>/shippingpaymentapi/</route>
|
45 |
+
<action_type>collection</action_type>
|
46 |
+
</route_collection>
|
47 |
+
|
48 |
+
<custom_cart_payment_save>
|
49 |
+
<route>/cart/add_shipping_payment/</route>
|
50 |
+
<action_type>collection</action_type>
|
51 |
+
</custom_cart_payment_save>
|
52 |
+
</routes>
|
53 |
+
<versions>1</versions>
|
54 |
+
</shippingPaymentapi>
|
55 |
+
|
56 |
+
</resources>
|
57 |
+
</api2>
|
58 |
+
</config>
|
app/code/local/ContusRestapi/ShippingPaymentapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ShippingPaymentapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_ShippingPaymentapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<shippingPaymentapi>
|
11 |
+
<class>ContusRestapi_ShippingPaymentapi_Model</class>
|
12 |
+
</shippingPaymentapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin.php
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Forgotpassword API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_SocialLogin
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_SocialLogin_Model_Api2_SocialLogin extends Mage_Api2_Model_Resource {
|
32 |
+
const FIRSTNAME = 'firstname';
|
33 |
+
const LASTNAME = 'lastname';
|
34 |
+
const LOGIN_TOKEN = 'login/token';
|
35 |
+
const RESULT = 'result';
|
36 |
+
const ENTITY_ID = 'entity_id';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* function that is called when post is done **
|
40 |
+
*
|
41 |
+
* Register or login via Social networks
|
42 |
+
*
|
43 |
+
* @param array $data
|
44 |
+
*
|
45 |
+
* @return array json array
|
46 |
+
*/
|
47 |
+
protected function _create(array $data) {
|
48 |
+
$response = array ();
|
49 |
+
// get newsletter value for customer
|
50 |
+
if ($data ['newsletter']) {
|
51 |
+
$newsletterid = $data ['newsletter'];
|
52 |
+
} else {
|
53 |
+
$newsletterid = 0;
|
54 |
+
}
|
55 |
+
// get website id
|
56 |
+
if ($data ['website_id']) {
|
57 |
+
$websiteId = $data ['website_id'];
|
58 |
+
} else {
|
59 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
60 |
+
}
|
61 |
+
// get store id
|
62 |
+
if ($data ['store_id']) {
|
63 |
+
$storeId = $data ['store_id'];
|
64 |
+
} else {
|
65 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
66 |
+
}
|
67 |
+
$dob = $data ['dob'];
|
68 |
+
// set currnet store id
|
69 |
+
Mage::app ()->setCurrentStore ( $storeId );
|
70 |
+
$email = $data ['email'];
|
71 |
+
// getting the device token
|
72 |
+
$deviceToken = $data ['device_token'];
|
73 |
+
// getting the device type
|
74 |
+
$deviceType = $data ['device_type'];
|
75 |
+
|
76 |
+
/**
|
77 |
+
*
|
78 |
+
* @var $customer Mage_Customer_Model_Customer
|
79 |
+
*/
|
80 |
+
$customer = Mage::getModel ( 'customer/customer' );
|
81 |
+
$customer->setWebsiteId ( $websiteId );
|
82 |
+
$customer->loadByEmail ( $email );
|
83 |
+
if ($customer->getId ()) {
|
84 |
+
try {
|
85 |
+
|
86 |
+
$response [static::RESULT] = Mage::getModel ( static::LOGIN_TOKEN )->getCustomerDetail ( $customer->getId () );
|
87 |
+
$response [static::RESULT] ['token'] = $this->getToken ( $customer->getId () );
|
88 |
+
$result [static::RESULT] ['cart_count'] = Mage::getModel ( static::LOGIN_TOKEN )->getCartCount ( $customer->getId (), $storeId );
|
89 |
+
// Update device token and type in token table
|
90 |
+
Mage::getModel ( 'login/methods_functions' )->updateDeviceToken ( $customer->getId (), $deviceToken, $deviceType );
|
91 |
+
|
92 |
+
$message = 'You have successfully logged in.';
|
93 |
+
$success = 1;
|
94 |
+
} catch ( Exception $e ) {
|
95 |
+
$message = $e->getMessage ();
|
96 |
+
$success = 0;
|
97 |
+
}
|
98 |
+
} else {
|
99 |
+
|
100 |
+
try {
|
101 |
+
// If customer email is not found, create as a new customer
|
102 |
+
// create password for customer
|
103 |
+
$password = $this->generatePassword ( 6 );
|
104 |
+
$customer->setEmail ( $email );
|
105 |
+
$customer->setFirstname ( $data [static::FIRSTNAME] );
|
106 |
+
$customer->setLastname ( $data [static::LASTNAME] );
|
107 |
+
$customer->setPassword ( $password );
|
108 |
+
$customer->setWebsiteId ( $websiteId );
|
109 |
+
$customer->setStoreId ( $storeId );
|
110 |
+
$customer->setDob ( $dob );
|
111 |
+
// set newsletter subscription for customer
|
112 |
+
$customer->setIsSubscribed ( $newsletterid );
|
113 |
+
|
114 |
+
$customer->save ();
|
115 |
+
// get customer data
|
116 |
+
$customerData = $customer->getData ();
|
117 |
+
|
118 |
+
$response [static::RESULT] = Mage::getModel ( static::LOGIN_TOKEN )->getCustomerDetail ( $customerData [static::ENTITY_ID] );
|
119 |
+
$response [static::RESULT] ['token'] = $this->getToken ( $customer->getId () );
|
120 |
+
$result [static::RESULT] ['cart_count'] = Mage::getModel ( static::LOGIN_TOKEN )->getCartCount ( $customerData [static::ENTITY_ID], $storeId );
|
121 |
+
// Update device token and type in token table
|
122 |
+
Mage::getModel ( 'login/methods_functions' )->updateDeviceToken ( $customerData [static::ENTITY_ID], $deviceToken, $deviceType );
|
123 |
+
|
124 |
+
$message = 'You have successfully logged in.';
|
125 |
+
$success = 1;
|
126 |
+
// send confirmation email to customer
|
127 |
+
$customer->sendNewAccountEmail ();
|
128 |
+
} catch ( Exception $e ) {
|
129 |
+
$message = $e->getMessage ();
|
130 |
+
$success = 0;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
$response ['error'] = false;
|
134 |
+
$response ['success'] = $success;
|
135 |
+
$response ["message"] = $message;
|
136 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Generate random password for customers login by Social network like facebook,twiter,etc,
|
142 |
+
*
|
143 |
+
* @param string $length
|
144 |
+
* Length for password
|
145 |
+
*
|
146 |
+
* @return string $password as password
|
147 |
+
*/
|
148 |
+
public function generatePassword($length) {
|
149 |
+
$chars = "1234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
150 |
+
$i = 0;
|
151 |
+
$password = "";
|
152 |
+
while ( $i <= $length ) {
|
153 |
+
$password .= $chars {mt_rand ( 0, strlen ( $chars ) )};
|
154 |
+
$i ++;
|
155 |
+
}
|
156 |
+
return $password;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* create token and assign to customer
|
161 |
+
*
|
162 |
+
* @param int $customerId
|
163 |
+
*
|
164 |
+
* @return string $tokenvalue
|
165 |
+
*/
|
166 |
+
public function getToken($customerId) {
|
167 |
+
try {
|
168 |
+
$tokenvalue = Mage::getModel ( static::LOGIN_TOKEN )->getRandomString ( 6 );
|
169 |
+
$tokenObj = Mage::getModel ( static::LOGIN_TOKEN )->load ( $customerId, 'userid' );
|
170 |
+
$tokenObj->setUserid ( $customerId );
|
171 |
+
$tokenObj->setToken ( $tokenvalue );
|
172 |
+
$tokenObj->setCreated ( date ( 'Y-m-d H:i:s' ) );
|
173 |
+
$tokenObj->setStatus ( 1 );
|
174 |
+
$tokenObj->save ();
|
175 |
+
} catch ( Exception $e ) {
|
176 |
+
$tokenvalue = $e->getMessage ();
|
177 |
+
}
|
178 |
+
return $tokenvalue;
|
179 |
+
}
|
180 |
+
}
|
app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SocialLogin
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest extends ContusRestapi_SocialLogin_Model_Api2_SocialLogin {
|
30 |
+
}
|
app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SocialLogin
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest_Admin_V1 extends ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SocialLogin
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest_Customer_V1 extends ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SocialLogin/Model/Api2/SocialLogin/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_SocialLogin
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest_Guest_V1 extends ContusRestapi_SocialLogin_Model_Api2_SocialLogin_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/SocialLogin/etc/api2.xml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="SocialLogin">
|
6 |
+
<title>Social Login API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<socialLogin translate="title" module="SocialLogin">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>socialLogin/api2_socialLogin</model>
|
14 |
+
<title>Customer Login</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
<delete>1</delete>
|
26 |
+
</customer>
|
27 |
+
<guest>
|
28 |
+
<create>1</create>
|
29 |
+
<retrieve>1</retrieve>
|
30 |
+
<delete>1</delete>
|
31 |
+
</guest>
|
32 |
+
</privileges>
|
33 |
+
<attributes module="api2">
|
34 |
+
<email>email</email>
|
35 |
+
<website_id>websiteid</website_id>
|
36 |
+
<customer_id>Customer Id</customer_id>
|
37 |
+
<firstname>First Name</firstname>
|
38 |
+
<lastname>Last Name</lastname>
|
39 |
+
<created_in>Created From</created_in>
|
40 |
+
<group_id>Group</group_id>
|
41 |
+
<confirmation>Is Confirmed</confirmation>
|
42 |
+
<store_id>Associate to Store</store_id>
|
43 |
+
<disable_auto_group_change>Disable automatic group change based on
|
44 |
+
VAT ID</disable_auto_group_change>
|
45 |
+
<social_network>Social Network</social_network>
|
46 |
+
<newsletter>Newsletter Subscribe</newsletter>
|
47 |
+
<success>Success</success>
|
48 |
+
<message>Message</message>
|
49 |
+
<error>Error</error>
|
50 |
+
<device_token>Device Token</device_token>
|
51 |
+
<device_type>Device Type</device_type>
|
52 |
+
</attributes>
|
53 |
+
<routes>
|
54 |
+
<route_collection>
|
55 |
+
<route>/customer/social_login/</route>
|
56 |
+
<action_type>collection</action_type>
|
57 |
+
</route_collection>
|
58 |
+
</routes>
|
59 |
+
<versions>1</versions>
|
60 |
+
</socialLogin>
|
61 |
+
|
62 |
+
</resources>
|
63 |
+
</api2>
|
64 |
+
</config>
|
app/code/local/ContusRestapi/SocialLogin/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_SocialLogin>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_SocialLogin>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<socialLogin>
|
11 |
+
<class>ContusRestapi_SocialLogin_Model</class>
|
12 |
+
</socialLogin>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Forgotpassword API
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Staticpages
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Staticpages_Model_Api2_Staticpages extends Mage_Api2_Model_Resource {
|
32 |
+
const CONTENT = 'content';
|
33 |
+
const MESSAGE = 'message';
|
34 |
+
const SUCCESS = 'success';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* function that is called when post is done **
|
38 |
+
*
|
39 |
+
* Get Static pages
|
40 |
+
*
|
41 |
+
* @return array json array
|
42 |
+
*/
|
43 |
+
protected function _retrieve() {
|
44 |
+
$response = array ();
|
45 |
+
|
46 |
+
// get website id from request
|
47 |
+
$websiteId = $this->getRequest ()->getParam ( 'website_id' );
|
48 |
+
if (! isset ( $websiteId ) && $websiteId == '') {
|
49 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
50 |
+
}
|
51 |
+
|
52 |
+
// get store id from request
|
53 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( 'store_id' );
|
54 |
+
if (! isset ( $storeId ) && $storeId == '') {
|
55 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
56 |
+
}
|
57 |
+
$pageKey = $this->getRequest ()->getParam ( 'page_key' );
|
58 |
+
|
59 |
+
// get cms page content based on store id and page_key
|
60 |
+
if ($pageKey) {
|
61 |
+
$collection = Mage::getModel ( 'cms/page' )->getCollection ()->addStoreFilter ( $storeId )->addFieldToFilter ( 'is_active', 1 )->addFieldToFilter ( 'identifier', $pageKey );
|
62 |
+
foreach ( $collection as $content ) {
|
63 |
+
$content = Mage::helper ( 'cms' )->getPageTemplateProcessor ()->filter ( $content->getContent () );
|
64 |
+
$response [static::CONTENT] = htmlentities ( $content );
|
65 |
+
$response [static::SUCCESS] = 1;
|
66 |
+
}
|
67 |
+
} else {
|
68 |
+
$response [static::MESSAGE] = 'No Data Available';
|
69 |
+
$response [static::SUCCESS] = 0;
|
70 |
+
}
|
71 |
+
if (empty ( $response )) {
|
72 |
+
$response [static::MESSAGE] = 'No Data Available';
|
73 |
+
$response [static::SUCCESS] = 0;
|
74 |
+
}
|
75 |
+
$response ['error'] = false;
|
76 |
+
return json_encode ( $response );
|
77 |
+
}
|
78 |
+
}
|
app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Staticpages
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest extends ContusRestapi_Staticpages_Model_Api2_Staticpages {
|
30 |
+
}
|
app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Staticpages
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest_Admin_V1 extends ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Staticpages
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest_Customer_V1 extends ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Staticpages/Model/Api2/Staticpages/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Staticpages
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest_Guest_V1 extends ContusRestapi_Staticpages_Model_Api2_Staticpages_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Staticpages/etc/api2.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="Staticpages">
|
6 |
+
<title>Static Pages API Module</title>
|
7 |
+
<sort_order>10</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<staticpages translate="title" module="Staticpages">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>staticpages/api2_staticpages</model>
|
14 |
+
<title>Static Pages</title>
|
15 |
+
<sort_order>10</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
</admin>
|
22 |
+
<customer>
|
23 |
+
<create>1</create>
|
24 |
+
<retrieve>1</retrieve>
|
25 |
+
</customer>
|
26 |
+
<guest>
|
27 |
+
<create>1</create>
|
28 |
+
<retrieve>1</retrieve>
|
29 |
+
</guest>
|
30 |
+
</privileges>
|
31 |
+
<attributes module="api2">
|
32 |
+
<website_id>websiteid</website_id>
|
33 |
+
<store_id>Associate to Store</store_id>
|
34 |
+
<page_key>Static Page Url Key</page_key>
|
35 |
+
</attributes>
|
36 |
+
<routes>
|
37 |
+
<route_collection>
|
38 |
+
<route>/staticpages/</route>
|
39 |
+
<action_type>entity</action_type>
|
40 |
+
</route_collection>
|
41 |
+
</routes>
|
42 |
+
<versions>1</versions>
|
43 |
+
</staticpages>
|
44 |
+
|
45 |
+
</resources>
|
46 |
+
</api2>
|
47 |
+
</config>
|
app/code/local/ContusRestapi/Staticpages/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Staticpages>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_Staticpages>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<staticpages>
|
11 |
+
<class>ContusRestapi_Staticpages_Model</class>
|
12 |
+
</staticpages>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist.php
ADDED
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* Wishlist Products
|
6 |
+
*
|
7 |
+
* NOTICE OF LICENSE
|
8 |
+
*
|
9 |
+
* This source file is subject to the EULA
|
10 |
+
* that is bundled with this package in the file LICENSE.txt.
|
11 |
+
* It is also available through the world-wide-web at this URL:
|
12 |
+
* http://www.apptha.com/LICENSE.txt
|
13 |
+
*
|
14 |
+
* ==============================================================
|
15 |
+
* MAGENTO EDITION USAGE NOTICE
|
16 |
+
* ==============================================================
|
17 |
+
* This package designed for Magento COMMUNITY edition
|
18 |
+
* Apptha does not guarantee correct work of this extension
|
19 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
20 |
+
* Apptha does not provide extension support in case of
|
21 |
+
* incorrect edition usage.
|
22 |
+
* ==============================================================
|
23 |
+
*
|
24 |
+
* @category Contus
|
25 |
+
* @package ContusRestapi_Wishlistapi
|
26 |
+
* @author Contus Team <developers@contus.in>
|
27 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
28 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
29 |
+
* @since 1.0
|
30 |
+
*/
|
31 |
+
class ContusRestapi_Wishlistapi_Model_Api2_Wishlist extends Mage_Api2_Model_Resource {
|
32 |
+
|
33 |
+
// define static variable.
|
34 |
+
const STOREID = 'store_id';
|
35 |
+
const WEBSITEID = 'website_id';
|
36 |
+
const CUSTOMER_ID = 'customer_id';
|
37 |
+
const ADDED_AT = 'added_at';
|
38 |
+
const PRODUCT_ID = 'product_id';
|
39 |
+
const IS_SALABLE = 'is_saleable';
|
40 |
+
const QTY = 'qty';
|
41 |
+
const SUCCESS = 'success';
|
42 |
+
const MESSAGE = 'message';
|
43 |
+
const ERROR = 'error';
|
44 |
+
const RESULT = 'result';
|
45 |
+
const TOKEN = 'token';
|
46 |
+
const LOGIN_TOKEN = 'login/token';
|
47 |
+
const VALID_TOKEN = 'isValidToken';
|
48 |
+
const AUTH_FAIL = 'Authentication failed.';
|
49 |
+
const TOTAL_COUNT = 'total_count';
|
50 |
+
const WISHLIST_ITEM = 'wishlist/item';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Add product to customer wishlist
|
54 |
+
*
|
55 |
+
* @param array $data
|
56 |
+
* @return array json array
|
57 |
+
*/
|
58 |
+
protected function _create(array $data) {
|
59 |
+
$response = array ();
|
60 |
+
|
61 |
+
$websiteId = ( int ) $data [static::WEBSITEID];
|
62 |
+
if ($websiteId <= 0) {
|
63 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
64 |
+
}
|
65 |
+
// get store id from request
|
66 |
+
$storeId = ( int ) $data [static::STOREID];
|
67 |
+
if ($storeId <= 0) {
|
68 |
+
Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
69 |
+
}
|
70 |
+
// get customer id
|
71 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
72 |
+
// get product Id from request
|
73 |
+
$productId = ( int ) $data [static::PRODUCT_ID];
|
74 |
+
|
75 |
+
// get token value from request
|
76 |
+
$token = $data [static::TOKEN];
|
77 |
+
$qty = ( int ) $data [static::QTY];
|
78 |
+
if ($qty <= 0) {
|
79 |
+
$qty = 1;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Check this customer has valid token or not
|
84 |
+
*
|
85 |
+
* @var $isValidToken Mage_Login_Model_Token
|
86 |
+
*/
|
87 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
88 |
+
|
89 |
+
if ($isValidToken) {
|
90 |
+
|
91 |
+
Mage::app ()->setCurrentStore ( $storeId );
|
92 |
+
// load wishlist model by customer id
|
93 |
+
$wishlist = Mage::getModel ( 'wishlist/wishlist' )->loadByCustomer ( $customerId, true );
|
94 |
+
// load product model by product id
|
95 |
+
$product = Mage::getModel ( 'catalog/product' )->load ( $productId );
|
96 |
+
// any possible options that are configurable and you want to save with the product
|
97 |
+
$requestParams = array (
|
98 |
+
'product' => $productId,
|
99 |
+
static::QTY => $qty,
|
100 |
+
static::STOREID => $storeId
|
101 |
+
);
|
102 |
+
$buyRequest = new Varien_Object ( $requestParams );
|
103 |
+
|
104 |
+
try {
|
105 |
+
$wishlist->addNewItem ( $product, $buyRequest );
|
106 |
+
$wishlist->save ();
|
107 |
+
if ($wishlist->save ()) {
|
108 |
+
$success = 1;
|
109 |
+
$add_message = "Product added to wishlist successfully.";
|
110 |
+
} else {
|
111 |
+
$success = 0;
|
112 |
+
$add_message = "Sorry, we're unable to add the product to wishlist.";
|
113 |
+
}
|
114 |
+
} catch ( Exception $e ) {
|
115 |
+
$success = 0;
|
116 |
+
$add_message = $e->getMessage ();
|
117 |
+
}
|
118 |
+
} else {
|
119 |
+
$success = 0;
|
120 |
+
$add_message = static::AUTH_FAIL;
|
121 |
+
}
|
122 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
123 |
+
$response [static::ERROR] = false;
|
124 |
+
$response [static::SUCCESS] = $success;
|
125 |
+
$response [static::MESSAGE] = $add_message;
|
126 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
127 |
+
return;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Retrieve Wishlist products collection
|
132 |
+
*
|
133 |
+
* @param integer $customerId
|
134 |
+
* @return array json array
|
135 |
+
*/
|
136 |
+
protected function _retrieveCollection() {
|
137 |
+
$response = array ();
|
138 |
+
|
139 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
140 |
+
// get website id from request
|
141 |
+
$websiteId = ( int ) $this->getRequest ()->getParam ( static::WEBSITEID );
|
142 |
+
// get store id from request
|
143 |
+
$storeId = ( int ) $this->getRequest ()->getParam ( static::STOREID );
|
144 |
+
if ($websiteId <= 0) {
|
145 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
146 |
+
}
|
147 |
+
if ($storeId <= 0) {
|
148 |
+
Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
149 |
+
}
|
150 |
+
|
151 |
+
// get page no
|
152 |
+
$page = ( int ) $this->getRequest ()->getParam ( 'page' );
|
153 |
+
if ($page <= 0) {
|
154 |
+
$page = 1;
|
155 |
+
}
|
156 |
+
// get page limit
|
157 |
+
$limit = ( int ) $this->getRequest ()->getParam ( 'limit' );
|
158 |
+
if ($limit <= 0) {
|
159 |
+
$limit = 20;
|
160 |
+
}
|
161 |
+
// get image size for resize
|
162 |
+
$imageSize = ( int ) $this->getRequest ()->getParam ( 'image_size' );
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Check this customer has valid token or not
|
166 |
+
*
|
167 |
+
* @var $isValidToken Mage_Login_Model_Token
|
168 |
+
*/
|
169 |
+
$token = $this->getRequest ()->getParam ( static::TOKEN );
|
170 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
171 |
+
if ($isValidToken) {
|
172 |
+
|
173 |
+
$wishlistProducts = $this->getWishlistProducts ( $storeId, $customerId, $page, $limit, $imageSize );
|
174 |
+
$result = $wishlistProducts [static::RESULT];
|
175 |
+
$totalCount = $wishlistProducts [static::TOTAL_COUNT];
|
176 |
+
$response [static::SUCCESS] = 1;
|
177 |
+
$response [static::ERROR] = false;
|
178 |
+
} else {
|
179 |
+
$result = array ();
|
180 |
+
$response [static::ERROR] = true;
|
181 |
+
$response [static::SUCCESS] = 0;
|
182 |
+
$totalCount = 0;
|
183 |
+
$response [static::MESSAGE] = static::AUTH_FAIL;
|
184 |
+
}
|
185 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
186 |
+
$response [static::TOTAL_COUNT] = $totalCount;
|
187 |
+
$response [static::RESULT] = $result;
|
188 |
+
return json_encode ( $response );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Get wislist products by customer account.
|
193 |
+
*
|
194 |
+
* @param integer $storeId
|
195 |
+
* @param int $customerId
|
196 |
+
* @param int $page
|
197 |
+
* @param int $limit
|
198 |
+
* @return array result
|
199 |
+
*/
|
200 |
+
public function getWishlistProducts($storeId, $customerId, $page, $limit, $imageSize) {
|
201 |
+
$result = array ();
|
202 |
+
$products = array ();
|
203 |
+
|
204 |
+
// get wishlist item collection based on customer id
|
205 |
+
$itemCollection = Mage::getModel ( static::WISHLIST_ITEM )->getCollection ()->addCustomerIdFilter ( $customerId );
|
206 |
+
|
207 |
+
// set items on descending order based on prodcut added to wishlist date
|
208 |
+
$itemCollection = $itemCollection->setOrder ( static::ADDED_AT, 'DESC' );
|
209 |
+
// get total products count
|
210 |
+
$totalProducts = $itemCollection->getSize ();
|
211 |
+
// set page
|
212 |
+
$itemCollection = $itemCollection->setCurPage ( $page );
|
213 |
+
// 10 elements per pages
|
214 |
+
$itemCollection = $itemCollection->setPageSize ( $limit );
|
215 |
+
// get total pages with limit
|
216 |
+
$last_page = ceil ( $totalProducts / $limit );
|
217 |
+
if ($last_page < $page) {
|
218 |
+
$result [static::TOTAL_COUNT] = 0;
|
219 |
+
$result ['result'] = array ();
|
220 |
+
} else {
|
221 |
+
$i = 0;
|
222 |
+
foreach ( $itemCollection as $item ) {
|
223 |
+
$_product = Mage::getModel ( 'catalog/product' )->load ( $item ['product_id'] );
|
224 |
+
$_product->setStoreId ( $storeId )->load ( $_product->getId () );
|
225 |
+
|
226 |
+
// get only enabled products
|
227 |
+
if ($_product->getId () != '') {
|
228 |
+
// get product id
|
229 |
+
$products [$i] ['entity_id'] = $_product->getId ();
|
230 |
+
$products [$i] ['type_id'] = $_product->getTypeId ();
|
231 |
+
// get product name
|
232 |
+
$products [$i] ['name'] = $_product->getName ();
|
233 |
+
// get product small image url
|
234 |
+
$products [$i] ['image_url'] = $this->resizeImage ( $_product, $imageSize );
|
235 |
+
|
236 |
+
// get the product final price
|
237 |
+
$products [$i] ['regular_price_with_tax'] = number_format ( $_product->getPrice (), 2, '.', '' );
|
238 |
+
$products [$i] ['final_price_with_tax'] = number_format ( $_product->getFinalPrice (), 2, '.', '' );
|
239 |
+
|
240 |
+
$stockDetail = Mage::getModel ( static::LOGIN_TOKEN )->getStockDetail ( $_product );
|
241 |
+
$products [$i] [static::IS_SALABLE] = $stockDetail [static::IS_SALABLE];
|
242 |
+
$products [$i] ['is_stock'] = $stockDetail ['is_stock'];
|
243 |
+
|
244 |
+
$products [$i] ['summary_rating'] = Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $_product->getId (), $storeId ) ? Mage::getModel ( static::LOGIN_TOKEN )->rateSummary ( $_product->getId (), $storeId ) : '0';
|
245 |
+
|
246 |
+
// get prodcut added date
|
247 |
+
$products [$i] ['added_date'] = date ( "d-m-Y", strtotime ( $item [static::ADDED_AT] ) );
|
248 |
+
|
249 |
+
$i ++;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
$result [static::TOTAL_COUNT] = $totalProducts;
|
253 |
+
$result [static::RESULT] = $products;
|
254 |
+
}
|
255 |
+
return $result;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Products Rating
|
260 |
+
*
|
261 |
+
* @param int $id
|
262 |
+
* Getting the particular product id
|
263 |
+
*
|
264 |
+
* @return array as json message as string and success rate count
|
265 |
+
*/
|
266 |
+
public function rateSummary($id) {
|
267 |
+
// getting rate model
|
268 |
+
$summaryData = Mage::getModel ( 'review/review_summary' )->load ( $id )->getRatingSummary ();
|
269 |
+
// calculate overage for ratings
|
270 |
+
return $summaryData / 20;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Remove product from cstomer wishlist.
|
275 |
+
*
|
276 |
+
* @param integer $productId
|
277 |
+
* @param int $customerId
|
278 |
+
* @return array result
|
279 |
+
*/
|
280 |
+
protected function _delete() {
|
281 |
+
|
282 |
+
// get product id from request
|
283 |
+
$productId = ( int ) $this->getRequest ()->getParam ( static::PRODUCT_ID );
|
284 |
+
|
285 |
+
// get customer id from request
|
286 |
+
$customerId = ( int ) $this->getRequest ()->getParam ( static::CUSTOMER_ID );
|
287 |
+
// Get website id
|
288 |
+
$websiteId = $this->getRequest ()->getParam ( static::WEBSITEID );
|
289 |
+
// get store id
|
290 |
+
$storeId = $this->getRequest ()->getParam ( static::STOREID );
|
291 |
+
|
292 |
+
$websiteId = (isset ( $websiteId )) ? $websiteId : Mage::app ()->getWebsite ( 'base' )->getId ();
|
293 |
+
$storeId = (isset ( $storeId )) ? $storeId : Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
294 |
+
|
295 |
+
$response = array ();
|
296 |
+
// get wishlist item collection based on customer id
|
297 |
+
$itemCollection = Mage::getModel ( static::WISHLIST_ITEM )->getCollection ()->addCustomerIdFilter ( $customerId );
|
298 |
+
$itemCollection = $itemCollection->setOrder ( static::ADDED_AT, 'DESC' );
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Check this customer has valid token or not
|
302 |
+
*
|
303 |
+
* @var $isValidToken Mage_Login_Model_Token
|
304 |
+
*/
|
305 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $this->getRequest ()->getParam ( static::TOKEN ) );
|
306 |
+
if ($isValidToken) {
|
307 |
+
try {
|
308 |
+
$result = $this->deleteWishlist ( $itemCollection, $productId );
|
309 |
+
|
310 |
+
$success = $result [static::SUCCESS];
|
311 |
+
$message = $result [static::MESSAGE];
|
312 |
+
} catch ( Exception $e ) {
|
313 |
+
$success = 0;
|
314 |
+
$message = "Sorry, we're unable to remove the product from wishlist.";
|
315 |
+
}
|
316 |
+
} else {
|
317 |
+
$success = 0;
|
318 |
+
$message = static::AUTH_FAIL;
|
319 |
+
}
|
320 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
321 |
+
$response [static::ERROR] = false;
|
322 |
+
$response [static::SUCCESS] = $success;
|
323 |
+
$response [static::MESSAGE] = $message;
|
324 |
+
|
325 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
326 |
+
return;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Delete Product from wishlist collection
|
331 |
+
*
|
332 |
+
* @param object $item
|
333 |
+
* @param int $itemId
|
334 |
+
* @param int $productId
|
335 |
+
* @return array :number string
|
336 |
+
*/
|
337 |
+
public function deleteWishlist($itemCollection, $productId) {
|
338 |
+
$result = array ();
|
339 |
+
$delete = false;
|
340 |
+
foreach ( $itemCollection as $item ) {
|
341 |
+
|
342 |
+
if ($item->getProduct ()->getId () == $productId) {
|
343 |
+
// delete product from wishlist
|
344 |
+
$item->delete ();
|
345 |
+
if ($item->delete ()) {
|
346 |
+
$success = 1;
|
347 |
+
$message = "Product deleted from wishlist successfully.";
|
348 |
+
} else {
|
349 |
+
$success = 0;
|
350 |
+
$message = "Sorry, we're unable to remove the product from wishlist.";
|
351 |
+
}
|
352 |
+
$delete = true;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
if (! $delete) {
|
356 |
+
$success = 0;
|
357 |
+
$message = "Item is not available. ";
|
358 |
+
}
|
359 |
+
$result [static::SUCCESS] = $success;
|
360 |
+
$result [static::MESSAGE] = $message;
|
361 |
+
return $result;
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Resize product image
|
366 |
+
*
|
367 |
+
* @param object $_product
|
368 |
+
* @param int $imageSize
|
369 |
+
* @return string $image
|
370 |
+
*/
|
371 |
+
public function resizeImage($_product, $imageSize) {
|
372 |
+
if ($imageSize <= 0) {
|
373 |
+
$image = ( string ) Mage::helper ( 'catalog/image' )->init ( $_product, 'small_image' );
|
374 |
+
} else {
|
375 |
+
$image = ( string ) Mage::helper ( 'catalog/image' )->init ( $_product, 'small_image' )->constrainOnly ( TRUE )->keepAspectRatio ( TRUE )->keepFrame ( FALSE )->resize ( $imageSize, null );
|
376 |
+
}
|
377 |
+
return $image;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* function that is called when put is done **
|
382 |
+
* Remove all products from customer wishlist
|
383 |
+
*
|
384 |
+
* @param array $data
|
385 |
+
* @return array json array
|
386 |
+
*/
|
387 |
+
protected function _update(array $data) {
|
388 |
+
$response = array ();
|
389 |
+
|
390 |
+
$websiteId = ( int ) $data [static::WEBSITEID];
|
391 |
+
if ($websiteId <= 0) {
|
392 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
393 |
+
}
|
394 |
+
// get store id from request
|
395 |
+
$storeId = ( int ) $data [static::STOREID];
|
396 |
+
if ($storeId <= 0) {
|
397 |
+
Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
398 |
+
}
|
399 |
+
// get token value from request
|
400 |
+
$token = $data [static::TOKEN];
|
401 |
+
// get customer id
|
402 |
+
$customerId = ( int ) $data [static::CUSTOMER_ID];
|
403 |
+
|
404 |
+
/**
|
405 |
+
* Check this customer has valid token or not
|
406 |
+
*
|
407 |
+
* @var $isValidToken Mage_Login_Model_Token
|
408 |
+
*/
|
409 |
+
$isValidToken = Mage::getModel ( static::LOGIN_TOKEN )->checkUserToken ( $customerId, $token );
|
410 |
+
|
411 |
+
// get wishlist item collection based on customer id
|
412 |
+
$itemCollection = Mage::getModel ( static::WISHLIST_ITEM )->getCollection ()->addCustomerIdFilter ( $customerId );
|
413 |
+
$itemCollection = $itemCollection->setOrder ( static::ADDED_AT, 'DESC' );
|
414 |
+
if(! is_array($itemCollection)){
|
415 |
+
$success = 0;
|
416 |
+
$message = 'There are no products in your wishlist.';
|
417 |
+
}
|
418 |
+
try {
|
419 |
+
if (! $isValidToken) {
|
420 |
+
throw new Exception ( static::AUTH_FAIL );
|
421 |
+
}
|
422 |
+
foreach ( $itemCollection as $item ) {
|
423 |
+
|
424 |
+
// delete product from wishlist
|
425 |
+
$item->delete ();
|
426 |
+
if ($item->delete ()) {
|
427 |
+
$success = 1;
|
428 |
+
$message = "Products deleted from wishlist successfully.";
|
429 |
+
} else {
|
430 |
+
$success = 0;
|
431 |
+
$message = "Sorry, we're unable to remove the products from wishlist.";
|
432 |
+
}
|
433 |
+
}
|
434 |
+
} catch ( Exception $e ) {
|
435 |
+
$success = 0;
|
436 |
+
$message = $e->getMessage ();
|
437 |
+
}
|
438 |
+
|
439 |
+
$response [static::VALID_TOKEN] = $isValidToken;
|
440 |
+
$response [static::ERROR] = false;
|
441 |
+
$response [static::SUCCESS] = $success;
|
442 |
+
$response [static::MESSAGE] = $message;
|
443 |
+
|
444 |
+
$this->getResponse ()->setBody ( json_encode ( $response ) );
|
445 |
+
|
446 |
+
return;
|
447 |
+
}
|
448 |
+
}
|
app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Wishlistapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest extends ContusRestapi_Wishlistapi_Model_Api2_Wishlist {
|
30 |
+
}
|
app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Admin/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Wishlistapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest_Admin_V1 extends ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Customer/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Wishlistapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest_Customer_V1 extends ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Wishlistapi/Model/Api2/Wishlist/Rest/Guest/V1.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the EULA
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.apptha.com/LICENSE.txt
|
11 |
+
*
|
12 |
+
* ==============================================================
|
13 |
+
* MAGENTO EDITION USAGE NOTICE
|
14 |
+
* ==============================================================
|
15 |
+
* This package designed for Magento COMMUNITY edition
|
16 |
+
* Apptha does not guarantee correct work of this extension
|
17 |
+
* on any other Magento edition except Magento COMMUNITY edition.
|
18 |
+
* Apptha does not provide extension support in case of
|
19 |
+
* incorrect edition usage.
|
20 |
+
* ==============================================================
|
21 |
+
*
|
22 |
+
* @category Contus
|
23 |
+
* @package ContusRestapi_Wishlistapi
|
24 |
+
* @author Contus Team <developers@contus.in>
|
25 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
26 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
class ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest_Guest_V1 extends ContusRestapi_Wishlistapi_Model_Api2_Wishlist_Rest {
|
30 |
+
}
|
app/code/local/ContusRestapi/Wishlistapi/etc/api2.xml
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<api2>
|
4 |
+
<resource_groups>
|
5 |
+
<contusRestapi translate="title" module="Wishlistapi">
|
6 |
+
<title>Wishlist Products</title>
|
7 |
+
<sort_order>14</sort_order>
|
8 |
+
</contusRestapi>
|
9 |
+
</resource_groups>
|
10 |
+
<resources>
|
11 |
+
<wishlistapi translate="title" module="Wishlistapi">
|
12 |
+
<group>contusrestapi</group>
|
13 |
+
<model>wishlistapi/api2_wishlist</model>
|
14 |
+
<title>Wishlist Products</title>
|
15 |
+
<sort_order>18</sort_order>
|
16 |
+
<privileges>
|
17 |
+
<admin>
|
18 |
+
<create>1</create>
|
19 |
+
<retrieve>1</retrieve>
|
20 |
+
<delete>1</delete>
|
21 |
+
<update>1</update>
|
22 |
+
</admin>
|
23 |
+
<customer>
|
24 |
+
<create>1</create>
|
25 |
+
<retrieve>1</retrieve>
|
26 |
+
<delete>1</delete>
|
27 |
+
<update>1</update>
|
28 |
+
</customer>
|
29 |
+
<guest>
|
30 |
+
<create>1</create>
|
31 |
+
<retrieve>1</retrieve>
|
32 |
+
<delete>1</delete>
|
33 |
+
<update>1</update>
|
34 |
+
</guest>
|
35 |
+
</privileges>
|
36 |
+
<attributes module="api2">
|
37 |
+
<website_id>websiteid</website_id>
|
38 |
+
<store_id>Associate to Store</store_id>
|
39 |
+
<customer_id>Customer Id</customer_id>
|
40 |
+
<customer_name>Customer Name</customer_name>
|
41 |
+
<product_id>Product Id</product_id>
|
42 |
+
<wishlist>Wishlist</wishlist>
|
43 |
+
<wishlist_action>Wishlist Action</wishlist_action>
|
44 |
+
<success>Success</success>
|
45 |
+
<result>All Reviews</result>
|
46 |
+
<ratings>Over all Rating</ratings>
|
47 |
+
<token>Token</token>
|
48 |
+
</attributes>
|
49 |
+
<routes>
|
50 |
+
<route_collection>
|
51 |
+
<route>/wishlist/add/</route>
|
52 |
+
<action_type>collection</action_type>
|
53 |
+
</route_collection>
|
54 |
+
<!-- Wishlist products collection -->
|
55 |
+
<wishlist_collection>
|
56 |
+
<route>/wishlist/productlist/</route>
|
57 |
+
<action_type>collection</action_type> <!-- This will call _retrieveCollection function -->
|
58 |
+
<!--<action_type>entity</action_type> --> <!-- This will call _retrieve function -->
|
59 |
+
</wishlist_collection>
|
60 |
+
|
61 |
+
<wishlist_delete>
|
62 |
+
<route>/wishlist/delete/token/:token/product_id/:product_id/customer_id/:customer_id/store_id/:store_id/website_id/:website_id
|
63 |
+
</route> <!-- qid = quote_id, pid = product_id -->
|
64 |
+
<action_type>entity</action_type>
|
65 |
+
</wishlist_delete>
|
66 |
+
<wishlist_clear>
|
67 |
+
<route>/wishlist/clear/</route>
|
68 |
+
<action_type>entity</action_type>
|
69 |
+
</wishlist_clear>
|
70 |
+
</routes>
|
71 |
+
<versions>1</versions>
|
72 |
+
</wishlistapi>
|
73 |
+
|
74 |
+
</resources>
|
75 |
+
</api2>
|
76 |
+
</config>
|
app/code/local/ContusRestapi/Wishlistapi/etc/config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Wishlistapi>
|
5 |
+
<version>0.1.0.0</version>
|
6 |
+
</ContusRestapi_Wishlistapi>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<wishlistapi>
|
11 |
+
<class>ContusRestapi_Wishlistapi_Model</class>
|
12 |
+
</wishlistapi>
|
13 |
+
</models>
|
14 |
+
</global>
|
15 |
+
</config>
|
app/design/adminhtml/default/default/layout/offers.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<offers_adminhtml_offers_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="adminhtml/template" template="offers/offers.phtml" />
|
6 |
+
<block type="offers/adminhtml_offers" name="offers" />
|
7 |
+
</reference>
|
8 |
+
</offers_adminhtml_offers_index>
|
9 |
+
</layout>
|
app/design/adminhtml/default/default/layout/pushnoteorders.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<pushnoteorders_adminhtml_pushnoteorders_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="adminhtml/template" template="pushnoteorders/pushnoteorders.phtml" />
|
6 |
+
<block type="pushnoteorders/adminhtml_pushnoteorders" name="pushnoteorders" />
|
7 |
+
</reference>
|
8 |
+
</pushnoteorders_adminhtml_pushnoteorders_index>
|
9 |
+
</layout>
|
app/design/adminhtml/default/default/layout/pushnoteproducts.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<pushnoteproducts_adminhtml_pushnoteproducts_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="adminhtml/template" template="pushnoteproducts/pushnoteproducts.phtml" />
|
6 |
+
<block type="pushnoteproducts/adminhtml_pushnoteproducts" name="pushnoteproducts" />
|
7 |
+
</reference>
|
8 |
+
</pushnoteproducts_adminhtml_pushnoteproducts_index>
|
9 |
+
</layout>
|
app/design/adminhtml/default/default/template/offers/offers.phtml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
/* Added simplemodal js for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
30 |
+
$mainjsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery-2.1.1.min.js';
|
31 |
+
$jsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery.simplemodal.js';
|
32 |
+
$cssUrl = $this->getSkinUrl ( 'popup.css' );
|
33 |
+
?>
|
34 |
+
<script type="text/javascript" src="<?php echo $mainjsUrl; ?>">
|
35 |
+
</script>
|
36 |
+
<script type="text/javascript" src="<?php echo $jsUrl; ?>">
|
37 |
+
</script>
|
38 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $cssUrl; ?>" />
|
39 |
+
|
40 |
+
<?php
|
41 |
+
/* This below code for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
42 |
+
$baseUrl = Mage::getBaseUrl ();
|
43 |
+
?>
|
44 |
+
<div id="offer-modal-content" class="pop-up" style="display: none">
|
45 |
+
<form id="offer-msg-form"
|
46 |
+
action="<?php echo Mage::helper("adminhtml")->getUrl("offers/adminhtml_offers/getPushMsgParams/");?>"
|
47 |
+
method="post">
|
48 |
+
<label>Enter your message to push</label> <span class="required">*</span><br />
|
49 |
+
<textarea rows="5" cols="10" id="offer_desc" name="offer_desc"></textarea>
|
50 |
+
<input type="hidden" id="offer_id" name="offer_id"></input> <input
|
51 |
+
name="form_key" type="hidden"
|
52 |
+
value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
53 |
+
<button type="submit" onclick="offerMsgValidation()">Submit</button>
|
54 |
+
<input type="button" class="cancel" value="Cancel" id="cancelOffer" />
|
55 |
+
|
56 |
+
</form>
|
57 |
+
</div>
|
58 |
+
<script type="text/javascript">
|
59 |
+
//var $j = jQuery.noConflict();
|
60 |
+
jQuery(document).ready(function(){
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
jQuery(".PushnoteOffer").click(function(){
|
65 |
+
|
66 |
+
var inputIframe = jQuery(this).attr("id");
|
67 |
+
var inputName = jQuery(this).attr("name");
|
68 |
+
jQuery("#offer_desc").val(inputName);
|
69 |
+
jQuery("#offer_id").val(inputIframe);
|
70 |
+
jQuery('#offer-modal-content').modal();
|
71 |
+
|
72 |
+
return false;
|
73 |
+
});
|
74 |
+
|
75 |
+
|
76 |
+
jQuery("#cancelOffer").click(function(){
|
77 |
+
jQuery.modal.close();
|
78 |
+
});
|
79 |
+
});
|
80 |
+
</script>
|
81 |
+
<script type="text/javascript">
|
82 |
+
|
83 |
+
function offerMsgValidation(){
|
84 |
+
var offer = new varienForm('offer-msg-form');
|
85 |
+
}
|
86 |
+
|
87 |
+
</script>
|
88 |
+
|
89 |
+
|
app/design/adminhtml/default/default/template/pushnoteorders/pushnoteorders.phtml
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
/* Added simplemodal js for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
30 |
+
$mainjsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery-2.1.1.min.js';
|
31 |
+
$jsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery.simplemodal.js';
|
32 |
+
$cssUrl = $this->getSkinUrl ( 'popup.css' );
|
33 |
+
?>
|
34 |
+
<script type="text/javascript" src="<?php echo $mainjsUrl; ?>">
|
35 |
+
</script>
|
36 |
+
<script type="text/javascript" src="<?php echo $jsUrl; ?>">
|
37 |
+
</script>
|
38 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $cssUrl; ?>" />
|
39 |
+
|
40 |
+
<?php
|
41 |
+
/* This below code for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
42 |
+
$baseUrl = Mage::getBaseUrl ();
|
43 |
+
?>
|
44 |
+
<div id="order-modal-content" class="pop-up" style="display: none">
|
45 |
+
<form id="order-msg-form"
|
46 |
+
action="<?php echo Mage::helper("adminhtml")->getUrl("pushnoteorders/adminhtml_pushnoteorders/getPushMsgParams/");?>"
|
47 |
+
method="post">
|
48 |
+
<label>Enter your message to push</label> <span class="required">*</span><br />
|
49 |
+
<textarea rows="5" cols="10" id="order_detail" name="order_detail"></textarea>
|
50 |
+
<input type="hidden" id="order_id" name="order_id"></input>
|
51 |
+
<input type="hidden" id="customer_id" name="customer_id"></input>
|
52 |
+
<input
|
53 |
+
name="form_key" type="hidden"
|
54 |
+
value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
55 |
+
<button type="submit" onclick="orderMsgValidation()">Push</button>
|
56 |
+
<input type="button" class="cancel" value="Cancel" id="cancelOrder" />
|
57 |
+
|
58 |
+
</form>
|
59 |
+
</div>
|
60 |
+
<script type="text/javascript">
|
61 |
+
|
62 |
+
jQuery(document).ready(function(){
|
63 |
+
|
64 |
+
jQuery(".PushnoteOrders").click(function(){
|
65 |
+
|
66 |
+
var inputIframe = jQuery(this).attr("id");
|
67 |
+
var inputName = jQuery(this).attr("name");
|
68 |
+
var customerId = jQuery(this).attr("customer_id");
|
69 |
+
jQuery("#order_detail").val(inputName);
|
70 |
+
jQuery("#order_id").val(inputIframe);
|
71 |
+
jQuery("#customer_id").val(customerId);
|
72 |
+
jQuery('#order-modal-content').modal();
|
73 |
+
|
74 |
+
return false;
|
75 |
+
});
|
76 |
+
|
77 |
+
jQuery("#cancelOrder").click(function(){
|
78 |
+
jQuery.modal.close();
|
79 |
+
});
|
80 |
+
});
|
81 |
+
</script>
|
82 |
+
<script type="text/javascript">
|
83 |
+
|
84 |
+
function orderMsgValidation(){
|
85 |
+
var product = new varienForm('order-msg-form');
|
86 |
+
}
|
87 |
+
|
88 |
+
</script>
|
89 |
+
|
90 |
+
|
app/design/adminhtml/default/default/template/pushnoteproducts/pushnoteproducts.phtml
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package default_default
|
23 |
+
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
|
28 |
+
<?php
|
29 |
+
/* Added simplemodal js for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
30 |
+
$mainjsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery-2.1.1.min.js';
|
31 |
+
$jsUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_JS ) . 'iframe/jquery.simplemodal.js';
|
32 |
+
$cssUrl = $this->getSkinUrl ( 'popup.css' );
|
33 |
+
?>
|
34 |
+
<script type="text/javascript" src="<?php echo $mainjsUrl; ?>">
|
35 |
+
</script>
|
36 |
+
<script type="text/javascript" src="<?php echo $jsUrl; ?>">
|
37 |
+
</script>
|
38 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $cssUrl; ?>" />
|
39 |
+
|
40 |
+
<?php
|
41 |
+
/* This below code for showing iframe code in a pop-up - contus groupclone manage deals grid */
|
42 |
+
$baseUrl = Mage::getBaseUrl ();
|
43 |
+
?>
|
44 |
+
<div id="product-modal-content" class="pop-up" style="display: none">
|
45 |
+
<form id="product-msg-form"
|
46 |
+
action="<?php echo Mage::helper("adminhtml")->getUrl("pushnoteproducts/adminhtml_pushnoteproducts/getPushMsgParams/");?>"
|
47 |
+
method="post">
|
48 |
+
<label>Enter your message to push</label> <span class="required">*</span><br />
|
49 |
+
<textarea rows="5" cols="10" id="product_name" name="product_name"></textarea>
|
50 |
+
<input type="hidden" id="product_id" name="product_id"></input> <input
|
51 |
+
name="form_key" type="hidden"
|
52 |
+
value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
53 |
+
<button type="submit" onclick="productMsgValidation()">Push</button>
|
54 |
+
<input type="button" class="cancel" value="Cancel" id="cancelProduct" />
|
55 |
+
</form>
|
56 |
+
</div>
|
57 |
+
<script type="text/javascript">
|
58 |
+
//var $j = jQuery.noConflict();
|
59 |
+
jQuery(document).ready(function(){
|
60 |
+
|
61 |
+
|
62 |
+
|
63 |
+
jQuery(".PushnoteProducts").click(function(){
|
64 |
+
|
65 |
+
var inputIframe = jQuery(this).attr("id");
|
66 |
+
var inputName = jQuery(this).attr("name");
|
67 |
+
jQuery("#product_name").val(inputName);
|
68 |
+
jQuery("#product_id").val(inputIframe);
|
69 |
+
jQuery('#product-modal-content').modal();
|
70 |
+
|
71 |
+
return false;
|
72 |
+
});
|
73 |
+
|
74 |
+
|
75 |
+
jQuery("#cancelProduct").click(function(){
|
76 |
+
jQuery.modal.close();
|
77 |
+
});
|
78 |
+
});
|
79 |
+
</script>
|
80 |
+
<script type="text/javascript">
|
81 |
+
|
82 |
+
function productMsgValidation(){
|
83 |
+
var product = new varienForm('product-msg-form');
|
84 |
+
}
|
85 |
+
|
86 |
+
</script>
|
87 |
+
|
88 |
+
|
app/etc/modules/ContusRestapi_AddressBook.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_AddressBook>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_AddressBook>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_ApplyCoupon.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ApplyCoupon>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_ApplyCoupon>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_CartAddressapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_CartAddressapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_CartAddressapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Cartapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Cartapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Cartapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Filters.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Filters>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Filters>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_HomePageapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_HomePageapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_HomePageapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Login.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Login>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Login>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_MultiCartapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_MultiCartapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_MultiCartapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_MyOrders.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_MyOrders>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_MyOrders>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_PlaceOrder.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_PlaceOrder>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_PlaceOrder>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_ProductList.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ProductList>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_ProductList>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Registration.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Registration>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Registration>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_ReviewRating.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ReviewRating>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_ReviewRating>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_SearchProducts.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_SearchProducts>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_SearchProducts>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_ShippingPaymentapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_ShippingPaymentapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_ShippingPaymentapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_SocialLogin.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_SocialLogin>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_SocialLogin>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Staticpages.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Staticpages>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Staticpages>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/ContusRestapi_Wishlistapi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ContusRestapi_Wishlistapi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</ContusRestapi_Wishlistapi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Contus_Configuration.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Configuration>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Contus_Configuration>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Contus_Offers.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Offers>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Contus_Offers>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Contus_Pushnoteorders.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Pushnoteorders>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Contus_Pushnoteorders>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/etc/modules/Contus_Pushnoteproducts.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Contus_Pushnoteproducts>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Contus_Pushnoteproducts>
|
8 |
+
</modules>
|
9 |
+
</config>
|
contus/Mcom_development.pem
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Bag Attributes
|
2 |
+
friendlyName: Apple Development IOS Push Services: com.contus.mcomdev
|
3 |
+
localKeyID: 3D 9A 54 01 76 20 9E AB 4B 6B C0 43 5A 46 20 5C 8B 53 74 72
|
4 |
+
subject=/UID=com.contus.mcomdev/CN=Apple Development IOS Push Services: com.contus.mcomdev/OU=26VP8T9LM7/C=US
|
5 |
+
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
|
6 |
+
-----BEGIN CERTIFICATE-----
|
7 |
+
MIIFiTCCBHGgAwIBAgIIVI1R9VDWqEkwDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV
|
8 |
+
BAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3Js
|
9 |
+
ZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3
|
10 |
+
aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
|
11 |
+
HhcNMTUwODA3MDYxNjE5WhcNMTYwODA2MDYxNjE5WjCBiDEiMCAGCgmSJomT8ixk
|
12 |
+
AQEMEmNvbS5jb250dXMubWNvbWRldjFAMD4GA1UEAww3QXBwbGUgRGV2ZWxvcG1l
|
13 |
+
bnQgSU9TIFB1c2ggU2VydmljZXM6IGNvbS5jb250dXMubWNvbWRldjETMBEGA1UE
|
14 |
+
CwwKMjZWUDhUOUxNNzELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IB
|
15 |
+
DwAwggEKAoIBAQC5AMmB+hkx7RTesdXfDB487LuhHKZsgil+uismrR+raCu2kd3O
|
16 |
+
jTftc5cZcolgIwz9Udvdtq6tcYHZAg6hiGc5BjYKGrUbhOcKDt9SCwGd8MaFNqBR
|
17 |
+
ygPTKZsWgn35rq2MHm4gLY5fs6UdfRTIp8Jh9hrlT5MZJeXrDPhoa1IiOaaQaPa8
|
18 |
+
CeL2HpPJ3ySfhBYC3pPb731/z4H49nK8Ovjp1HWLmtwTsSwKURBMQQTaNTfeH3K+
|
19 |
+
+oqoQWpzbjNavBfFdbxqnwHbRzMQAi2j3nJXDltP1Ya3TxB9M0dWCrOuDc8DridH
|
20 |
+
CqGuIYahv/2UUFffQek9/sh+x1Dbyvt/rwdvAgMBAAGjggHlMIIB4TAdBgNVHQ4E
|
21 |
+
FgQUPZpUAXYgnqtLa8BDWkYgXItTdHIwCQYDVR0TBAIwADAfBgNVHSMEGDAWgBSI
|
22 |
+
JxcJqbYYYIvs67r2R1nFUlSjtzCCAQ8GA1UdIASCAQYwggECMIH/BgkqhkiG92Nk
|
23 |
+
BQEwgfEwgcMGCCsGAQUFBwICMIG2DIGzUmVsaWFuY2Ugb24gdGhpcyBjZXJ0aWZp
|
24 |
+
Y2F0ZSBieSBhbnkgcGFydHkgYXNzdW1lcyBhY2NlcHRhbmNlIG9mIHRoZSB0aGVu
|
25 |
+
IGFwcGxpY2FibGUgc3RhbmRhcmQgdGVybXMgYW5kIGNvbmRpdGlvbnMgb2YgdXNl
|
26 |
+
LCBjZXJ0aWZpY2F0ZSBwb2xpY3kgYW5kIGNlcnRpZmljYXRpb24gcHJhY3RpY2Ug
|
27 |
+
c3RhdGVtZW50cy4wKQYIKwYBBQUHAgEWHWh0dHA6Ly93d3cuYXBwbGUuY29tL2Fw
|
28 |
+
cGxlY2EvME0GA1UdHwRGMEQwQqBAoD6GPGh0dHA6Ly9kZXZlbG9wZXIuYXBwbGUu
|
29 |
+
Y29tL2NlcnRpZmljYXRpb25hdXRob3JpdHkvd3dkcmNhLmNybDALBgNVHQ8EBAMC
|
30 |
+
B4AwEwYDVR0lBAwwCgYIKwYBBQUHAwIwEAYKKoZIhvdjZAYDAQQCBQAwDQYJKoZI
|
31 |
+
hvcNAQEFBQADggEBAIpzac6OBubNUyKEFpGtNUpkX/i1G66yJADUb+OgueIamvSe
|
32 |
+
i39tR1LIb+JHHtFmEeriuKBYjtbWBKFVHbuf1R5bxVZ2hxmlETGNMphhnKXOlH5I
|
33 |
+
NnsYPPv6n4FFXFjt2ZD7YVgqXcY/kZcHLIsZnX9HH6lbxPOtJnHulT4psCKTTEDZ
|
34 |
+
fv4+zkwjmy7vHiPFlXbeP4Rjjm6YrIB30ifbegyllvY6wnu1zxviXsRCN2dKFTTv
|
35 |
+
JnueaXodjtWFwXIZA4ZdM6uxHGy1IzNYAuVID+zA+T19zGxhoPx/IgOG/izBdJUj
|
36 |
+
DAMs9reLdnvCKT/tXmx/WrxOkxTjbD/s7aBZtWA=
|
37 |
+
-----END CERTIFICATE-----
|
38 |
+
Bag Attributes
|
39 |
+
friendlyName: Contus Distribution 2014
|
40 |
+
localKeyID: 3D 9A 54 01 76 20 9E AB 4B 6B C0 43 5A 46 20 5C 8B 53 74 72
|
41 |
+
Key Attributes: <No Attributes>
|
42 |
+
-----BEGIN RSA PRIVATE KEY-----
|
43 |
+
MIIEpQIBAAKCAQEAuQDJgfoZMe0U3rHV3wwePOy7oRymbIIpfrorJq0fq2grtpHd
|
44 |
+
zo037XOXGXKJYCMM/VHb3baurXGB2QIOoYhnOQY2Chq1G4TnCg7fUgsBnfDGhTag
|
45 |
+
UcoD0ymbFoJ9+a6tjB5uIC2OX7OlHX0UyKfCYfYa5U+TGSXl6wz4aGtSIjmmkGj2
|
46 |
+
vAni9h6Tyd8kn4QWAt6T2+99f8+B+PZyvDr46dR1i5rcE7EsClEQTEEE2jU33h9y
|
47 |
+
vvqKqEFqc24zWrwXxXW8ap8B20czEAIto95yVw5bT9WGt08QfTNHVgqzrg3PA64n
|
48 |
+
RwqhriGGob/9lFBX30HpPf7IfsdQ28r7f68HbwIDAQABAoIBABziOpPIcFaTJUb/
|
49 |
+
jNyeD7qDW2f0CSe3yrK2bjZDoUYppWmDrJWrBqhT+6tFbp1L26NRPHqJIwyBRDyV
|
50 |
+
TaN6oGMOzTEWql/5h/jSCZvNjBsUlGoH9U/PsnktbcE97l0lIINX3Om5MxlN+uF3
|
51 |
+
vd72EispOVnD6rtqZ1MjW0UyPEiLY3DVb0tf8oREMeS++0ir8lYHkbxjpdbKOLED
|
52 |
+
j3bHk+EX2nTXrqBRMxGmE+U5tS2Iyihkedh8a1H+9VkSTgy4WrHq/AeqOJS0S1ZN
|
53 |
+
Wz2cdUBdiOwZfgKHx2IgHWlYlmPsFCnNr5/VXsd5GrfM18Rmqg3a3pbpaW4bJbKS
|
54 |
+
k4i46kECgYEA7nP9+iWPTOulRuGXSfC5wkZGthEJfA++1XyTe+DkCPEWqdNwOj4X
|
55 |
+
H1FYNshpjQ9KFxG7YLVS7mt+mbZvQPdZvuPoMYBwKp08aiZoT+ocRQX8e6dLY+fs
|
56 |
+
wlc7AZiTV8ngPLaLE48uWq9n6eIp4tVXg92k4VWi0taB62XCZ2FlPq0CgYEAxp3l
|
57 |
+
ref2IqU6GNfYkQiuB6C5TGFIBsfuqQCVZEimIf5z2Wmm160srfoxwWnhnaQjlHWO
|
58 |
+
pdRBoq6XzFWGEwnBCSl3k6fGWl8lZ5JQxTt3pbCswzH8kpjL8KCtoCyaZJXa5570
|
59 |
+
Z6VSNEJhfRneK+2lzUm/JXx5kv4GDT/IxqzjbgsCgYEAg0sgm7xUk+DoBwgtmgvO
|
60 |
+
7DZvts3YsBOnWrsWJc5lILtGZEnEcH1Bk//hF4DwBThW7i7YQl50hExxz8cQqO/I
|
61 |
+
3X91mNQEbqJW4oe1RdM8r5ClPZyWuTK5PSR0m+Nbtam1KxjDqQhcWJheGfxqXbhk
|
62 |
+
UHoYz+2sEnUD4g4MpYmOCp0CgYEAiTkIOZm8rX0YYZenUbT8f9qki0fe+ohhtLPp
|
63 |
+
gyrKVUw3ACwFkJdd+imU/LtJnJ+N0YFS9/FpE5uq1wrzoe2oR8s1iXduDHwWHLOz
|
64 |
+
SEFozbn98rJzfVlB9dMdgj+uv/XlEwf4di97Vw3Ryxv3KsR7PBVKkfypBkypI7hA
|
65 |
+
4DsMurcCgYEA2peSDlA3GYVrQjtZwCF5mMo21MW82ZlzQhmUpQuLFuHcaaym2iqV
|
66 |
+
zK+P5K6RdQw+p/jBWFhk/151bW//qk9I3NM2JVRY5H2XU6G/G4G2YwEAkL7MHgRt
|
67 |
+
+NNhxOHLlSM2KmfJVgcSFk+dY+zHsu6Os7u00SDVuqwOrnrtyhYUpFs=
|
68 |
+
-----END RSA PRIVATE KEY-----
|
contus/Mcom_production.pem
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Bag Attributes
|
2 |
+
friendlyName: Apple Production IOS Push Services: com.contus.mcom
|
3 |
+
localKeyID: 3B 46 FF 5D 9B F0 52 FB 0E EC 07 B0 73 F6 AE A8 12 A0 F6 DF
|
4 |
+
subject=/UID=com.contus.mcom/CN=Apple Production IOS Push Services: com.contus.mcom/OU=G44VFA67ZG/C=US
|
5 |
+
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
|
6 |
+
-----BEGIN CERTIFICATE-----
|
7 |
+
MIIFgjCCBGqgAwIBAgIIcHQAFlfdNX8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV
|
8 |
+
BAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3Js
|
9 |
+
ZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3
|
10 |
+
aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
|
11 |
+
HhcNMTUwNzIxMDYxOTA5WhcNMTYwNzIwMDYxOTA5WjCBgTEfMB0GCgmSJomT8ixk
|
12 |
+
AQEMD2NvbS5jb250dXMubWNvbTE8MDoGA1UEAwwzQXBwbGUgUHJvZHVjdGlvbiBJ
|
13 |
+
T1MgUHVzaCBTZXJ2aWNlczogY29tLmNvbnR1cy5tY29tMRMwEQYDVQQLDApHNDRW
|
14 |
+
RkE2N1pHMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
15 |
+
ggEBANrcl/FHuxhGO1AbfZcyrxviHaD2XrLy2aeHyXhL2YIEsCmoKPvE7MSNDqM+
|
16 |
+
Fk6pEICC0JVSnuVHX67JBY3r/PaSTUkoxzV/h4ZlkxwHeSnWZFafTXG8OxQZTsGH
|
17 |
+
s2ETkSPT05iOyEWQPBNJdrTQaXd3MxKYgf1/Hh6HKpiZB/kyUtg/toIU8DoNVZlA
|
18 |
+
/KMqKUoxLxm7VKNUT/z6F/HasX5b+L+svUgyrrUi9k2PNh7BEN9rzmpod7BeWJQd
|
19 |
+
WZhAlXWQThpzAH4fUDRW9+r/Wao1viEgWar1mIE91qkIfJEHWiAwkUjSjtVfD+Mb
|
20 |
+
FTYZc+YmBljmBzJ4a5naePDZXscCAwEAAaOCAeUwggHhMB0GA1UdDgQWBBQ7Rv9d
|
21 |
+
m/BS+w7sB7Bz9q6oEqD23zAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFIgnFwmpthhg
|
22 |
+
i+zruvZHWcVSVKO3MIIBDwYDVR0gBIIBBjCCAQIwgf8GCSqGSIb3Y2QFATCB8TCB
|
23 |
+
wwYIKwYBBQUHAgIwgbYMgbNSZWxpYW5jZSBvbiB0aGlzIGNlcnRpZmljYXRlIGJ5
|
24 |
+
IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGlj
|
25 |
+
YWJsZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRp
|
26 |
+
ZmljYXRlIHBvbGljeSBhbmQgY2VydGlmaWNhdGlvbiBwcmFjdGljZSBzdGF0ZW1l
|
27 |
+
bnRzLjApBggrBgEFBQcCARYdaHR0cDovL3d3dy5hcHBsZS5jb20vYXBwbGVjYS8w
|
28 |
+
TQYDVR0fBEYwRDBCoECgPoY8aHR0cDovL2RldmVsb3Blci5hcHBsZS5jb20vY2Vy
|
29 |
+
dGlmaWNhdGlvbmF1dGhvcml0eS93d2RyY2EuY3JsMAsGA1UdDwQEAwIHgDATBgNV
|
30 |
+
HSUEDDAKBggrBgEFBQcDAjAQBgoqhkiG92NkBgMCBAIFADANBgkqhkiG9w0BAQUF
|
31 |
+
AAOCAQEAAjhn2lA3G5nbaDxPIILsM2iiX0itFFkgfT4i/gKXCYMURmL5RQ9Auf0x
|
32 |
+
jWTbFQtehD9DzI+AzWdpio6BHOGBWzYgVx80F9IqZSyjvO4wgwUDgIBVL/8/poch
|
33 |
+
6ZqiOq15kc8/+uNjtYYeIAlhe9MsjZvlyd3BSq5ONWJRPYAccszZdoPUyUGEe4G9
|
34 |
+
tmYg2cAVhlCXq6xwk9XsbYE0Urcij9KdHp5cB2wtN1I2ByQjLq2Wza/rb5RVOrNj
|
35 |
+
+I0jD25gZ45RYTDBQGcFhqauBDxcsh7t39h3JdSaf3Zqg20lUFxxQwpKZ8GfFXgq
|
36 |
+
QoSnLXGDh6Whvhy4V/m2tcj0bs1qyQ==
|
37 |
+
-----END CERTIFICATE-----
|
38 |
+
Bag Attributes
|
39 |
+
friendlyName: Contus
|
40 |
+
localKeyID: 3B 46 FF 5D 9B F0 52 FB 0E EC 07 B0 73 F6 AE A8 12 A0 F6 DF
|
41 |
+
Key Attributes: <No Attributes>
|
42 |
+
-----BEGIN RSA PRIVATE KEY-----
|
43 |
+
MIIEpAIBAAKCAQEA2tyX8Ue7GEY7UBt9lzKvG+IdoPZesvLZp4fJeEvZggSwKago
|
44 |
+
+8TsxI0Ooz4WTqkQgILQlVKe5UdfrskFjev89pJNSSjHNX+HhmWTHAd5KdZkVp9N
|
45 |
+
cbw7FBlOwYezYRORI9PTmI7IRZA8E0l2tNBpd3czEpiB/X8eHocqmJkH+TJS2D+2
|
46 |
+
ghTwOg1VmUD8oyopSjEvGbtUo1RP/PoX8dqxflv4v6y9SDKutSL2TY82HsEQ32vO
|
47 |
+
amh3sF5YlB1ZmECVdZBOGnMAfh9QNFb36v9ZqjW+ISBZqvWYgT3WqQh8kQdaIDCR
|
48 |
+
SNKO1V8P4xsVNhlz5iYGWOYHMnhrmdp48NlexwIDAQABAoIBAQCFhF/ZXUZBZ88V
|
49 |
+
br/udognPYmPwd1B1C9+KbN6BOPbktqZfzIJbjh3LAqLAfx/3lnn3GY9QlsXSrSP
|
50 |
+
n6kYzKfVEKm/gPYOqA9YqSzWw6RiJp2tzp9jTE7KUyodnJiNF2/K6JZEko6RCY3s
|
51 |
+
wjt90UsWC40HwixDJsKMIy+USn93wN86zx0qKpdXuFZajIYfkIk2eXbZbPM3ke71
|
52 |
+
8FSbV+v6ppV4WtvTzCEjtExlN574dagVhbeYGzKlnINA3Arx6bKsH/OQ2Hrptf1v
|
53 |
+
tq24ocjCI8InYQKjxPnp16FLvyEU7p0lNMoE21GOyemLa4WqHyGK8fxyuh+tXt5v
|
54 |
+
IijZENcxAoGBAPucIcB5JalO/dAtyX1CvUm/q83Zm8hHNhLl8WWapIPbs3zyGXaU
|
55 |
+
jHcLhfcscc/Sl+i4iKqAH3bZq4MICRYqcDNO+jErNN4jnwA7JGK+Hgnv57wO4W8p
|
56 |
+
tj6ZHf8C+A1xoOD8DkW7teh+KJEej3Ej21aWhhQQWvwNPohM0oK/yt2PAoGBAN6u
|
57 |
+
L11diiTlmC/tVyhsPBO5zz5Iv9nINprvC4yFHjjwglVg9v1U3Yb9q2plbcT1pS/K
|
58 |
+
IlMjhFKYCzW2SuHxZHMyXtF+xeL5mSR3dv8WBkEmBRARQ9pH7g3GlpK2DMQnl3tJ
|
59 |
+
jcMn6ODm9ux0xQFVdovxOk702GcJ6EG7oijr5j9JAoGAWloQzLs0SP4yqsUma7LB
|
60 |
+
onAP09Xm2R6pTlQAQYostaT5aU7O0gQ6BK3Ap6fwHr7zCgDqIr/rjJRRwLXr/Wez
|
61 |
+
7tjXgzyOuY51FHIoeMToqIzb3G5DidWiugvl96MrTDiXmvModOYZRqm3C5W70Ncd
|
62 |
+
dpSLBT1yTry6zds4ZPdWdAUCgYEApykg+ziV1F7aINhNPlYJv1ETxxC7nFPU0fey
|
63 |
+
trjTWDEL1eXlY4TKi2Rvwn4DqgAxEa/ulnSqB4qFl7uReQ1Jt8RPM3q0OE/ga2SW
|
64 |
+
2qSA63UMBeTAB+NJS+QQ8m9hI/sIlw8/MQoLopEfOZ/qp7atOB5NBCp/LNJeHMIq
|
65 |
+
2AdGH6kCgYA5WwSDbqmxx/MYQA2Jmsc89McG7YFyRuEXLKu0h343cw5YNSTm/l7d
|
66 |
+
mp19hpsc7cfjor9+noM36xZsE8P7Vm3OetKBlqh1fWHcExGilFeMEjApGnzzjSmY
|
67 |
+
k/P7khakRZNrjuBozhdaK/9PRo9pcFDdlWcPbBT7VyYDOZxwPGXdmw==
|
68 |
+
-----END RSA PRIVATE KEY-----
|
contus/image/splash_logo.png
ADDED
Binary file
|
js/iframe/jquery-2.1.1.min.js
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
2 |
+
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)
|
3 |
+
},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||l,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[n.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new n.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=l),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&n.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return n.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=n.extend(new n.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?n.event.trigger(e,null,b):n.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},n.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},n.Event=function(a,b){return this instanceof n.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?Z:$):this.type=a,b&&n.extend(this,b),this.timeStamp=a&&a.timeStamp||n.now(),void(this[n.expando]=!0)):new n.Event(a,b)},n.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Z,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},n.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){n.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!n.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.focusinBubbles||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a),!0)};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),n.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return n().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=n.guid++)),this.each(function(){n.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,n(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){n.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||n.fx.stop(),Lb=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Mb||(Mb=setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){clearInterval(Mb),Mb=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(a,b){return a=n.fx?n.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=l.createElement("input"),b=l.createElement("select"),c=b.appendChild(l.createElement("option"));a.type="checkbox",k.checkOn=""!==a.value,k.optSelected=c.selected,b.disabled=!0,k.optDisabled=!c.disabled,a=l.createElement("input"),a.value="t",a.type="radio",k.radioValue="t"===a.value}();var Yb,Zb,$b=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return J(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b))
|
4 |
+
},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=l.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,n.ajaxSettings),b):tc(n.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=n.ajaxSettings.xhr();a.ActiveXObject&&n(a).on("unload",function(){for(var a in Dc)Dc[a]()}),k.cors=!!Fc&&"withCredentials"in Fc,k.ajax=Fc=!!Fc,n.ajaxTransport(function(a){var b;return k.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),l.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||n.expando+"_"+cc++;return this[a]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||n.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&n.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),n.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||l;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=n.buildFragment([a],b,e),e&&e.length&&n(e).remove(),n.merge([],d.childNodes))};var Ic=n.fn.load;n.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=n.trim(a.slice(h)),a=a.slice(0,h)),n.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&n.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?n("<div>").append(n.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},n.expr.filters.animated=function(a){return n.grep(n.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return n.isWindow(a)?a:9===a.nodeType&&a.defaultView}n.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=n.css(a,"position"),l=n(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=n.css(a,"top"),i=n.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,n.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===n.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(d=a.offset()),d.top+=n.css(a[0],"borderTopWidth",!0),d.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-n.css(c,"marginTop",!0),left:b.left-d.left-n.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Jc})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;n.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=yb(k.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var Lc=a.jQuery,Mc=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=Mc),b&&a.jQuery===n&&(a.jQuery=Lc),n},typeof b===U&&(a.jQuery=a.$=n),n});
|
5 |
+
jQuery.noConflict();
|
js/iframe/jquery.simplemodal.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* SimpleModal 1.4.4 - jQuery Plugin
|
3 |
+
* http://simplemodal.com/
|
4 |
+
* Copyright (c) 2013 Eric Martin
|
5 |
+
* Licensed under MIT and GPL
|
6 |
+
* Date: Sun, Jan 20 2013 15:58:56 -0800
|
7 |
+
*/
|
8 |
+
(function(b){"function"===typeof define&&define.amd?define(["jquery"],b):b(jQuery)})(function(b){var j=[],n=b(document),k=navigator.userAgent.toLowerCase(),l=b(window),g=[],o=null,p=/msie/.test(k)&&!/opera/.test(k),q=/opera/.test(k),m,r;m=p&&/msie 6./.test(k)&&"object"!==typeof window.XMLHttpRequest;r=p&&/msie 7.0/.test(k);b.modal=function(a,h){return b.modal.impl.init(a,h)};b.modal.close=function(){b.modal.impl.close()};b.modal.focus=function(a){b.modal.impl.focus(a)};b.modal.setContainerDimensions=
|
9 |
+
function(){b.modal.impl.setContainerDimensions()};b.modal.setPosition=function(){b.modal.impl.setPosition()};b.modal.update=function(a,h){b.modal.impl.update(a,h)};b.fn.modal=function(a){return b.modal.impl.init(this,a)};b.modal.defaults={appendTo:"body",focus:!0,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:!1,autoPosition:!0,zIndex:1E3,
|
10 |
+
close:!0,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:"simplemodal-close",escClose:!0,overlayClose:!1,fixed:!0,position:null,persist:!1,modal:!0,onOpen:null,onShow:null,onClose:null};b.modal.impl={d:{},init:function(a,h){if(this.d.data)return!1;o=p&&!b.support.boxModel;this.o=b.extend({},b.modal.defaults,h);this.zIndex=this.o.zIndex;this.occb=!1;if("object"===typeof a){if(a=a instanceof b?a:b(a),this.d.placeholder=!1,0<a.parent().parent().size()&&(a.before(b("<span></span>").attr("id",
|
11 |
+
"simplemodal-placeholder").css({display:"none"})),this.d.placeholder=!0,this.display=a.css("display"),!this.o.persist))this.d.orig=a.clone(!0)}else if("string"===typeof a||"number"===typeof a)a=b("<div></div>").html(a);else return alert("SimpleModal Error: Unsupported data type: "+typeof a),this;this.create(a);this.open();b.isFunction(this.o.onShow)&&this.o.onShow.apply(this,[this.d]);return this},create:function(a){this.getDimensions();if(this.o.modal&&m)this.d.iframe=b('<iframe src="javascript:false;"></iframe>').css(b.extend(this.o.iframeCss,
|
12 |
+
{display:"none",opacity:0,position:"fixed",height:g[0],width:g[1],zIndex:this.o.zIndex,top:0,left:0})).appendTo(this.o.appendTo);this.d.overlay=b("<div></div>").attr("id",this.o.overlayId).addClass("simplemodal-overlay").css(b.extend(this.o.overlayCss,{display:"none",opacity:this.o.opacity/100,height:this.o.modal?j[0]:0,width:this.o.modal?j[1]:0,position:"fixed",left:0,top:0,zIndex:this.o.zIndex+1})).appendTo(this.o.appendTo);this.d.container=b("<div></div>").attr("id",this.o.containerId).addClass("simplemodal-container").css(b.extend({position:this.o.fixed?
|
13 |
+
"fixed":"absolute"},this.o.containerCss,{display:"none",zIndex:this.o.zIndex+2})).append(this.o.close&&this.o.closeHTML?b(this.o.closeHTML).addClass(this.o.closeClass):"").appendTo(this.o.appendTo);this.d.wrap=b("<div></div>").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(this.d.container);this.d.data=a.attr("id",a.attr("id")||this.o.dataId).addClass("simplemodal-data").css(b.extend(this.o.dataCss,{display:"none"})).appendTo("body");this.setContainerDimensions();
|
14 |
+
this.d.data.appendTo(this.d.wrap);(m||o)&&this.fixIE()},bindEvents:function(){var a=this;b("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()});a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});n.bind("keydown.simplemodal",function(b){a.o.modal&&9===b.keyCode?a.watchTab(b):a.o.close&&a.o.escClose&&27===b.keyCode&&(b.preventDefault(),a.close())});l.bind("resize.simplemodal orientationchange.simplemodal",
|
15 |
+
function(){a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();m||o?a.fixIE():a.o.modal&&(a.d.iframe&&a.d.iframe.css({height:g[0],width:g[1]}),a.d.overlay.css({height:j[0],width:j[1]}))})},unbindEvents:function(){b("."+this.o.closeClass).unbind("click.simplemodal");n.unbind("keydown.simplemodal");l.unbind(".simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this.o.position;b.each([this.d.iframe||null,!this.o.modal?null:this.d.overlay,
|
16 |
+
"fixed"===this.d.container.css("position")?this.d.container:null],function(b,e){if(e){var f=e[0].style;f.position="absolute";if(2>b)f.removeExpression("height"),f.removeExpression("width"),f.setExpression("height",'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"'),f.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"');else{var c,d;a&&a.constructor===
|
17 |
+
Array?(c=a[0]?"number"===typeof a[0]?a[0].toString():a[0].replace(/px/,""):e.css("top").replace(/px/,""),c=-1===c.indexOf("%")?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',a[1]&&(d="number"===typeof a[1]?
|
18 |
+
a[1].toString():a[1].replace(/px/,""),d=-1===d.indexOf("%")?d+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(d.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"')):(c='(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"',
|
19 |
+
d='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"');f.removeExpression("top");f.removeExpression("left");f.setExpression("top",c);f.setExpression("left",d)}}})},focus:function(a){var h=this,a=a&&-1!==b.inArray(a,["first","last"])?a:"first",e=b(":input:enabled:visible:"+a,h.d.wrap);setTimeout(function(){0<e.length?e.focus():h.d.wrap.focus()},
|
20 |
+
10)},getDimensions:function(){var a="undefined"===typeof window.innerHeight?l.height():window.innerHeight;j=[n.height(),n.width()];g=[a,l.width()]},getVal:function(a,b){return a?"number"===typeof a?a:"auto"===a?0:0<a.indexOf("%")?parseInt(a.replace(/%/,""))/100*("h"===b?g[0]:g[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){if(!this.d.data)return!1;this.d.origHeight=this.getVal(a,"h");this.d.origWidth=this.getVal(b,"w");this.d.data.hide();a&&this.d.container.css("height",a);b&&this.d.container.css("width",
|
21 |
+
b);this.setContainerDimensions();this.d.data.show();this.o.focus&&this.focus();this.unbindEvents();this.bindEvents()},setContainerDimensions:function(){var a=m||r,b=this.d.origHeight?this.d.origHeight:q?this.d.container.height():this.getVal(a?this.d.container[0].currentStyle.height:this.d.container.css("height"),"h"),a=this.d.origWidth?this.d.origWidth:q?this.d.container.width():this.getVal(a?this.d.container[0].currentStyle.width:this.d.container.css("width"),"w"),e=this.d.data.outerHeight(!0),f=
|
22 |
+
this.d.data.outerWidth(!0);this.d.origHeight=this.d.origHeight||b;this.d.origWidth=this.d.origWidth||a;var c=this.o.maxHeight?this.getVal(this.o.maxHeight,"h"):null,d=this.o.maxWidth?this.getVal(this.o.maxWidth,"w"):null,c=c&&c<g[0]?c:g[0],d=d&&d<g[1]?d:g[1],i=this.o.minHeight?this.getVal(this.o.minHeight,"h"):"auto",b=b?this.o.autoResize&&b>c?c:b<i?i:b:e?e>c?c:this.o.minHeight&&"auto"!==i&&e<i?i:e:i,c=this.o.minWidth?this.getVal(this.o.minWidth,"w"):"auto",a=a?this.o.autoResize&&a>d?d:a<c?c:a:f?
|
23 |
+
f>d?d:this.o.minWidth&&"auto"!==c&&f<c?c:f:c;this.d.container.css({height:b,width:a});this.d.wrap.css({overflow:e>b||f>a?"auto":"visible"});this.o.autoPosition&&this.setPosition()},setPosition:function(){var a,b;a=g[0]/2-this.d.container.outerHeight(!0)/2;b=g[1]/2-this.d.container.outerWidth(!0)/2;var e="fixed"!==this.d.container.css("position")?l.scrollTop():0;this.o.position&&"[object Array]"===Object.prototype.toString.call(this.o.position)?(a=e+(this.o.position[0]||a),b=this.o.position[1]||b):
|
24 |
+
a=e+a;this.d.container.css({left:b,top:a})},watchTab:function(a){if(0<b(a.target).parents(".simplemodal-container").length){if(this.inputs=b(":input:enabled:visible:first, :input:enabled:visible:last",this.d.data[0]),!a.shiftKey&&a.target===this.inputs[this.inputs.length-1]||a.shiftKey&&a.target===this.inputs[0]||0===this.inputs.length)a.preventDefault(),this.focus(a.shiftKey?"last":"first")}else a.preventDefault(),this.focus()},open:function(){this.d.iframe&&this.d.iframe.show();b.isFunction(this.o.onOpen)?
|
25 |
+
this.o.onOpen.apply(this,[this.d]):(this.d.overlay.show(),this.d.container.show(),this.d.data.show());this.o.focus&&this.focus();this.bindEvents()},close:function(){if(!this.d.data)return!1;this.unbindEvents();if(b.isFunction(this.o.onClose)&&!this.occb)this.occb=!0,this.o.onClose.apply(this,[this.d]);else{if(this.d.placeholder){var a=b("#simplemodal-placeholder");this.o.persist?a.replaceWith(this.d.data.removeClass("simplemodal-data").css("display",this.display)):(this.d.data.hide().remove(),a.replaceWith(this.d.orig))}else this.d.data.hide().remove();
|
26 |
+
this.d.container.hide().remove();this.d.overlay.hide();this.d.iframe&&this.d.iframe.hide().remove();this.d.overlay.remove();this.d={}}}}});
|
27 |
+
jQuery.noConflict();
|
package.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Contus_Mcomm</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Contus Mcom Module </summary>
|
10 |
+
<description>Contus Mcom Module </description>
|
11 |
+
<notes>Contus M-Comm, a ready to go solution to build native Magento mobile apps for your store across all devices.
|
12 |
+
</notes>
|
13 |
+
<authors><author><name>contus</name><user>contus</user><email>developers@contus.in</email></author></authors>
|
14 |
+
<date>2015-08-17</date>
|
15 |
+
<time>13:29:33</time>
|
16 |
+
<contents><target name="mageetc"><dir><dir name="modules"><file name="Contus_Offers.xml" hash="9eb0553e491ea8d5e446e7cc558cb58b"/><file name="Contus_Configuration.xml" hash="41fb04ff499bda81e9bfc3464312de5c"/><file name="Contus_Pushnoteorders.xml" hash="04990a32246dce9b672de674213ebee5"/><file name="Contus_Pushnoteproducts.xml" hash="148b2b106ef411de65569bccdccc30f0"/><file name="ContusRestapi_AddressBook.xml" hash="fda5174d2aea353c844a42f27ab989eb"/><file name="ContusRestapi_ApplyCoupon.xml" hash="633db3d6edd00c396c99296a6fdd4902"/><file name="ContusRestapi_CartAddressapi.xml" hash="dd8f64f45e6575a833431905619604f5"/><file name="ContusRestapi_Cartapi.xml" hash="30793aaf7eda767f1bb667c58d2f68a6"/><file name="ContusRestapi_Filters.xml" hash="1450296e437b3112f007896af955f424"/><file name="ContusRestapi_HomePageapi.xml" hash="08814a3f0c9d073f1bea7895e89bc059"/><file name="ContusRestapi_Login.xml" hash="f77221543e7ff841c3706a99b73e937c"/><file name="ContusRestapi_MultiCartapi.xml" hash="85d05924d95011d58daae2114992483e"/><file name="ContusRestapi_MyOrders.xml" hash="49e029267031a0aa61b7c09e1155bf58"/><file name="ContusRestapi_PlaceOrder.xml" hash="4e60174c9499436682c8103e112ec561"/><file name="ContusRestapi_ProductList.xml" hash="7d7f8d3f63417ad73ba0e663c37727b7"/><file name="ContusRestapi_Registration.xml" hash="76dd1182003a33b4982b156d80cf1a1b"/><file name="ContusRestapi_ReviewRating.xml" hash="d864b7d755f0a68d530a0d18d34ccd4e"/><file name="ContusRestapi_SearchProducts.xml" hash="391b8900fa5d0024011c2c1e6764b78f"/><file name="ContusRestapi_ShippingPaymentapi.xml" hash="a24e1c097d56936819b5c385b7313570"/><file name="ContusRestapi_SocialLogin.xml" hash="8812ff2f9805cbafd3dfa9b3ae74bc43"/><file name="ContusRestapi_Staticpages.xml" hash="233c3a726f75fe559fc890000ab889ba"/><file name="ContusRestapi_Wishlistapi.xml" hash="bb680accc2edf350336d681d1c7ca965"/></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="offers.xml" hash="00e36ce786fea57557de25e315ff4d44"/><file name="pushnoteproducts.xml" hash="06eee4ed043285524d70f14fb8f5190b"/><file name="pushnoteorders.xml" hash="baa5ec7f3079699b0eb340d95586016a"/></dir><dir name="template"><dir name="offers"><file name="offers.phtml" hash="39e48356b3706eb29221763b1b82c55e"/></dir><dir name="pushnoteproducts"><file name="pushnoteproducts.phtml" hash="a2dbc8159d3c97b7cb2832d3a1670c12"/></dir><dir name="pushnoteorders"><file name="pushnoteorders.phtml" hash="4673989e2102012fb24230873b99656c"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><file name="popup.css" hash="8cc8c3a5113d76b51ec13ade4fc41afb"/></dir></dir></dir></dir></target><target name="mage"><dir><dir name="js"><dir name="iframe"><file name="jquery-2.1.1.min.js" hash="49fffe009bd5abd3db052a50537dcbe3"/><file name="jquery.simplemodal.js" hash="b33a4bd97176d530ba43a6659daaa748"/></dir></dir><dir name="contus"><file name="Mcom_development.pem" hash="21cec017e04e0b229b9349138ed939c3"/><file name="Mcom_production.pem" hash="8e3131c3eca71a6996c346b6b1144b21"/><dir><dir name="image"><file name="splash_logo.png" hash="8ca437906154fe6b0e854764fe4991b3"/></dir></dir></dir><dir name="paypal"><file name="PaymentGateway.php" hash="276078578ddf722db13f0409e955255d"/><file name="Paypal.php" hash="ac313df2943a8424b5235d1f7d75ca39"/><file name="cancel.php" hash="d9f87387c5b8e1e9e1ad95cc661acd21"/><file name="ipn.php" hash="782cc7a4b7b8b9e53d057d2780e40285"/><file name="ipnlistener.php" hash="1f9b96d748b21dc333d5235804086981"/><file name="redirect.php" hash="950ebf702848fe0609d9bb4a3ce6f391"/><file name="success.php" hash="8d662cbefd8081db70b40444d24aa668"/></dir><dir name="rest"><file name="Rest.inc.php" hash="db6e2cdc43f08a964b1d7de82f7b5ba3"/><file name="api.php" hash="5bd85348f04269fbdd050a3c7a13d81c"/><file name=".htaccess" hash="0a6a1af3eba87f4e9dd820b01c38e766"/></dir></dir></target><target name="magelocal"><dir><dir name="ContusRestapi"><dir><dir name="AddressBook"><dir name="Model"><dir name="Api2"><dir name="AddressBook"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="fa87ce51335210432b63ee767704f48c"/></dir><dir name="Customer"><file name="V1.php" hash="ec4d710ae329f358c3eb2d902a89a853"/></dir><dir name="Guest"><file name="V1.php" hash="a8039455bfcd23ed607fa667ae7bb1c7"/></dir></dir><file name="Rest.php" hash="30e3ee96d4611f0bd792d1b10ba348d1"/></dir><file name="AddressBookapi.php" hash="3f374bbf1fb1c7577367c2477cb6f93e"/><dir name="Country"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="2c8ccecc9a2f4fdb1ca891a58df12b2e"/></dir><dir name="Customer"><file name="V1.php" hash="323672cd9e310ca58941cba073f05c23"/></dir><dir name="Guest"><file name="V1.php" hash="31056c51f9316006ddb8468c510f5f90"/></dir></dir><file name="Rest.php" hash="d3f8dd6b9172a5b3523734c18ebad887"/></dir><file name="Country.php" hash="386046a292f3089d641c23fbc13d4d03"/><dir name="State"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="069dfc1cf9158f73ad1c5803eeb1413b"/></dir><dir name="Guest"><file name="V1.php" hash="816582cd3557fe11890beadb49fb858b"/></dir></dir><file name="Rest.php" hash="b4794c183f5103bcf5e570b6777c2959"/></dir><file name="State.php" hash="973f8e8e696d4fc3751826592ad3fb06"/></dir></dir><dir name="etc"><file name="api2.xml" hash="b7a8262be03ca5c517a8b692abf84e7d"/><file name="config.xml" hash="92a63d6bdce25d58fdcad08722deb3dd"/></dir></dir><dir name="ApplyCoupon"><dir name="Model"><dir name="Api2"><dir name="ApplyCoupon"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="1a577bc661a83ee1b77cfb97367d113c"/></dir><dir name="Customer"><file name="V1.php" hash="736dc803ee29515ad32ff00afe155e46"/></dir><dir name="Guest"><file name="V1.php" hash="605595e312d8b8941e8b55a04c795f7b"/></dir></dir><file name="Rest.php" hash="0e679cf5405ac8e3b216d49cae52a67f"/></dir><file name="ApplyCouponapi.php" hash="47d9eb575987325609fd89a1b11a8b21"/></dir></dir><dir name="etc"><file name="api2.xml" hash="b7f6afd002743deab122af594a24eeb9"/><file name="config.xml" hash="d1ce73f4eeb36c9e0d2204785ddef5f3"/></dir></dir><dir name="CartAddressapi"><dir name="Model"><dir name="Api2"><dir name="CartAddressapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="800148a390660be0e966dab0f3f1a3b3"/></dir><dir name="Customer"><file name="V1.php" hash="c4540f56b75ca665a8771194e5b108de"/></dir><dir name="Guest"><file name="V1.php" hash="d4f6627ea61a7e3de9762e2a5730f21f"/></dir></dir><file name="Rest.php" hash="6069a2f769245b78398adc93bf01cd4e"/></dir><file name="CartAddressapi.php" hash="ff302469c5365a8f0aede220e4e4179a"/></dir></dir><dir name="etc"><file name="api2.xml" hash="d1ceb1780f9428cd2617faacce4113c2"/><file name="config.xml" hash="85b2ea62c85b6a52bf1326e7ea2e80d2"/></dir></dir><dir name="Cartapi"><dir name="Model"><dir name="Api2"><dir name="Cartapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="e9b2780fc6717cf4c8cd70a0996da952"/></dir><dir name="Customer"><file name="V1.php" hash="e9e27542054b1050eff94b8e24dc81f7"/></dir><dir name="Guest"><file name="V1.php" hash="e0df6d95bdca4ac73c162c72dccd3157"/></dir></dir><file name="Rest.php" hash="11089e228f3a08342bc294a55ec2a0d5"/></dir><file name="Cartapi.php" hash="79ce0dd04d329c2583d9c7f787d9b7f7"/></dir></dir><dir name="etc"><file name="api2.xml" hash="2dbf3da500930f58108bf9a9f87ec75f"/><file name="config.xml" hash="6dce6326329b06cc349316fdc7f1e8a1"/></dir></dir><dir name="Filters"><dir name="Model"><dir name="Api2"><dir name="Filters"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="9c86175283d31ad4991d3e22561c1a29"/></dir><dir name="Customer"><file name="V1.php" hash="63ae714a9128ae75fe4f0dc62f0f8212"/></dir><dir name="Guest"><file name="V1.php" hash="b04bd01daf25c8f0303fbee0601a55bc"/></dir></dir><file name="Rest.php" hash="705aadf18a53896bbb2cfce41a1b8102"/></dir><file name="Filters.php" hash="6c62d6da5fdddbcf7672c2260eb43636"/></dir></dir><dir name="etc"><file name="api2.xml" hash="c56047774d688915d3992226d395131d"/><file name="config.xml" hash="3c9507f5ba31aaf209c268557e9339b0"/></dir></dir><dir name="HomePageapi"><dir name="Model"><dir name="Api2"><dir name="HomePageapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="5eb5a39d75920703ef26975183a5f81d"/></dir><dir name="Customer"><file name="V1.php" hash="06e96d56de1c93c933a5c1865b0e43e7"/></dir><dir name="Guest"><file name="V1.php" hash="b76cf62bf759c748858ac11213e2d95d"/></dir></dir><file name="Rest.php" hash="764dc0c42c07a4fd35beef9159721a25"/></dir><file name="HomePageapi.php" hash="3599888ab1ba72ea10bee0793264b0fc"/></dir></dir><dir name="etc"><file name="api2.xml" hash="a7d1833752e198041c6bcb9ceac2c35f"/><file name="config.xml" hash="987e0202a5cf8d5650b2d1004277be2d"/></dir></dir><dir name="Login"><dir name="Model"><dir name="Api2"><dir name="Forgotpassword"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ed7ecb2d101124a3af996aa68ad4ae14"/></dir><dir name="Customer"><file name="V1.php" hash="1d9dde0cbb555ed9b2763265712e16f1"/></dir><dir name="Guest"><file name="V1.php" hash="b4f685ad6006e34e7761e8db39a1601e"/></dir></dir><file name="Rest.php" hash="b80db9b5f7f413bfa636d7f4da708e12"/></dir><file name="Forgotpassword.php" hash="ac9512f4102bdeb1314cdad651a02ea6"/><dir name="Login"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="e3fb6be3b3fe28194e227ec57ad5a186"/></dir><dir name="Customer"><file name="V1.php" hash="0ed601b8c568805da9312b97615d73a3"/></dir><dir name="Guest"><file name="V1.php" hash="d9631834e143659f579642fb671efa9d"/></dir></dir><file name="Rest.php" hash="79ffc7815aa51db77b342d01c0badfd4"/></dir><file name="Login.php" hash="d5efc4d011def0681330cea3741f446c"/></dir><dir name="Methods"><file name="Functions.php" hash="2dcaeddd01dc131660c2877745d571dd"/></dir><dir name="Resource"><dir name="Token"><file name="Collection.php" hash="d23102f756323dc0fcf56e725ad3affb"/></dir><file name="Token.php" hash="ed7ceb24bc163901207ed31106aa608c"/></dir><file name="Token.php" hash="9ff569b68c7fe3891a8a0e3021e2b82a"/></dir><dir name="etc"><file name="api2.xml" hash="6046abc7493543066b1d1fa824de0c5a"/><file name="config.xml" hash="3742f5c20e70c0bec8f659843d192df7"/></dir><dir name="sql"><dir name="login_setup"><file name="install-0.0.1.php" hash="c63d2093807a82d58ff96f7ff5a619a5"/></dir></dir></dir><dir name="MultiCartapi"><dir name="Model"><dir name="Api2"><dir name="MultiCartapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="bdae2062576a265a2dbb4a6e5c54ee2c"/></dir><dir name="Customer"><file name="V1.php" hash="ba637aedc8caa447f09847f6ff5b10bf"/></dir><dir name="Guest"><file name="V1.php" hash="324c03fcfc448472977123bd1875276a"/></dir></dir><file name="Rest.php" hash="90acb34b0dba704008a4baed584836f7"/></dir><file name="MultiCartapi.php" hash="77ddaaa100fa0f9861a5442cc4de392c"/></dir></dir><dir name="etc"><file name="api2.xml" hash="f7667c6f9f9123e908b304aaa5c83bf2"/><file name="config.xml" hash="661ba9f4224bd74555c5526f7c41154e"/></dir></dir><dir name="MyOrders"><dir name="Model"><dir name="Api2"><dir name="MyOrderapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="82927b08ae221b6277cdefdb21554f89"/></dir><dir name="Customer"><file name="V1.php" hash="d75f8b2801775a0401f1ec865b09a62f"/></dir><dir name="Guest"><file name="V1.php" hash="0f9a5558397ee4c5abe68c127cc65ba6"/></dir></dir><file name="Rest.php" hash="4be3db78f9081383ad2385b22d194405"/></dir><file name="MyOrderapi.php" hash="dd44b7d0b903e748b17a309a427cdd1b"/></dir></dir><dir name="etc"><file name="api2.xml" hash="87ef0d8a9ce4889870e10191a660884e"/><file name="config.xml" hash="9d884c040632d7c1ba6b3eb7258038f0"/></dir></dir><dir name="PlaceOrder"><dir name="Model"><dir name="Api2"><dir name="PlaceOrderapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="c124d62195ea7a653e7579f3dd96e2b6"/></dir><dir name="Customer"><file name="V1.php" hash="71c496a9ef5230f14f3f9777b990ab19"/></dir><dir name="Guest"><file name="V1.php" hash="b7b69c391c4784f0ac353574325fba0d"/></dir></dir><file name="Rest.php" hash="7636ec8af040e665b1553031dba50f98"/></dir><file name="PlaceOrderapi.php" hash="2b1ee9d65d9fc0813b456c3a9b8b5a74"/></dir></dir><dir name="etc"><file name="api2.xml" hash="6f5ca0ce6abe55c93604f6aada67e96d"/><file name="config.xml" hash="c072fca46b706bdaa1070c1b7cfd4112"/></dir></dir><dir name="ProductList"><dir name="Model"><dir name="Api2"><dir name="ProductList"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="0a49f28a84be01e71d9c1644d95b4c2b"/></dir><dir name="Guest"><file name="V1.php" hash="729240a7ec2eeff1a39a8061345edd56"/></dir></dir><file name="Rest.php" hash="0952e8c10b0815bc13e2fdd51b1fbc3e"/></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="88f6f2efd8285e34f641c3908481b0c0"/><file name="config.xml" hash="b2fef8859874c5505007f85733103c86"/></dir></dir><dir name="Registration"><dir name="Model"><dir name="Api2"><dir name="ChangePassword"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="04b3985e11a37c6f80310366d7276d4d"/></dir><dir name="Customer"><file name="V1.php" hash="df47bcb511a2c12deadfd444d1adc383"/></dir><dir name="Guest"><file name="V1.php" hash="87e0a4ff0c254135b83c810bdbd979c2"/></dir></dir><file name="Rest.php" hash="755ef8a11d74f0fca457115cd3801f6e"/></dir><dir name="Registration"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="2d960ebf6a581b3fd4ba29892f553d52"/></dir><dir name="Customer"><file name="V1.php" hash="6d81dde797e56696c5af656244dcac8b"/></dir><dir name="Guest"><file name="V1.php" hash="5d6bc426abc5c0b19c0668ccbfd3c021"/></dir></dir><file name="Rest.php" hash="c53396e643e5c25b20922b4d335bb57e"/></dir></dir></dir><dir name="etc"><file name="api2.xml" hash="67f9baac0ce159bf71f4b2f2a3566428"/><file name="config.xml" hash="3803604868540ff96f6ffdb3c7c09278"/></dir></dir><dir name="ReviewRating"><dir name="Model"><dir name="Api2"><dir name="ReviewRating"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="0b4dee4df40cebce802c92a56626d5ca"/></dir><dir name="Customer"><file name="V1.php" hash="0806b569367c814c269be3015781d65c"/></dir><dir name="Guest"><file name="V1.php" hash="57a1fa55ee5b2dba5d6d44afa7b432ec"/></dir></dir><file name="Rest.php" hash="e5812d28743261a30c30513b3b1c8d3b"/></dir><file name="ReviewRating.php" hash="fc9de1f5a5a587a2d715caf0cde60635"/></dir></dir><dir name="etc"><file name="api2.xml" hash="84d901a3715fd3c28f4214ecd4a69b42"/><file name="config.xml" hash="093a59ea31a58cb0f1ff118d86583179"/></dir></dir><dir name="SearchProducts"><dir name="Model"><dir name="Api2"><dir name="SearchProducts"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="ebe95d66e8935f824d50f10145d50a3a"/></dir><dir name="Customer"><file name="V1.php" hash="6549897f48909896ceb6f17d2544fc98"/></dir><dir name="Guest"><file name="V1.php" hash="0c333730ee604f6d9418e5452b80ad47"/></dir></dir><file name="Rest.php" hash="6b00435029dc3040d4d45717a7eaa36a"/></dir><file name="SearchProducts.php" hash="fb96c1cf81500bb23af8fd51b7a6f4f3"/></dir></dir><dir name="etc"><file name="api2.xml" hash="4e72d3f00586fea385ac425e7afc5a65"/><file name="config.xml" hash="08c2950ca36e9f719ea10a8e66b4ef36"/></dir></dir><dir name="ShippingPaymentapi"><dir name="Model"><dir name="Api2"><dir name="ShippingPaymentapi"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="a6e310b9e522eb2cba1ddca9bb01adbd"/></dir><dir name="Customer"><file name="V1.php" hash="c9b52a26bf774691a94459979d7981be"/></dir><dir name="Guest"><file name="V1.php" hash="d40b5e9c42b366e901eed11ef2bf2b50"/></dir></dir><file name="Rest.php" hash="e8ce41c58deeebaa87832c6d090594fa"/></dir><file name="ShippingPaymentapi.php" hash="6a55c62967503d7479dcd1534c26ea98"/></dir></dir><dir name="etc"><file name="api2.xml" hash="fcff0dcff1662fbc5b69d535d3865b93"/><file name="config.xml" hash="f449893d3b9ce99743f4f9df88957eee"/></dir></dir><dir name="SocialLogin"><dir name="Model"><dir name="Api2"><dir name="SocialLogin"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="504f5dacd99ab70df5fc0b977b3b1e9d"/></dir><dir name="Customer"><file name="V1.php" hash="0ed3fd7da081ddf3db38280a449df107"/></dir><dir name="Guest"><file name="V1.php" hash="a078c51f0a28754ef44ed49f22d45934"/></dir></dir><file name="Rest.php" hash="debf62f88f8eea1477ccdf7263e05839"/></dir><file name="SocialLogin.php" hash="dd17e5ddd2b8bfab2f122665a6f252bd"/></dir></dir><dir name="etc"><file name="api2.xml" hash="1ec20f146ee828ad924a8b5915186481"/><file name="config.xml" hash="bcc1a1ee0b876f6fcfa1e70533278dfc"/></dir></dir><dir name="Staticpages"><dir name="Model"><dir name="Api2"><dir name="Staticpages"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="daf94348a90bf00576d13f2395f44373"/></dir><dir name="Customer"><file name="V1.php" hash="e4345e55df3beb22a24b7a06bd0a7e60"/></dir><dir name="Guest"><file name="V1.php" hash="8d6f72cf5db3a3fe5def87cd9945e168"/></dir></dir><file name="Rest.php" hash="2d9e3ce4db5ebd695a36405918c54902"/></dir><file name="Staticpages.php" hash="a5a11a73b2941d15d7e8ca35d26984fc"/></dir></dir><dir name="etc"><file name="api2.xml" hash="a2a52f764e9020a4ae039ae0179609a7"/><file name="config.xml" hash="28491ccf1cfca21dadf91257cfbbbed4"/></dir></dir><dir name="Wishlistapi"><dir name="Model"><dir name="Api2"><dir name="Wishlist"><dir name="Rest"><dir name="Admin"><file name="V1.php" hash="f651beba4be1bc71ca9f67d8cb10cab3"/></dir><dir name="Customer"><file name="V1.php" hash="562cfde7040cfed53b787b0eab9e2a22"/></dir><dir name="Guest"><file name="V1.php" hash="851ad054c968702c9867cbe40570c434"/></dir></dir><file name="Rest.php" hash="53ee075545cb61fd4f24d5b83a03306f"/></dir><file name="Wishlist.php" hash="7fa68433ba0334c40fecb2893c557f46"/></dir></dir><dir name="etc"><file name="api2.xml" hash="77537ed8a65c37ade93c8eb13085e1b5"/><file name="config.xml" hash="d57983e6481f0bf170e8855ce56b673c"/></dir></dir></dir></dir><dir name="Contus"><dir name="Configuration"><dir><dir name="Block"><dir name="Adminhtml"><file name="About.php" hash="481fb6808dc558341b193c23139a2696"/></dir></dir><dir name="Helper"><file name="Data.php" hash="589c315c38ae37d76bb93b644d27738f"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Count.php" hash="01b7f7216f1a0ebc0997ba3f753296a0"/><file name="Homelist.php" hash="44d04a9f483e83d6273ed45694451630"/></dir><file name="Config.php" hash="9711c2896ebd37631855d03a4c5466f2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2ab511bfbb24399f66f92c5e129e93ed"/><file name="config.xml" hash="868cc56a8ba9fae0d4b5ca0ee3ea74e5"/><file name="system.xml" hash="c688db0d103e81e1cc8a0fb58b49f147"/></dir></dir></dir><dir name="Offers"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Offers"><dir name="Edit"><file name="Form.php" hash="ecc572cb365ef62b9658d0c7f67721f5"/><dir name="Tab"><file name="Form.php" hash="63e0168a8d5e7098bd8bac54dee15e96"/><file name="Productlist.php" hash="7aba8bae660fef8b16d37ecea0343a13"/></dir><file name="Tabs.php" hash="a357a8b708ab7c96f1f5200f7828f03f"/></dir><file name="Edit.php" hash="f3e49391b8b03a845b37cda0dcd8c616"/><file name="Grid.php" hash="e724024aea678311111d801b94696998"/><dir name="Renderer"><file name="Image.php" hash="cc37093e5c80cef280088d58c82b6470"/><file name="Notification.php" hash="c727f9a4fc45748c1c5bb53be3f78f06"/><file name="View.php" hash="a818c7e6c82efb3852e85cfc01103109"/></dir></dir><file name="Offers.php" hash="9a2d5c00bb5cfaf04fae9b0e1bf37813"/></dir><file name="Offers.php" hash="24ad7397a1a83adccfa81ab1b86546c4"/></dir><dir name="Helper"><file name="Data.php" hash="3400397d268933f11bb5f6b5ad745eaf"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Offers"><file name="Collection.php" hash="0b45658ccbd52447163e50a73bda2fdb"/></dir><file name="Offers.php" hash="a9cb9633c24d9e9283298fe865fbd926"/></dir><file name="Offers.php" hash="6178200d641970fc870d0c1869dfbcac"/><file name="Status.php" hash="74f9c981477bc89ec5cf8902c6a829d1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="OffersController.php" hash="d55933d6fa8a9bb7dab6078c01353db2"/></dir><file name="IndexController.php" hash="8ad61469cb056026c9450c550063d7ce"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a66266c8ea8f62aaea031291382eb000"/><file name="config.xml" hash="177be990abafa805f035ba2169db3a56"/></dir><dir name="sql"><dir name="offers_setup"><file name="mysql4-install-0.1.0.php" hash="9981e09f5acaafe1906875cdfb7b9258"/></dir></dir></dir></dir><dir name="Pushnoteorders"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Pushnoteorders"><file name="Edit.php" hash="1bddef98ed3cbb6c2257082c815dec1a"/><file name="Grid.php" hash="d8fc00d43a5187f3af89da63f9e404b6"/><dir name="Renderer"><file name="Notification.php" hash="79f97835ef176565e47ad19ada958e22"/><file name="View.php" hash="12034fa2c7178b6fe898d60b46fcb61f"/></dir></dir><file name="Pushnoteorders.php" hash="a7c1a0a2e5f5b39d8e5c781e508f9f56"/></dir><file name="Pushnoteorders.php" hash="0b16da26a98412686c1b9a4f762f1285"/></dir><dir name="Helper"><file name="Data.php" hash="e731245220b7b38db9f0fd31a40ae39e"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PushnoteordersController.php" hash="4ffeb67950d98498615412d31414c450"/></dir><file name="IndexController.php" hash="a36f49a983432759ba209b2d0b335bd6"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1ae517a1e0c037dfb43a50a9917e7c97"/><file name="config.xml" hash="fb2714db776c5a1021eb440317828d92"/></dir></dir></dir><dir name="Pushnoteproducts"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Pushnoteproducts"><file name="Edit.php" hash="cdf5a1dcbce0ad048faa1e9a33a8cdc9"/><file name="Grid.php" hash="ecf2f79fb04c2df52b99849b64244a07"/><dir name="Renderer"><file name="Notification.php" hash="7dbf8c30708cfa1d15a9cf941dfe0d97"/><file name="View.php" hash="f5cc64c42c5caf364921d51177f865d2"/></dir></dir><file name="Pushnoteproducts.php" hash="eb399595756eb635c1390ae985d2fb1d"/></dir><file name="Pushnoteproducts.php" hash="b9d833bc77da69e92098e3d9dadaddff"/></dir><dir name="Helper"><file name="Data.php" hash="8ffd99731b3d4a5dd12fa062f6b1db16"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PushnoteproductsController.php" hash="51b598caaecce3fe928d80e8364f2328"/></dir><file name="IndexController.php" hash="3cf009c3f2125552591c0c0558018297"/></dir><dir name="etc"><file name="config.xml" hash="384b48e0d97d58aad7bc4268aadee828"/></dir></dir></dir></dir></dir></target></contents>
|
17 |
+
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
+
</package>
|
paypal/PaymentGateway.php
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Payment Gateway
|
5 |
+
*
|
6 |
+
* This library provides generic payment gateway handling functionlity
|
7 |
+
* to the other payment gateway classes in an uniform way. Please have
|
8 |
+
* a look on them for the implementation details.
|
9 |
+
*
|
10 |
+
* @package Payment Gateway
|
11 |
+
* @category Library
|
12 |
+
* @author Md Emran Hasan <phpfour@gmail.com>
|
13 |
+
* @link http://www.phpfour.com
|
14 |
+
*/
|
15 |
+
|
16 |
+
abstract class PaymentGateway
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Holds the last error encountered
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
public $lastError;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Do we need to log IPN results ?
|
27 |
+
*
|
28 |
+
* @var boolean
|
29 |
+
*/
|
30 |
+
public $logIpn;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* File to log IPN results
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
public $ipnLogFile;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Payment gateway IPN response
|
41 |
+
*
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
public $ipnResponse;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Are we in test mode ?
|
48 |
+
*
|
49 |
+
* @var boolean
|
50 |
+
*/
|
51 |
+
public $testMode;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Field array to submit to gateway
|
55 |
+
*
|
56 |
+
* @var array
|
57 |
+
*/
|
58 |
+
public $fields = array();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* IPN post values as array
|
62 |
+
*
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
public $ipnData = array();
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Payment gateway URL
|
69 |
+
*
|
70 |
+
* @var string
|
71 |
+
*/
|
72 |
+
public $gatewayUrl;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Initialization constructor
|
76 |
+
*
|
77 |
+
* @param none
|
78 |
+
* @return void
|
79 |
+
*/
|
80 |
+
public function __construct()
|
81 |
+
{
|
82 |
+
// Some default values of the class
|
83 |
+
$this->lastError = '';
|
84 |
+
$this->logIpn = TRUE;
|
85 |
+
$this->ipnResponse = '';
|
86 |
+
$this->testMode = FALSE;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Adds a key=>value pair to the fields array
|
91 |
+
*
|
92 |
+
* @param string key of field
|
93 |
+
* @param string value of field
|
94 |
+
* @return
|
95 |
+
*/
|
96 |
+
public function addField($field, $value)
|
97 |
+
{
|
98 |
+
$this->fields["$field"] = $value;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Submit Payment Request
|
103 |
+
*
|
104 |
+
* Generates a form with hidden elements from the fields array
|
105 |
+
* and submits it to the payment gateway URL. The user is presented
|
106 |
+
* a redirecting message along with a button to click.
|
107 |
+
*
|
108 |
+
* @param none
|
109 |
+
* @return void
|
110 |
+
*/
|
111 |
+
public function submitPayment()
|
112 |
+
{
|
113 |
+
|
114 |
+
$this->prepareSubmit();
|
115 |
+
|
116 |
+
echo "<html>\n";
|
117 |
+
echo "<head><title>Processing Payment...</title></head>\n";
|
118 |
+
echo "<body onLoad=\"document.forms['gateway_form'].submit();\">\n";
|
119 |
+
echo "<p style=\"text-align:center;\"><h2>Please wait, your order is being processed and you";
|
120 |
+
echo " will be redirected to the payment website.</h2></p>\n";
|
121 |
+
echo "<form method=\"POST\" name=\"gateway_form\" ";
|
122 |
+
echo "action=\"" . $this->gatewayUrl . "\">\n";
|
123 |
+
|
124 |
+
foreach ($this->fields as $name => $value)
|
125 |
+
{
|
126 |
+
echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n";
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
echo "<p style=\"text-align:center;\"><br/><br/>If you are not automatically redirected to ";
|
131 |
+
echo "payment website within 5 seconds...<br/><br/>\n";
|
132 |
+
echo "<input type=\"submit\" value=\"Click Here\"></p>\n";
|
133 |
+
|
134 |
+
echo "</form>\n";
|
135 |
+
echo "</body></html>\n";
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Perform any pre-posting actions
|
140 |
+
*
|
141 |
+
* @param none
|
142 |
+
* @return none
|
143 |
+
*/
|
144 |
+
protected function prepareSubmit()
|
145 |
+
{
|
146 |
+
// Fill if needed
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Enables the test mode
|
151 |
+
*
|
152 |
+
* @param none
|
153 |
+
* @return none
|
154 |
+
*/
|
155 |
+
abstract protected function enableTestMode();
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Validate the IPN notification
|
159 |
+
*
|
160 |
+
* @param none
|
161 |
+
* @return boolean
|
162 |
+
*/
|
163 |
+
abstract protected function validateIpn();
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Logs the IPN results
|
167 |
+
*
|
168 |
+
* @param boolean IPN result
|
169 |
+
* @return void
|
170 |
+
*/
|
171 |
+
public function logResults($success)
|
172 |
+
{
|
173 |
+
|
174 |
+
if (!$this->logIpn) return;
|
175 |
+
|
176 |
+
// Timestamp
|
177 |
+
$text = '[' . date('m/d/Y g:i A').'] - ';
|
178 |
+
|
179 |
+
// Success or failure being logged?
|
180 |
+
$text .= ($success) ? "SUCCESS!\n" : 'FAIL: ' . $this->lastError . "\n";
|
181 |
+
|
182 |
+
// Log the POST variables
|
183 |
+
$text .= "IPN POST Vars from gateway:\n";
|
184 |
+
foreach ($this->ipnData as $key=>$value)
|
185 |
+
{
|
186 |
+
$text .= "$key=$value, ";
|
187 |
+
}
|
188 |
+
|
189 |
+
// Log the response from the paypal server
|
190 |
+
$text .= "\nIPN Response from gateway Server:\n " . $this->ipnResponse;
|
191 |
+
|
192 |
+
// Write to log
|
193 |
+
$fp = fopen($this->ipnLogFile,'a');
|
194 |
+
fwrite($fp, $text . "\n\n");
|
195 |
+
fclose($fp);
|
196 |
+
}
|
197 |
+
}
|
paypal/Paypal.php
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Paypal Class
|
5 |
+
*
|
6 |
+
* Integrate the Paypal payment gateway in your site using this easy
|
7 |
+
* to use library. Just see the example code to know how you should
|
8 |
+
* proceed. Btw, this library does not support the recurring payment
|
9 |
+
* system. If you need that, drop me a note and I will send to you.
|
10 |
+
*
|
11 |
+
* @package Payment Gateway
|
12 |
+
* @category Library
|
13 |
+
* @author Md Emran Hasan <phpfour@gmail.com>
|
14 |
+
* @link http://www.phpfour.com
|
15 |
+
*/
|
16 |
+
|
17 |
+
include_once ('PaymentGateway.php');
|
18 |
+
|
19 |
+
class Paypal extends PaymentGateway
|
20 |
+
{
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Initialize the Paypal gateway
|
24 |
+
*
|
25 |
+
* @param none
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
public function __construct()
|
29 |
+
{
|
30 |
+
parent::__construct();
|
31 |
+
|
32 |
+
// Some default values of the class
|
33 |
+
$this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr';
|
34 |
+
$this->ipnLogFile = 'paypal.ipn_results.log';
|
35 |
+
|
36 |
+
// Populate $fields array with a few default
|
37 |
+
$this->addField('rm', '2'); // Return method = POST
|
38 |
+
$this->addField('cmd', '_xclick');
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Enables the test mode
|
43 |
+
*
|
44 |
+
* @param none
|
45 |
+
* @return none
|
46 |
+
*/
|
47 |
+
public function enableTestMode()
|
48 |
+
{
|
49 |
+
$this->testMode = TRUE;
|
50 |
+
$this->gatewayUrl = 'https://www.paypal.com/cgi-bin/webscr';
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Validate the IPN notification
|
55 |
+
*
|
56 |
+
* @param none
|
57 |
+
* @return boolean
|
58 |
+
*/
|
59 |
+
public function validateIpn()
|
60 |
+
{
|
61 |
+
// parse the paypal URL
|
62 |
+
$urlParsed = parse_url($this->gatewayUrl);
|
63 |
+
|
64 |
+
// generate the post string from the _POST vars
|
65 |
+
$postString = '';
|
66 |
+
|
67 |
+
foreach ($_POST as $field=>$value)
|
68 |
+
{
|
69 |
+
$this->ipnData["$field"] = $value;
|
70 |
+
$postString .= $field .'=' . urlencode(stripslashes($value)) . '&';
|
71 |
+
}
|
72 |
+
|
73 |
+
$postString .="cmd=_notify-validate"; // append ipn command
|
74 |
+
|
75 |
+
// open the connection to paypal
|
76 |
+
$fp = fsockopen($urlParsed[host], "80", $errNum, $errStr, 30);
|
77 |
+
|
78 |
+
if(!$fp)
|
79 |
+
{
|
80 |
+
// Could not open the connection, log error if enabled
|
81 |
+
$this->lastError = "fsockopen error no. $errNum: $errStr";
|
82 |
+
$this->logResults(false);
|
83 |
+
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
else
|
87 |
+
{
|
88 |
+
// Post the data back to paypal
|
89 |
+
|
90 |
+
fputs($fp, "POST $urlParsed[path] HTTP/1.1\r\n");
|
91 |
+
fputs($fp, "Host: $urlParsed[host]\r\n");
|
92 |
+
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
|
93 |
+
fputs($fp, "Content-length: " . strlen($postString) . "\r\n");
|
94 |
+
fputs($fp, "Connection: close\r\n\r\n");
|
95 |
+
fputs($fp, $postString . "\r\n\r\n");
|
96 |
+
|
97 |
+
// loop through the response from the server and append to variable
|
98 |
+
while(!feof($fp))
|
99 |
+
{
|
100 |
+
$this->ipnResponse .= fgets($fp, 1024);
|
101 |
+
}
|
102 |
+
|
103 |
+
fclose($fp); // close connection
|
104 |
+
}
|
105 |
+
|
106 |
+
if (eregi("VERIFIED", $this->ipnResponse))
|
107 |
+
{
|
108 |
+
// Valid IPN transaction.
|
109 |
+
$this->logResults(true);
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
else
|
113 |
+
{
|
114 |
+
// Invalid IPN transaction. Check the log for details.
|
115 |
+
$this->lastError = "IPN Validation Failed . $urlParsed[path] : $urlParsed[host]";
|
116 |
+
$this->logResults(false);
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
paypal/cancel.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<meta content='True' name='HandheldFriendly' />
|
4 |
+
<meta content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' name='viewport' />
|
5 |
+
</head>
|
6 |
+
<body>
|
7 |
+
<center> <h2>Order Has Been Cancelled</h2></center>
|
8 |
+
|
9 |
+
</body>
|
10 |
+
</html>
|
paypal/ipn.php
ADDED
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require '../app/Mage.php';
|
3 |
+
|
4 |
+
Mage::App (); // might be "default"
|
5 |
+
$_SERVER ['SCRIPT_NAME'] = str_replace ( basename ( __FILE__ ), 'index.php', $_SERVER ['SCRIPT_NAME'] );
|
6 |
+
$_SERVER ['SCRIPT_FILENAME'] = str_replace ( basename ( __FILE__ ), 'index.php', $_SERVER ['SCRIPT_FILENAME'] );
|
7 |
+
// $explodeDetail = explode('-',$_SESSION['pxpayval']);
|
8 |
+
|
9 |
+
$transaction_id = $_POST ['verify_sign'];
|
10 |
+
$order_id = $_POST ['invoice'];
|
11 |
+
$status = $_POST ['payment_status'];
|
12 |
+
$email = $_POST ['payer_email'];
|
13 |
+
$name = $_POST ['first_name'];
|
14 |
+
$pendingreason = $_POST ['pending_reason'];
|
15 |
+
$txnid = $_POST ['txn_id'];
|
16 |
+
$mcgross = $_POST ['mc_gross'];
|
17 |
+
$refundreason = $_POST ['reason_code'];
|
18 |
+
|
19 |
+
$verified = false;
|
20 |
+
// Check to see there are posted variables coming into the script
|
21 |
+
if ($_SERVER ['REQUEST_METHOD'] != "POST")
|
22 |
+
die ( "No Post Variables" );
|
23 |
+
|
24 |
+
// CONFIG: Enable debug mode. This means we'll log requests into 'ipn.log' in the same directory.
|
25 |
+
// Especially useful if you encounter network errors or other intermittent problems with IPN (validation).
|
26 |
+
// Set this to 0 once you go live or don't require logging.
|
27 |
+
define ( "DEBUG", 1 );
|
28 |
+
// Set to 0 once you're ready to go live
|
29 |
+
define ( "USE_SANDBOX", 1 );
|
30 |
+
define ( "LOG_FILE", "./ipn.log" );
|
31 |
+
// Read POST data
|
32 |
+
// reading posted data directly from $_POST causes serialization
|
33 |
+
// issues with array data in POST. Reading raw POST data from input stream instead.
|
34 |
+
$raw_post_data = file_get_contents ( 'php://input' );
|
35 |
+
$raw_post_array = explode ( '&', $raw_post_data );
|
36 |
+
$myPost = array ();
|
37 |
+
foreach ( $raw_post_array as $keyval ) {
|
38 |
+
$keyval = explode ( '=', $keyval );
|
39 |
+
if (count ( $keyval ) == 2)
|
40 |
+
$myPost [$keyval [0]] = urldecode ( $keyval [1] );
|
41 |
+
}
|
42 |
+
// read the post from PayPal system and add 'cmd'
|
43 |
+
$req = 'cmd=_notify-validate';
|
44 |
+
if (function_exists ( 'get_magic_quotes_gpc' )) {
|
45 |
+
$get_magic_quotes_exists = true;
|
46 |
+
}
|
47 |
+
foreach ( $myPost as $key => $value ) {
|
48 |
+
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc () == 1) {
|
49 |
+
$value = urlencode ( stripslashes ( $value ) );
|
50 |
+
} else {
|
51 |
+
$value = urlencode ( $value );
|
52 |
+
}
|
53 |
+
$req .= "&$key=$value";
|
54 |
+
}
|
55 |
+
// Post IPN data back to PayPal to validate the IPN data is genuine
|
56 |
+
// Without this step anyone can fake IPN data
|
57 |
+
if (USE_SANDBOX == true) {
|
58 |
+
$paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
|
59 |
+
} else {
|
60 |
+
$paypal_url = "https://www.paypal.com/cgi-bin/webscr";
|
61 |
+
}
|
62 |
+
$ch = curl_init ( $paypal_url );
|
63 |
+
if ($ch == FALSE) {
|
64 |
+
return FALSE;
|
65 |
+
$verified = false;
|
66 |
+
}
|
67 |
+
curl_setopt ( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
|
68 |
+
curl_setopt ( $ch, CURLOPT_POST, 1 );
|
69 |
+
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
70 |
+
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $req );
|
71 |
+
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
|
72 |
+
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
|
73 |
+
curl_setopt ( $ch, CURLOPT_FORBID_REUSE, 1 );
|
74 |
+
if (DEBUG == true) {
|
75 |
+
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
|
76 |
+
curl_setopt ( $ch, CURLINFO_HEADER_OUT, 1 );
|
77 |
+
}
|
78 |
+
// CONFIG: Optional proxy configuration
|
79 |
+
// curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
80 |
+
// curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
|
81 |
+
// Set TCP timeout to 30 seconds
|
82 |
+
curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 30 );
|
83 |
+
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
|
84 |
+
'Connection: Close'
|
85 |
+
) );
|
86 |
+
// CONFIG: Please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
|
87 |
+
// of the certificate as shown below. Ensure the file is readable by the webserver.
|
88 |
+
// This is mandatory for some environments.
|
89 |
+
// $cert = __DIR__ . "./cacert.pem";
|
90 |
+
// curl_setopt($ch, CURLOPT_CAINFO, $cert);
|
91 |
+
$res = curl_exec ( $ch );
|
92 |
+
if (curl_errno ( $ch ) != 0) // cURL error
|
93 |
+
{
|
94 |
+
if (DEBUG == true) {
|
95 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "Can't connect to PayPal to validate IPN message: " . curl_error ( $ch ) . PHP_EOL, 3, LOG_FILE );
|
96 |
+
}
|
97 |
+
curl_close ( $ch );
|
98 |
+
$verified = false;
|
99 |
+
} else {
|
100 |
+
// Log the entire HTTP response if debug is switched on.
|
101 |
+
if (DEBUG == true) {
|
102 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "HTTP request of validation request:" . curl_getinfo ( $ch, CURLINFO_HEADER_OUT ) . " for IPN payload: $req" . PHP_EOL, 3, LOG_FILE );
|
103 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "HTTP response of validation request: $res" . PHP_EOL, 3, LOG_FILE );
|
104 |
+
}
|
105 |
+
curl_close ( $ch );
|
106 |
+
}
|
107 |
+
// Inspect IPN validation result and act accordingly
|
108 |
+
// Split response headers and payload, a better way for strcmp
|
109 |
+
$tokens = explode ( "\r\n\r\n", trim ( $res ) );
|
110 |
+
$res = trim ( end ( $tokens ) );
|
111 |
+
if (strcmp ( $res, "VERIFIED" ) == 0) {
|
112 |
+
// check whether the payment_status is Completed
|
113 |
+
// check that txn_id has not been previously processed
|
114 |
+
// check that receiver_email is your PayPal email
|
115 |
+
// check that payment_amount/payment_currency are correct
|
116 |
+
// process payment and mark item as paid.
|
117 |
+
// assign posted variables to local variables
|
118 |
+
// $item_name = $_POST['item_name'];
|
119 |
+
// $item_number = $_POST['item_number'];
|
120 |
+
// $payment_status = $_POST['payment_status'];
|
121 |
+
// $payment_amount = $_POST['mc_gross'];
|
122 |
+
// $payment_currency = $_POST['mc_currency'];
|
123 |
+
// $txn_id = $_POST['txn_id'];
|
124 |
+
// $receiver_email = $_POST['receiver_email'];
|
125 |
+
// $payer_email = $_POST['payer_email'];
|
126 |
+
|
127 |
+
if (DEBUG == true) {
|
128 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "Verified IPN: $req " . PHP_EOL, 3, LOG_FILE );
|
129 |
+
}
|
130 |
+
$verified = true;
|
131 |
+
} else if (strcmp ( $res, "INVALID" ) == 0) {
|
132 |
+
|
133 |
+
// log for manual investigation
|
134 |
+
// Add business logic here which deals with invalid IPN messages
|
135 |
+
if (DEBUG == true) {
|
136 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "Invalid IPN: $req" . PHP_EOL, 3, LOG_FILE );
|
137 |
+
}
|
138 |
+
$verified = false;
|
139 |
+
} else {
|
140 |
+
$verified = false;
|
141 |
+
|
142 |
+
error_log ( date ( '[Y-m-d H:i e] ' ) . "Error IPN: $req" . PHP_EOL, 3, LOG_FILE );
|
143 |
+
}
|
144 |
+
|
145 |
+
/*
|
146 |
+
* CHECK THESE 4 THINGS BEFORE PROCESSING THE TRANSACTION, HANDLE THEM AS YOU WISH 1. Make sure that business email returned is your business email 2. Make sure that the transaction�s payment status is �completed� 3. Make sure there are no duplicate txn_id 4. Make sure the payment amount matches what you charge for items. (Defeat Price-Jacking)
|
147 |
+
*/
|
148 |
+
|
149 |
+
// Check Number 1 ------------------------------------------------------------------------------------------------------------
|
150 |
+
$receiver_email = $_POST ['receiver_email'];
|
151 |
+
if ($receiver_email != "subhasini@contus.in") {
|
152 |
+
fwrite ( $fh, 'business email returned is not your business email' );
|
153 |
+
$verified = false;
|
154 |
+
// handle the wrong business url
|
155 |
+
} else {
|
156 |
+
$verified = true;
|
157 |
+
}
|
158 |
+
|
159 |
+
// Check number 2 ------------------------------------------------------------------------------------------------------------
|
160 |
+
$order = Mage::getModel ( 'sales/order' )->loadByIncrementId ( $order_id );
|
161 |
+
|
162 |
+
if ($verified) {
|
163 |
+
|
164 |
+
if ($order->getId ()) {
|
165 |
+
|
166 |
+
if (! $order->getEmailSent ()) {
|
167 |
+
$order->sendNewOrderEmail ();
|
168 |
+
$order->setEmailSent ( true );
|
169 |
+
$order->save ();
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
$payment = $order->getPayment ();
|
174 |
+
|
175 |
+
$myvalue = " case==>" . $status;
|
176 |
+
fwrite ( $fh, $myvalue );
|
177 |
+
try {
|
178 |
+
switch ($status) {
|
179 |
+
case 'Completed' :
|
180 |
+
|
181 |
+
$payment->setTransactionId ( $txnid )->setParentTransactionId ( $txnid )->setShouldCloseParentTransaction ( 'Completed' === $status )->setIsTransactionClosed ( 0 )->registerCaptureNotification ( $mcgross );
|
182 |
+
$order->save ();
|
183 |
+
|
184 |
+
// notify customer
|
185 |
+
|
186 |
+
$invoice = $payment->getCreatedInvoice ();
|
187 |
+
if ($invoice && ! $order->getEmailSent ()) {
|
188 |
+
$order->sendNewOrderEmail ()->addStatusHistoryComment ( Mage::helper ( 'paypal' )->__ ( 'Notified customer about invoice #%s.', $invoice->getIncrementId () ) )->setIsCustomerNotified ( true )->save ();
|
189 |
+
}
|
190 |
+
|
191 |
+
break;
|
192 |
+
case 'Denied' :
|
193 |
+
$myvalue = "denied case" . $status;
|
194 |
+
fwrite ( $fh, $myvalue );
|
195 |
+
$payment->setTransactionId ( $txnid )->setNotificationResult ( true )->setIsTransactionClosed ( true )->registerPaymentReviewAction ( Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, false );
|
196 |
+
$order->save ();
|
197 |
+
|
198 |
+
break;
|
199 |
+
case 'Failed' :
|
200 |
+
|
201 |
+
$order->registerCancellation ( createIpnComment ( $status ), false )->save ();
|
202 |
+
|
203 |
+
break;
|
204 |
+
case 'Reversed' :
|
205 |
+
$myvalue = "reversed case" . $status;
|
206 |
+
fwrite ( $fh, $myvalue );
|
207 |
+
break;
|
208 |
+
case 'Canceled_Reversal' :
|
209 |
+
// $myvalue = "Canceled_Reversal case".$status;
|
210 |
+
// fwrite($fh, $myvalue);
|
211 |
+
break;
|
212 |
+
case 'Refunded' :
|
213 |
+
|
214 |
+
$reason = $refundreason;
|
215 |
+
$myvalue = "refund case" . $refundreason;
|
216 |
+
fwrite ( $fh, $myvalue );
|
217 |
+
$isRefundFinal = ! 0;
|
218 |
+
$payment->setPreparedMessage ( createIpnComment ( $reason ) )->setTransactionId ( $txnid )->setParentTransactionId ( $txnid )->setIsTransactionClosed ( $isRefundFinal )->registerRefundNotification ( - 1 * $mcgross );
|
219 |
+
$order->save ();
|
220 |
+
|
221 |
+
// TODO: there is no way to close a capture right now
|
222 |
+
|
223 |
+
if ($creditmemo = $payment->getCreatedCreditmemo ()) {
|
224 |
+
$creditmemo->sendEmail ();
|
225 |
+
$comment = $order->addStatusHistoryComment ( Mage::helper ( 'paypal' )->__ ( 'Notified customer about creditmemo #%s.', $creditmemo->getIncrementId () ) )->setIsCustomerNotified ( true )->save ();
|
226 |
+
}
|
227 |
+
|
228 |
+
break;
|
229 |
+
case 'Pending' :
|
230 |
+
|
231 |
+
$reason = $pendingreason;
|
232 |
+
if ('authorization' === $reason) {
|
233 |
+
registerPaymentAuthorization ();
|
234 |
+
return;
|
235 |
+
}
|
236 |
+
if ('order' === $reason) {
|
237 |
+
throw new Exception ( 'The "order" authorizations are not implemented.' );
|
238 |
+
}
|
239 |
+
|
240 |
+
// case when was placed using PayPal standard
|
241 |
+
if (Mage_Sales_Model_Order::STATE_PENDING_PAYMENT == $order->getState ()) {
|
242 |
+
}
|
243 |
+
|
244 |
+
$payment->setPreparedMessage ( createIpnComment ( explainPendingReason ( $reason ) ) )->setTransactionId ( $txnid )->setIsTransactionClosed ( 0 )->registerPaymentReviewAction ( Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false );
|
245 |
+
$order->save ();
|
246 |
+
|
247 |
+
$order->setState ( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT );
|
248 |
+
$order->setStatus ( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT );
|
249 |
+
|
250 |
+
$message = Mage::helper ( 'paypal' )->__ ( 'Payment pending#%s.', $order_id );
|
251 |
+
$order->addStatusToHistory ( $status, $message, true );
|
252 |
+
$order->save ();
|
253 |
+
|
254 |
+
break;
|
255 |
+
case 'Processed' :
|
256 |
+
$myvalue = "Processed";
|
257 |
+
fwrite ( $fh, $myvalue );
|
258 |
+
$comment = createIpnComment ( '', true );
|
259 |
+
$comment->save ();
|
260 |
+
break;
|
261 |
+
case 'Voided' :
|
262 |
+
$myvalue = "Voided";
|
263 |
+
fwrite ( $fh, $myvalue );
|
264 |
+
$payment->getPayment ()->setPreparedMessage ( createIpnComment ( '' ) )->setParentTransactionId ( $txnid )->registerVoidNotification ();
|
265 |
+
|
266 |
+
$order->save ();
|
267 |
+
|
268 |
+
break;
|
269 |
+
default :
|
270 |
+
$myvalue2 = "default";
|
271 |
+
fwrite ( $fh, $myvalue2 );
|
272 |
+
$order->setState ( Mage_Sales_Model_Order::STATE_CANCELED );
|
273 |
+
$order->setStatus ( Mage_Sales_Model_Order::STATE_CANCELED );
|
274 |
+
|
275 |
+
break;
|
276 |
+
}
|
277 |
+
} catch ( Mage_Core_Exception $e ) {
|
278 |
+
$myvalue1 = "ex" . $e->getMessage ();
|
279 |
+
fwrite ( $fh, $myvalue1 );
|
280 |
+
$comment = createIpnComment ( Mage::helper ( 'paypal' )->__ ( 'Note: %s', $e->getMessage () ), true );
|
281 |
+
$comment->save ();
|
282 |
+
throw $e;
|
283 |
+
}
|
284 |
+
} else {
|
285 |
+
}
|
286 |
+
function registerPaymentAuthorization() {
|
287 |
+
$order->getPayment ()->setPreparedMessage ( $createIpnComment ( '' ) )->setTransactionId ( $txnid )->setParentTransactionId ( $txnid )->setIsTransactionClosed ( 0 )->registerAuthorizationNotification ( $mcgross );
|
288 |
+
if (! $_order->getEmailSent ()) {
|
289 |
+
$_order->sendNewOrderEmail ();
|
290 |
+
}
|
291 |
+
$order->save ();
|
292 |
+
}
|
293 |
+
function createIpnComment($paymentStatus) {
|
294 |
+
$comment = '';
|
295 |
+
$addToHistory = false;
|
296 |
+
|
297 |
+
$message = Mage::helper ( 'paypal' )->__ ( 'IPN ' . $order_id . '"%s".', $paymentStatus );
|
298 |
+
if ($comment) {
|
299 |
+
$message .= ' ' . $comment;
|
300 |
+
}
|
301 |
+
if ($addToHistory) {
|
302 |
+
$message = $order->addStatusHistoryComment ( $message );
|
303 |
+
$message->setIsCustomerNotified ( null );
|
304 |
+
}
|
305 |
+
return $message;
|
306 |
+
}
|
307 |
+
|
308 |
+
?>
|
paypal/ipnlistener.php
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PayPal IPN Listener
|
4 |
+
*
|
5 |
+
* A class to listen for and handle Instant Payment Notifications (IPN) from
|
6 |
+
* the PayPal server.
|
7 |
+
*
|
8 |
+
* https://github.com/Quixotix/PHP-PayPal-IPN
|
9 |
+
*
|
10 |
+
* @package PHP-PayPal-IPN
|
11 |
+
* @author Micah Carrick
|
12 |
+
* @copyright (c) 2011 - Micah Carrick
|
13 |
+
* @version 2.0.3
|
14 |
+
* @license http://opensource.org/licenses/gpl-3.0.html
|
15 |
+
*/
|
16 |
+
class IpnListener {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* If true, the recommended cURL PHP library is used to send the post back
|
20 |
+
* to PayPal. If flase then fsockopen() is used. Default true.
|
21 |
+
*
|
22 |
+
* @var boolean
|
23 |
+
*/
|
24 |
+
public $use_curl = true;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* If true, explicitly sets cURL to use SSL version 3. Use this if cURL
|
28 |
+
* is compiled with GnuTLS SSL.
|
29 |
+
*
|
30 |
+
* @var boolean
|
31 |
+
*/
|
32 |
+
public $force_ssl_v3 = false;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* If true, an SSL secure connection (port 443) is used for the post back
|
36 |
+
* as recommended by PayPal. If false, a standard HTTP (port 80) connection
|
37 |
+
* is used. Default true.
|
38 |
+
*
|
39 |
+
* @var boolean
|
40 |
+
*/
|
41 |
+
public $use_ssl = true;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* If true, the paypal sandbox URI www.sandbox.paypal.com is used for the
|
45 |
+
* post back. If false, the live URI www.paypal.com is used. Default false.
|
46 |
+
*
|
47 |
+
* @var boolean
|
48 |
+
*/
|
49 |
+
public $use_sandbox = false;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The amount of time, in seconds, to wait for the PayPal server to respond
|
53 |
+
* before timing out. Default 30 seconds.
|
54 |
+
*
|
55 |
+
* @var int
|
56 |
+
*/
|
57 |
+
public $timeout = 30;
|
58 |
+
|
59 |
+
private $post_data = array();
|
60 |
+
private $post_uri = '';
|
61 |
+
private $response_status = '';
|
62 |
+
private $response = '';
|
63 |
+
|
64 |
+
const PAYPAL_HOST = 'www.paypal.com';
|
65 |
+
const SANDBOX_HOST = 'www.sandbox.paypal.com';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Post Back Using cURL
|
69 |
+
*
|
70 |
+
* Sends the post back to PayPal using the cURL library. Called by
|
71 |
+
* the processIpn() method if the use_curl property is true. Throws an
|
72 |
+
* exception if the post fails. Populates the response, response_status,
|
73 |
+
* and post_uri properties on success.
|
74 |
+
*
|
75 |
+
* @param string The post data as a URL encoded string
|
76 |
+
*/
|
77 |
+
protected function curlPost($encoded_data) {
|
78 |
+
|
79 |
+
if ($this->use_ssl) {
|
80 |
+
$uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
|
81 |
+
$this->post_uri = $uri;
|
82 |
+
} else {
|
83 |
+
$uri = 'http://'.$this->getPaypalHost().'/cgi-bin/webscr';
|
84 |
+
$this->post_uri = $uri;
|
85 |
+
}
|
86 |
+
|
87 |
+
$ch = curl_init();
|
88 |
+
|
89 |
+
curl_setopt($ch, CURLOPT_URL, $uri);
|
90 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
91 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
92 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
|
93 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
94 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
|
95 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
96 |
+
curl_setopt($ch, CURLOPT_HEADER, true);
|
97 |
+
|
98 |
+
if ($this->force_ssl_v3) {
|
99 |
+
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
|
100 |
+
}
|
101 |
+
|
102 |
+
$this->response = curl_exec($ch);
|
103 |
+
$this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
|
104 |
+
|
105 |
+
if ($this->response === false || $this->response_status == '0') {
|
106 |
+
$errno = curl_errno($ch);
|
107 |
+
$errstr = curl_error($ch);
|
108 |
+
throw new Exception("cURL error: [$errno] $errstr");
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Post Back Using fsockopen()
|
114 |
+
*
|
115 |
+
* Sends the post back to PayPal using the fsockopen() function. Called by
|
116 |
+
* the processIpn() method if the use_curl property is false. Throws an
|
117 |
+
* exception if the post fails. Populates the response, response_status,
|
118 |
+
* and post_uri properties on success.
|
119 |
+
*
|
120 |
+
* @param string The post data as a URL encoded string
|
121 |
+
*/
|
122 |
+
protected function fsockPost($encoded_data) {
|
123 |
+
|
124 |
+
if ($this->use_ssl) {
|
125 |
+
$uri = 'ssl://'.$this->getPaypalHost();
|
126 |
+
$port = '443';
|
127 |
+
$this->post_uri = $uri.'/cgi-bin/webscr';
|
128 |
+
} else {
|
129 |
+
$uri = $this->getPaypalHost(); // no "http://" in call to fsockopen()
|
130 |
+
$port = '80';
|
131 |
+
$this->post_uri = 'http://'.$uri.'/cgi-bin/webscr';
|
132 |
+
}
|
133 |
+
|
134 |
+
$fp = fsockopen($uri, $port, $errno, $errstr, $this->timeout);
|
135 |
+
|
136 |
+
if (!$fp) {
|
137 |
+
// fsockopen error
|
138 |
+
throw new Exception("fsockopen error: [$errno] $errstr");
|
139 |
+
}
|
140 |
+
|
141 |
+
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
|
142 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
143 |
+
$header .= "Content-Length: ".strlen($encoded_data)."\r\n";
|
144 |
+
$header .= "Connection: Close\r\n\r\n";
|
145 |
+
|
146 |
+
fputs($fp, $header.$encoded_data."\r\n\r\n");
|
147 |
+
|
148 |
+
while(!feof($fp)) {
|
149 |
+
if (empty($this->response)) {
|
150 |
+
// extract HTTP status from first line
|
151 |
+
$this->response .= $status = fgets($fp, 1024);
|
152 |
+
$this->response_status = trim(substr($status, 9, 4));
|
153 |
+
} else {
|
154 |
+
$this->response .= fgets($fp, 1024);
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
fclose($fp);
|
159 |
+
}
|
160 |
+
|
161 |
+
private function getPaypalHost() {
|
162 |
+
if ($this->use_sandbox) return IpnListener::SANDBOX_HOST;
|
163 |
+
else return IpnListener::PAYPAL_HOST;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Get POST URI
|
168 |
+
*
|
169 |
+
* Returns the URI that was used to send the post back to PayPal. This can
|
170 |
+
* be useful for troubleshooting connection problems. The default URI
|
171 |
+
* would be "ssl://www.sandbox.paypal.com:443/cgi-bin/webscr"
|
172 |
+
*
|
173 |
+
* @return string
|
174 |
+
*/
|
175 |
+
public function getPostUri() {
|
176 |
+
return $this->post_uri;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Get Response
|
181 |
+
*
|
182 |
+
* Returns the entire response from PayPal as a string including all the
|
183 |
+
* HTTP headers.
|
184 |
+
*
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
public function getResponse() {
|
188 |
+
return $this->response;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Get Response Status
|
193 |
+
*
|
194 |
+
* Returns the HTTP response status code from PayPal. This should be "200"
|
195 |
+
* if the post back was successful.
|
196 |
+
*
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
public function getResponseStatus() {
|
200 |
+
return $this->response_status;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get Text Report
|
205 |
+
*
|
206 |
+
* Returns a report of the IPN transaction in plain text format. This is
|
207 |
+
* useful in emails to order processors and system administrators. Override
|
208 |
+
* this method in your own class to customize the report.
|
209 |
+
*
|
210 |
+
* @return string
|
211 |
+
*/
|
212 |
+
public function getTextReport() {
|
213 |
+
|
214 |
+
$r = '';
|
215 |
+
|
216 |
+
// date and POST url
|
217 |
+
for ($i=0; $i<80; $i++) { $r .= '-'; }
|
218 |
+
$r .= "\n[".date('m/d/Y g:i A').'] - '.$this->getPostUri();
|
219 |
+
if ($this->use_curl) $r .= " (curl)\n";
|
220 |
+
else $r .= " (fsockopen)\n";
|
221 |
+
|
222 |
+
// HTTP Response
|
223 |
+
for ($i=0; $i<80; $i++) { $r .= '-'; }
|
224 |
+
$r .= "\n{$this->getResponse()}\n";
|
225 |
+
|
226 |
+
// POST vars
|
227 |
+
for ($i=0; $i<80; $i++) { $r .= '-'; }
|
228 |
+
$r .= "\n";
|
229 |
+
|
230 |
+
foreach ($this->post_data as $key => $value) {
|
231 |
+
if($key == 'transaction'){
|
232 |
+
foreach ($value as $k => $v) {
|
233 |
+
$r .= str_pad($k, 25)."$v\n";
|
234 |
+
}
|
235 |
+
$r .= str_pad(count($value), 25)."\n";
|
236 |
+
//$r .= print_r($value)."\n";
|
237 |
+
}
|
238 |
+
$r .= str_pad($key, 25)."$value\n";
|
239 |
+
}
|
240 |
+
$r .= "\n\n";
|
241 |
+
|
242 |
+
return $r;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Process IPN
|
247 |
+
*
|
248 |
+
* Handles the IPN post back to PayPal and parsing the response. Call this
|
249 |
+
* method from your IPN listener script. Returns true if the response came
|
250 |
+
* back as "VERIFIED", false if the response came back "INVALID", and
|
251 |
+
* throws an exception if there is an error.
|
252 |
+
*
|
253 |
+
* @param array
|
254 |
+
*
|
255 |
+
* @return boolean
|
256 |
+
*/
|
257 |
+
public function processIpn($post_data=null) {
|
258 |
+
|
259 |
+
$encoded_data = 'cmd=_notify-validate';
|
260 |
+
|
261 |
+
if ($post_data === null) {
|
262 |
+
|
263 |
+
|
264 |
+
// use raw POST data
|
265 |
+
if (!empty($_POST)) {
|
266 |
+
$this->post_data = $_POST;
|
267 |
+
$encoded_data .= '&'.file_get_contents('php://input');
|
268 |
+
} else {
|
269 |
+
throw new Exception("No POST data found.");
|
270 |
+
}
|
271 |
+
} else {
|
272 |
+
// use provided data array
|
273 |
+
$this->post_data = $post_data;
|
274 |
+
|
275 |
+
foreach ($this->post_data as $key => $value) {
|
276 |
+
$value = urlencode(stripslashes($value));
|
277 |
+
$encoded_data .= "&$key=$value";
|
278 |
+
}
|
279 |
+
|
280 |
+
// foreach ($this->post_data as $key => $value) {
|
281 |
+
// $encoded_data .= "&$key=".urlencode($value);
|
282 |
+
// }
|
283 |
+
}
|
284 |
+
|
285 |
+
if ($this->use_curl) $this->curlPost($encoded_data);
|
286 |
+
else $this->fsockPost($encoded_data);
|
287 |
+
|
288 |
+
if (strpos($this->response_status, '200') === false) {
|
289 |
+
throw new Exception("Invalid response status: ".$this->response_status);
|
290 |
+
}
|
291 |
+
|
292 |
+
if (strpos($this->response, "VERIFIED") !== false) {
|
293 |
+
return true;
|
294 |
+
} elseif (strpos($this->response, "INVALID") !== false) {
|
295 |
+
return false;
|
296 |
+
} else {
|
297 |
+
throw new Exception("Unexpected response from PayPal.");
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Require Post Method
|
303 |
+
*
|
304 |
+
* Throws an exception and sets a HTTP 405 response header if the request
|
305 |
+
* method was not POST.
|
306 |
+
*/
|
307 |
+
public function requirePostMethod() {
|
308 |
+
// require POST requests
|
309 |
+
if ($_SERVER['REQUEST_METHOD'] && $_SERVER['REQUEST_METHOD'] != 'POST') {
|
310 |
+
header('Allow: POST', true, 405);
|
311 |
+
throw new Exception("Invalid HTTP request method.");
|
312 |
+
}
|
313 |
+
}
|
314 |
+
}
|
315 |
+
?>
|
paypal/redirect.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once ('../app/Mage.php');
|
3 |
+
umask ( 0 );
|
4 |
+
Mage::app ();
|
5 |
+
Mage::getSingleton ( 'core/session', array (
|
6 |
+
'name' => 'frontend'
|
7 |
+
) );
|
8 |
+
Mage::getSingleton ( 'checkout/session', array (
|
9 |
+
'name' => 'frontend'
|
10 |
+
) );
|
11 |
+
|
12 |
+
include_once ('Paypal.php');
|
13 |
+
|
14 |
+
$order_Id = $_GET ['id'];
|
15 |
+
|
16 |
+
$order = Mage::getModel ( 'sales/order' )->load ( $order_Id );
|
17 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($order_Id);
|
18 |
+
|
19 |
+
$orderId = $order->getIncrementId ();
|
20 |
+
|
21 |
+
$result = $order->getAllItems ();
|
22 |
+
|
23 |
+
$currency_code = $order ['base_currency_code'];
|
24 |
+
|
25 |
+
$shipping = round ( $order ['base_shipping_amount'], 2 );
|
26 |
+
$weight = round ( $order ['Weight'], 2 );
|
27 |
+
$ship_method = $order ['Shipping_description'];
|
28 |
+
$tax = trim ( round ( $order ['tax_amount'], 2 ) );
|
29 |
+
$discountAmount = $order ['discount_amount'];
|
30 |
+
|
31 |
+
number_format($discountAmount, 2, '.', '');
|
32 |
+
$amount = round ( $order ['grand_total'], 2 );
|
33 |
+
|
34 |
+
$customerid = $order ['customer_id'];
|
35 |
+
$customer = Mage::getModel ( 'customer/customer' )->load ( $customerid );
|
36 |
+
|
37 |
+
$billingaddress = Mage::getModel ( 'customer/address' )->load ( $customer->default_billing );
|
38 |
+
$shippingaddress = Mage::getModel ( 'customer/address' )->load ( $customer->default_shipping );
|
39 |
+
|
40 |
+
$city = $billingaddress ['city'];
|
41 |
+
$country = $billingaddress ['country'];
|
42 |
+
$email = $billingaddress ['customer_email'];
|
43 |
+
$firstname = $billingaddress ['firstname'];
|
44 |
+
$lastname = $billingaddress ['lastname'];
|
45 |
+
$postcode = $billingaddress ['Postcode'];
|
46 |
+
$region = $billingaddress ['region'];
|
47 |
+
$street = $billingaddress ['street'];
|
48 |
+
|
49 |
+
$telephone = $billingaddress ['telephone'];
|
50 |
+
$regioncode = $billingaddress ['region_code'];
|
51 |
+
|
52 |
+
if ($shippingaddress ['customer_email']) {
|
53 |
+
|
54 |
+
$city = $shippingaddress ['city'];
|
55 |
+
$country = $shippingaddress ['country'];
|
56 |
+
$email = $shippingaddress ['customer_email'];
|
57 |
+
$firstname = $shippingaddress ['firstname'];
|
58 |
+
$lastname = $shippingaddress ['lastname'];
|
59 |
+
$postcode = $shippingaddress ['Postcode'];
|
60 |
+
$region = $shippingaddress ['region'];
|
61 |
+
$street = $shippingaddress ['street'];
|
62 |
+
|
63 |
+
$telephone = $shippingaddress ['telephone'];
|
64 |
+
$regioncode = $shippingaddress ['region_code'];
|
65 |
+
}
|
66 |
+
|
67 |
+
$post_code = preg_replace ( '@[^\d]@', '', $postcode );
|
68 |
+
|
69 |
+
$paypalEmail = Mage::getStoreConfig ( 'paypal/general/business_account' );
|
70 |
+
|
71 |
+
$demo = Mage::getStoreConfig ( 'payment/paypal_standard/sandbox_flag' );
|
72 |
+
$demo = 1;
|
73 |
+
$payAction = Mage::getStoreConfig ( 'payment/paypal_standard/payment_action' );
|
74 |
+
|
75 |
+
$websiteData = Mage::app ()->getStore ()->getWebsite ()->getData ();
|
76 |
+
$storeName = $websiteData ['name'];
|
77 |
+
$baseUrl = Mage::getStoreConfig ( 'web/secure/base_url' );
|
78 |
+
|
79 |
+
if ($demo == 1) {
|
80 |
+
$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
|
81 |
+
} else {
|
82 |
+
$url = "https://www.paypal.com/cgi-bin/webscr";
|
83 |
+
}
|
84 |
+
// echo $url; exit;
|
85 |
+
|
86 |
+
$redirecturl = $baseUrl . "paypal/";
|
87 |
+
?>
|
88 |
+
<html>
|
89 |
+
<body>
|
90 |
+
You will be redirected to the PayPal website in a few seconds.
|
91 |
+
<form action="<?php echo $url;?>" id="paypal_standard_checkout"
|
92 |
+
name="paypal_standard_checkout" method="POST">
|
93 |
+
<div>
|
94 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::helper('core')->getRandomString(16); ?>" />
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<input id="business" name="business" value="<?php echo $paypalEmail;?>" type="hidden" />
|
98 |
+
<input id="invoice" name="invoice" value="<?php echo $orderId;?>" type="hidden" />
|
99 |
+
<input id="currency_code" name="currency_code" value="<?php echo $currency_code; ?>" type="hidden" />
|
100 |
+
<input id="paymentaction" name="paymentaction" value="<?php echo strtolower($payAction);?>" type="hidden" />
|
101 |
+
<input id="return" name="return" value="<?php echo $redirecturl.'success.php'?>" type="hidden" />
|
102 |
+
<input id="cancel_return" name="cancel_return" value="<?php echo $redirecturl.'cancel.php'?>" type="hidden" />
|
103 |
+
<input id="notify_url" name="notify_url" value="<?php echo $redirecturl.'ipn.php'?>" type="hidden" />
|
104 |
+
<!--<input id="notify_url" name="notify_url" value="<?php echo $redirecturl.'my_ipn.php'?>" type="hidden" />-->
|
105 |
+
<input id="bn" name="bn" value="Varien_Cart_WPS_IT" type="hidden" />
|
106 |
+
<input id="item_name" name="item_name" value="Main Website Store" type="hidden" />
|
107 |
+
<input id="lc" name="lc" value="en_US" type="hidden" />
|
108 |
+
<input id="charset" name="charset" value="utf-8" type="hidden" />
|
109 |
+
|
110 |
+
<input id="amount" name="amount" value="<?php echo $amount;?>" type="hidden" />
|
111 |
+
<input id="tax" name="tax" value="<?php echo number_format($tax, 2, '.', '');?>" type="hidden" />
|
112 |
+
<input id="shipping1" name="shipping1" value="<?php echo sprintf("%.2f", $shipping);?>" type="hidden" />
|
113 |
+
<input id="discount_amount" name="discount_amount" value="<?php echo number_format($discountAmount, 2, '.', '');?>" type="hidden" />
|
114 |
+
|
115 |
+
|
116 |
+
<input type="hidden" name="rm" value="2">
|
117 |
+
<input type="hidden" name="cbt" value="Return to The Store">
|
118 |
+
<input type="hidden" name="custom" value="custom_value">
|
119 |
+
|
120 |
+
|
121 |
+
<?php //echo "<pre>";print_r($result);
|
122 |
+
foreach ($result as $key => $item) { ?>
|
123 |
+
|
124 |
+
<input id="item_number_<?php echo $key + 1; ?>" name="item_number_<?php echo $key + 1; ?>" value="<?php echo $item->getSku(); ?>" type="hidden" />
|
125 |
+
<input id="item_name_<?php echo $key + 1; ?>" name="item_name_<?php echo $key + 1; ?>" value="<?php echo $item->getName(); ?>" type="hidden" />
|
126 |
+
<input id="quantity_<?php echo $key + 1; ?>" name="quantity_<?php echo $key + 1; ?>" value="<?php echo intval($item->getQtyOrdered()); ?>" type="hidden" />
|
127 |
+
<input id="amount_<?php echo $key + 1; ?>" name="amount_<?php echo $key + 1; ?>" value="<?php echo number_format($item->getPrice(),2,'.',''); ?>" type="hidden" />
|
128 |
+
|
129 |
+
<?php } //exit;?>
|
130 |
+
|
131 |
+
<input id="shipping_1" name="shipping_1" value="<?php echo sprintf("%.2f", $shipping);?>" type="hidden" />
|
132 |
+
<input id="discount_amount" name="discount_amount" value="<?php echo number_format($discountAmount, 2, '.', '');?>" type="hidden" />
|
133 |
+
<input id="cmd" name="cmd" value="_cart" type="hidden" />
|
134 |
+
<input id="upload" name="upload" value="1" type="hidden" />
|
135 |
+
|
136 |
+
<input id="tax_cart" name="tax_cart" value="<?php echo number_format($tax, 2, '.', '');?>" type="hidden"/>
|
137 |
+
<input id="discount_amount_cart" name="discount_amount_cart" value="<?php echo number_format($discountAmount, 2, '.', '');?>" type="hidden"/>
|
138 |
+
|
139 |
+
<input id="city" name="city" value="<?php echo $city; ?>" type="hidden" />
|
140 |
+
<input id="country" name="country" value="<?php echo $country; ?>" type="hidden" />
|
141 |
+
<input id="email" name="email" value="<?php echo $email; ?>" type="hidden" />
|
142 |
+
<input id="first_name" name="first_name" value="<?php echo $firstname; ?>" type="hidden" />
|
143 |
+
<input id="last_name" name="last_name" value="<?php echo $lastname; ?>" type="hidden" />
|
144 |
+
<input id="zip" name="zip" value="<?php echo $post_code; ?>" type="hidden" />
|
145 |
+
<input id="state" name="state" value="<?php echo $regioncode; ?>" type="hidden" />
|
146 |
+
<input id="address1" name="address1" value="<?php echo $streetvalue; ?>" type="hidden" />
|
147 |
+
<input id="address2" name="address2" value="" type="hidden" />
|
148 |
+
<input id="address_override" name="address_override" value="0" type="hidden" />
|
149 |
+
|
150 |
+
<?php //exit;?>
|
151 |
+
</form>
|
152 |
+
<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>
|
153 |
+
</body>
|
154 |
+
</html>
|
paypal/success.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require '../app/Mage.php';
|
3 |
+
|
4 |
+
Mage::App (); // might be "default"
|
5 |
+
$_SERVER ['SCRIPT_NAME'] = str_replace ( basename ( __FILE__ ), 'index.php', $_SERVER ['SCRIPT_NAME'] );
|
6 |
+
$_SERVER ['SCRIPT_FILENAME'] = str_replace ( basename ( __FILE__ ), 'index.php', $_SERVER ['SCRIPT_FILENAME'] );
|
7 |
+
|
8 |
+
|
9 |
+
echo "transaction id= ".$txnid = $_REQUEST ['txn_id'];
|
10 |
+
mail("vinotha.a@contus.in",'paypal', $txnid);
|
11 |
+
$transaction_id = $_POST ['verify_sign'];
|
12 |
+
$order_id = $_POST ['invoice'];
|
13 |
+
$status = $_POST ['payment_status'];
|
14 |
+
$email = $_POST ['payer_email'];
|
15 |
+
$name = $_POST ['first_name'];
|
16 |
+
$pendingreason = $_POST ['pending_reason'];
|
17 |
+
|
18 |
+
$mcgross = $_POST ['mc_gross'];
|
19 |
+
$refundreason = $_POST ['reason_code'];
|
20 |
+
|
21 |
+
?>
|
22 |
+
<script language="javascript">
|
23 |
+
function showAndroidToast(toast) {
|
24 |
+
alert(toast);
|
25 |
+
PaymentTransaction.showToast(toast);
|
26 |
+
}
|
27 |
+
</script>
|
28 |
+
<html>
|
29 |
+
<head>
|
30 |
+
<meta content='True' name='HandheldFriendly' />
|
31 |
+
<meta
|
32 |
+
content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'
|
33 |
+
name='viewport' />
|
34 |
+
</head>
|
35 |
+
|
36 |
+
<body onload="showAndroidToast('<?php echo $txnid; ?>')">
|
37 |
+
<input id="txnid" name="txnid" value="<?php echo $txnid;?>" type="hidden" />
|
38 |
+
<center>
|
39 |
+
<h2>Order Placed successfully.</h2>
|
40 |
+
</center>
|
41 |
+
|
42 |
+
<table>
|
43 |
+
<tr>
|
44 |
+
<td><b>Transcation Id :</b></td>
|
45 |
+
<td><?php echo $txnid ;?></td>
|
46 |
+
<td><b> Order Id :</b></td>
|
47 |
+
<td><?php echo $order_id ;?></td>
|
48 |
+
</tr>
|
49 |
+
</table>
|
50 |
+
</body>
|
51 |
+
</html>
|
rest/.htaccess
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<IfModule mod_rewrite.c>
|
2 |
+
RewriteEngine On
|
3 |
+
RewriteCond %{REQUEST_FILENAME} !-d
|
4 |
+
RewriteCond %{REQUEST_FILENAME} !-s
|
5 |
+
RewriteRule ^(.*)$ api.php?req=$1 [QSA,NC,L]
|
6 |
+
|
7 |
+
RewriteCond %{REQUEST_FILENAME} -d
|
8 |
+
RewriteRule ^(.*)$ api.php [QSA,NC,L]
|
9 |
+
|
10 |
+
RewriteCond %{REQUEST_FILENAME} -s
|
11 |
+
RewriteRule ^(.*)$ api.php [QSA,NC,L]
|
12 |
+
</IfModule>
|
rest/Rest.inc.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class REST {
|
3 |
+
|
4 |
+
public $_allow = array();
|
5 |
+
public $_content_type = "application/json";
|
6 |
+
public $_request = array();
|
7 |
+
|
8 |
+
private $_method = "";
|
9 |
+
private $_code = 200;
|
10 |
+
|
11 |
+
public function __construct(){
|
12 |
+
$this->inputs();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function get_referer(){
|
16 |
+
return $_SERVER['HTTP_REFERER'];
|
17 |
+
}
|
18 |
+
|
19 |
+
public function response($data,$status){
|
20 |
+
$this->_code = ($status)?$status:200;
|
21 |
+
$this->set_headers();
|
22 |
+
echo $data;
|
23 |
+
exit;
|
24 |
+
}
|
25 |
+
|
26 |
+
function sendResponse($status = 200, $body = '', $content_type = 'application/json') {
|
27 |
+
$status_header = 'HTTP/1.1 ' . $status . ' ' . $this->getStatusCodeMessage ( $status );
|
28 |
+
header ( $status_header );
|
29 |
+
header ( 'Content-type: ' . $content_type );
|
30 |
+
echo $body;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Method to get the status code from the url to check whether it is valid or not
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*
|
38 |
+
*/
|
39 |
+
|
40 |
+
function getStatusCodeMessage($status)
|
41 |
+
{
|
42 |
+
$codes = Array (
|
43 |
+
100 => 'Continue',
|
44 |
+
101 => 'Switching Protocols',
|
45 |
+
200 => 'OK',
|
46 |
+
201 => 'Created',
|
47 |
+
202 => 'Accepted',
|
48 |
+
203 => 'Non-Authoritative Information',
|
49 |
+
204 => 'No Content',
|
50 |
+
205 => 'Reset Content',
|
51 |
+
206 => 'Partial Content',
|
52 |
+
300 => 'Multiple Choices',
|
53 |
+
301 => 'Moved Permanently',
|
54 |
+
302 => 'Found',
|
55 |
+
303 => 'See Other',
|
56 |
+
304 => 'Not Modified',
|
57 |
+
305 => 'Use Proxy',
|
58 |
+
306 => '(Unused)',
|
59 |
+
307 => 'Temporary Redirect',
|
60 |
+
400 => 'Bad Request',
|
61 |
+
401 => 'Unauthorized',
|
62 |
+
402 => 'Payment Required',
|
63 |
+
403 => 'Forbidden',
|
64 |
+
404 => 'Not Found',
|
65 |
+
405 => 'Method Not Allowed',
|
66 |
+
406 => 'Not Acceptable',
|
67 |
+
407 => 'Proxy Authentication Required',
|
68 |
+
408 => 'Request Timeout',
|
69 |
+
409 => 'Conflict',
|
70 |
+
410 => 'Gone',
|
71 |
+
411 => 'Length Required',
|
72 |
+
412 => 'Precondition Failed',
|
73 |
+
413 => 'Request Entity Too Large',
|
74 |
+
414 => 'Request-URI Too Long',
|
75 |
+
415 => 'Unsupported Media Type',
|
76 |
+
416 => 'Requested Range Not Satisfiable',
|
77 |
+
417 => 'Expectation Failed',
|
78 |
+
500 => 'Internal Server Error',
|
79 |
+
501 => 'Not Implemented',
|
80 |
+
502 => 'Bad Gateway',
|
81 |
+
503 => 'Service Unavailable',
|
82 |
+
504 => 'Gateway Timeout',
|
83 |
+
505 => 'HTTP Version Not Supported'
|
84 |
+
);
|
85 |
+
|
86 |
+
return (isset ( $codes [$status] )) ? $codes [$status] : '';
|
87 |
+
}
|
88 |
+
|
89 |
+
public function get_request_method(){
|
90 |
+
return $_SERVER['REQUEST_METHOD'];
|
91 |
+
}
|
92 |
+
|
93 |
+
private function inputs(){
|
94 |
+
switch($this->get_request_method()){
|
95 |
+
case "POST":
|
96 |
+
$this->_request = $this->cleanInputs($_POST);
|
97 |
+
break;
|
98 |
+
case "GET":
|
99 |
+
$this->_request = $this->cleanInputs($_GET);
|
100 |
+
break;
|
101 |
+
case "DELETE":
|
102 |
+
$this->_request = $this->cleanInputs($_GET);
|
103 |
+
break;
|
104 |
+
case "PUT":
|
105 |
+
parse_str(file_get_contents("php://input"),$this->_request);
|
106 |
+
$this->_request = $this->cleanInputs($this->_request);
|
107 |
+
break;
|
108 |
+
default:
|
109 |
+
$this->response('',406);
|
110 |
+
break;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
private function cleanInputs($data){
|
115 |
+
$clean_input = array();
|
116 |
+
if(is_array($data)){
|
117 |
+
foreach($data as $k => $v){
|
118 |
+
$clean_input[$k] = $this->cleanInputs($v);
|
119 |
+
}
|
120 |
+
}else{
|
121 |
+
if(get_magic_quotes_gpc()){
|
122 |
+
$data = trim(stripslashes($data));
|
123 |
+
}
|
124 |
+
$data = strip_tags($data);
|
125 |
+
$clean_input = trim($data);
|
126 |
+
}
|
127 |
+
return $clean_input;
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
private function set_headers(){
|
132 |
+
header("HTTP/1.1 ".$this->_code." ".$this->get_status_message());
|
133 |
+
header("Content-Type:".$this->_content_type);
|
134 |
+
}
|
135 |
+
}
|
136 |
+
?>
|
rest/api.php
ADDED
@@ -0,0 +1,1635 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contus
|
4 |
+
* This class is to demonstrate the Simple Rest Web-service and doing
|
5 |
+
|
6 |
+
* HTTP operations like PUT,POST,GET and DELETE.
|
7 |
+
*
|
8 |
+
* @author Contus Team <developers@contus.in>
|
9 |
+
* @copyright Copyright (c) 2014 Apptha. (http://www.apptha.com)
|
10 |
+
* @license http://www.apptha.com/LICENSE.txt Open Software License ("OSL") v. 3.0
|
11 |
+
|
12 |
+
*/
|
13 |
+
|
14 |
+
require_once ("Rest.inc.php");
|
15 |
+
$mageFilename = '../app/Mage.php';
|
16 |
+
require_once $mageFilename;
|
17 |
+
class API extends REST {
|
18 |
+
public $data = "";
|
19 |
+
public function __construct() {
|
20 |
+
parent::__construct (); // Init parent constructor
|
21 |
+
}
|
22 |
+
|
23 |
+
// Public method for access api.
|
24 |
+
// This method dynamically call the method based on the query string
|
25 |
+
public function processApi() {
|
26 |
+
$func = strtolower ( trim ( str_replace ( "/", "", $_REQUEST ['req'] ) ) );
|
27 |
+
if (( int ) method_exists ( $this, $func ) > 0)
|
28 |
+
$this->$func ();
|
29 |
+
else
|
30 |
+
$this->sendResponse ( 404, json_encode ( array (
|
31 |
+
'error' => true,
|
32 |
+
'message' => 'Not Found'
|
33 |
+
) ) );
|
34 |
+
// If the method not exist with in this class, response would be "Page not found".
|
35 |
+
}
|
36 |
+
private function api() {
|
37 |
+
// $callbackUrl is a path to your file with OAuth authentication example for the Admin user
|
38 |
+
$baseUrl = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_WEB );
|
39 |
+
|
40 |
+
$callbackUrl = $baseUrl . "rest/api.php";
|
41 |
+
$temporaryCredentialsRequestUrl = $baseUrl . "oauth/initiate?oauth_callback=" . urlencode ( $callbackUrl );
|
42 |
+
$adminAuthorizationUrl = $baseUrl . 'oauth/authorize';
|
43 |
+
$accessTokenRequestUrl = $baseUrl . 'oauth/token';
|
44 |
+
$apiUrl = $baseUrl . 'api/rest';
|
45 |
+
//get rest key and secretkey
|
46 |
+
$consumerKey = Mage::getStoreConfig ( 'contus/mcomapp_about/rest_apikey' );
|
47 |
+
$consumerSecret = Mage::getStoreConfig ( 'contus/mcomapp_about/rest_secretkey' );
|
48 |
+
|
49 |
+
session_start ();
|
50 |
+
|
51 |
+
try {
|
52 |
+
$oauthClient = new OAuth ( $consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI );
|
53 |
+
$oauthClient->enableDebug ();
|
54 |
+
|
55 |
+
if (! isset ( $_GET ['oauth_token'] )) {
|
56 |
+
$requestToken = $oauthClient->getRequestToken ( $temporaryCredentialsRequestUrl );
|
57 |
+
$_SESSION ['secret'] = $requestToken ['oauth_token_secret'];
|
58 |
+
$_SESSION ['token'] = $requestToken ['oauth_token'];
|
59 |
+
$_SESSION ['state'] = 1;
|
60 |
+
}
|
61 |
+
|
62 |
+
$oauthClient->setToken ( $_SESSION ['token'], $_SESSION ['secret'] );
|
63 |
+
|
64 |
+
$action = $this->_request ['action'];
|
65 |
+
try {
|
66 |
+
switch ($action) {
|
67 |
+
case "homepage" :
|
68 |
+
|
69 |
+
if ($this->get_request_method () != "GET") {
|
70 |
+
$this->sendResponse ( 400, json_encode ( array (
|
71 |
+
'error' => true,
|
72 |
+
'message' => 'Bad Request'
|
73 |
+
) ) );
|
74 |
+
} else {
|
75 |
+
$requestData = array (
|
76 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
77 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
78 |
+
'image_size' => (int) $this->_request ['image_size']
|
79 |
+
);
|
80 |
+
$headers = array (
|
81 |
+
'Content-Type' => 'application/json',
|
82 |
+
'Accept' => '*/*'
|
83 |
+
);
|
84 |
+
$resourceUrl = "$apiUrl/homepage/";
|
85 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
86 |
+
$result = $oauthClient->getLastResponse ();
|
87 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
88 |
+
}
|
89 |
+
break;
|
90 |
+
|
91 |
+
case "category_products" :
|
92 |
+
|
93 |
+
$requestData = array (
|
94 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
95 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
96 |
+
'page' => ( int ) $this->_request ['page'],
|
97 |
+
'limit' => ( int ) $this->_request ['limit'],
|
98 |
+
'category_id' => ( int ) $this->_request ['category_id'],
|
99 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
100 |
+
'orderby' => $this->_request ['orderby'],
|
101 |
+
'sortby' => $this->_request ['sortby'] ,
|
102 |
+
|
103 |
+
'filters' => $this->_request['filters'],
|
104 |
+
'image_size' => (int) $this->_request ['image_size']
|
105 |
+
|
106 |
+
);
|
107 |
+
$headers = array (
|
108 |
+
'Content-Type' => 'application/json',
|
109 |
+
'Accept' => '*/*'
|
110 |
+
);
|
111 |
+
$resourceUrl = "$apiUrl/products_list/";
|
112 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
113 |
+
$result = $oauthClient->getLastResponse ();
|
114 |
+
|
115 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
116 |
+
break;
|
117 |
+
|
118 |
+
case "productdetail" :
|
119 |
+
if ($this->get_request_method () != "GET") {
|
120 |
+
$this->sendResponse ( 400, json_encode ( array (
|
121 |
+
'error' => true,
|
122 |
+
'message' => 'Bad Request'
|
123 |
+
) ) );
|
124 |
+
} else {
|
125 |
+
|
126 |
+
$requestData = array (
|
127 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
128 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
129 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
130 |
+
'id' => ( int ) $this->_request ['product_id'] ,
|
131 |
+
'image_size' => (int) $this->_request ['image_size']
|
132 |
+
);
|
133 |
+
$headers = array (
|
134 |
+
'Content-Type' => 'application/json',
|
135 |
+
'Accept' => '*/*'
|
136 |
+
);
|
137 |
+
$resourceUrl = "$apiUrl/product_detail/";
|
138 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
139 |
+
$result = $oauthClient->getLastResponse ();
|
140 |
+
$this->sendResponse ( 200, ($result) );
|
141 |
+
}
|
142 |
+
break;
|
143 |
+
|
144 |
+
case "static_page" :
|
145 |
+
if ($this->get_request_method () != "GET") {
|
146 |
+
$this->sendResponse ( 400, json_encode ( array (
|
147 |
+
'error' => true,
|
148 |
+
'message' => 'Bad Request'
|
149 |
+
) ) );
|
150 |
+
} else {
|
151 |
+
|
152 |
+
$requestData = array (
|
153 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
154 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
155 |
+
'page_key' => $this->_request ['page_key']
|
156 |
+
);
|
157 |
+
$headers = array (
|
158 |
+
'Content-Type' => 'application/json',
|
159 |
+
'Accept' => '*/*'
|
160 |
+
);
|
161 |
+
$resourceUrl = "$apiUrl/staticpages";
|
162 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
163 |
+
$result = $oauthClient->getLastResponse ();
|
164 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
165 |
+
}
|
166 |
+
break;
|
167 |
+
|
168 |
+
case "login" :
|
169 |
+
if ($this->get_request_method () != "POST") {
|
170 |
+
$this->sendResponse ( 400, json_encode ( array (
|
171 |
+
'error' => true,
|
172 |
+
'message' => 'Bad Request'
|
173 |
+
) ) );
|
174 |
+
} else {
|
175 |
+
|
176 |
+
$requestData = json_encode ( array (
|
177 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
178 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
179 |
+
'email' => $this->_request ['email'],
|
180 |
+
'password' => $this->_request ['login_signature'],
|
181 |
+
'device_token' => $this->_request ['device_token'],
|
182 |
+
'device_type' => $this->_request ['device_type']
|
183 |
+
|
184 |
+
) );
|
185 |
+
$headers = array (
|
186 |
+
'Content-Type' => 'application/json',
|
187 |
+
'Accept' => '*/*'
|
188 |
+
);
|
189 |
+
$resourceUrl = "$apiUrl/customer/login/";
|
190 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
191 |
+
$result = $oauthClient->getLastResponse ();
|
192 |
+
$this->sendResponse ( 200, ($result) );
|
193 |
+
}
|
194 |
+
break;
|
195 |
+
|
196 |
+
case "forgot_signature" :
|
197 |
+
|
198 |
+
if ($this->get_request_method () != "POST") {
|
199 |
+
$this->sendResponse ( 400, json_encode ( array (
|
200 |
+
'error' => true,
|
201 |
+
'message' => 'Bad Request'
|
202 |
+
) ) );
|
203 |
+
} else {
|
204 |
+
|
205 |
+
$requestData = json_encode ( array (
|
206 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
207 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
208 |
+
'email' => $this->_request ['email']
|
209 |
+
) );
|
210 |
+
$headers = array (
|
211 |
+
'Content-Type' => 'application/json',
|
212 |
+
'Accept' => '*/*'
|
213 |
+
);
|
214 |
+
$oauthClient->fetch ( "$apiUrl/customer/forgotpassword/", $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
215 |
+
$result = $oauthClient->getLastResponse ();
|
216 |
+
$this->sendResponse ( 200, ($result) );
|
217 |
+
}
|
218 |
+
break;
|
219 |
+
|
220 |
+
case "change_signature" :
|
221 |
+
if ($this->get_request_method () != "POST") {
|
222 |
+
$this->sendResponse ( 400, json_encode ( array (
|
223 |
+
'error' => true,
|
224 |
+
'message' => 'Bad Request'
|
225 |
+
) ) );
|
226 |
+
} else {
|
227 |
+
|
228 |
+
$requestData = json_encode ( array (
|
229 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
230 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
231 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
232 |
+
'old_password' => $this->_request ['old_signature'],
|
233 |
+
'new_password' => $this->_request ['new_signature'],
|
234 |
+
'token' => $this->_request ['token']
|
235 |
+
) );
|
236 |
+
$headers = array (
|
237 |
+
'Content-Type' => 'application/json',
|
238 |
+
'Accept' => '*/*'
|
239 |
+
);
|
240 |
+
$resourceUrl = "$apiUrl/customer/changepassword/";
|
241 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
242 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
243 |
+
|
244 |
+
if (! $result ['isValidToken']) {
|
245 |
+
$this->sendResponse ( 401, json_encode ( array (
|
246 |
+
'error' => true,
|
247 |
+
'message' => 'Unauthorized'
|
248 |
+
) ) );
|
249 |
+
} else {
|
250 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
break;
|
254 |
+
|
255 |
+
case "customer_register" :
|
256 |
+
|
257 |
+
if ($this->get_request_method () != "POST") {
|
258 |
+
$this->sendResponse ( 400, json_encode ( array (
|
259 |
+
'error' => true,
|
260 |
+
'message' => 'Bad Request'
|
261 |
+
) ) );
|
262 |
+
} else {
|
263 |
+
|
264 |
+
$requestData = json_encode ( array (
|
265 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
266 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
267 |
+
'email' => $this->_request ['email'],
|
268 |
+
'password' => $this->_request ['login_signature'],
|
269 |
+
'firstname' => $this->_request ['firstname'],
|
270 |
+
'lastname' => $this->_request ['lastname'],
|
271 |
+
'newsletter' => ( int ) $this->_request ['newsletter'],
|
272 |
+
'dob' => $this->_request ['dob'],
|
273 |
+
'group_id' => ( int ) $this->_request ['group_id'],
|
274 |
+
'device_token' => $this->_request ['device_token'],
|
275 |
+
'device_type' => $this->_request ['device_type']
|
276 |
+
) );
|
277 |
+
$headers = array (
|
278 |
+
'Content-Type' => 'application/json',
|
279 |
+
'Accept' => '*/*'
|
280 |
+
);
|
281 |
+
$oauthClient->fetch ( "$apiUrl/customer/register/", $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
282 |
+
$result = $oauthClient->getLastResponse ();
|
283 |
+
$this->sendResponse ( 200, ($result) );
|
284 |
+
}
|
285 |
+
break;
|
286 |
+
|
287 |
+
case "customer_update" :
|
288 |
+
|
289 |
+
if ($this->get_request_method () != "POST") {
|
290 |
+
$this->sendResponse ( 400, json_encode ( array (
|
291 |
+
'error' => true,
|
292 |
+
'message' => 'Bad Request'
|
293 |
+
) ) );
|
294 |
+
} else {
|
295 |
+
|
296 |
+
$requestData = json_encode ( array (
|
297 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
298 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
299 |
+
'email' => $this->_request ['email'],
|
300 |
+
'firstname' => $this->_request ['firstname'],
|
301 |
+
'lastname' => $this->_request ['lastname'],
|
302 |
+
'newsletter' => ( int ) $this->_request ['newsletter'],
|
303 |
+
'dob' => $this->_request ['dob'],
|
304 |
+
'token' => $this->_request ['token']
|
305 |
+
) );
|
306 |
+
|
307 |
+
$customerId = ( int ) $this->_request ['customer_id'];
|
308 |
+
$headers = array (
|
309 |
+
'Content-Type' => 'application/json',
|
310 |
+
'Accept' => '*/*'
|
311 |
+
);
|
312 |
+
$oauthClient->fetch ( "$apiUrl/customer/update/$customerId", $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
313 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
314 |
+
if (! $result ['isValidToken']) {
|
315 |
+
$this->sendResponse ( 401, json_encode ( array (
|
316 |
+
'error' => true,
|
317 |
+
'message' => 'Unauthorized'
|
318 |
+
) ) );
|
319 |
+
} else {
|
320 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
321 |
+
}
|
322 |
+
}
|
323 |
+
break;
|
324 |
+
|
325 |
+
case "personal_detail" :
|
326 |
+
|
327 |
+
if ($this->get_request_method () != "POST") {
|
328 |
+
$this->sendResponse ( 400, json_encode ( array (
|
329 |
+
'error' => true,
|
330 |
+
'message' => 'Bad Request'
|
331 |
+
) ) );
|
332 |
+
} else {
|
333 |
+
|
334 |
+
$requestData = array (
|
335 |
+
'id' => ( int ) $this->_request ['customer_id'],
|
336 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
337 |
+
'token' => $this->_request ['token']
|
338 |
+
);
|
339 |
+
$headers = array (
|
340 |
+
'Content-Type' => 'application/json',
|
341 |
+
'Accept' => '*/*'
|
342 |
+
);
|
343 |
+
$resourceUrl = "$apiUrl/customer/detail/";
|
344 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
345 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
346 |
+
if (! $result ['isValidToken']) {
|
347 |
+
$this->sendResponse ( 401, json_encode ( array (
|
348 |
+
'error' => true,
|
349 |
+
'message' => 'Unauthorized'
|
350 |
+
) ) );
|
351 |
+
} else {
|
352 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
353 |
+
}
|
354 |
+
}
|
355 |
+
break;
|
356 |
+
|
357 |
+
case "social_login" :
|
358 |
+
|
359 |
+
if ($this->get_request_method () != "POST") {
|
360 |
+
$this->sendResponse ( 400, json_encode ( array (
|
361 |
+
'error' => true,
|
362 |
+
'message' => 'Bad Request'
|
363 |
+
) ) );
|
364 |
+
} else {
|
365 |
+
$requestData = json_encode ( array (
|
366 |
+
'email' => $this->_request ['email'],
|
367 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
368 |
+
'firstname' => $this->_request ['firstname'],
|
369 |
+
'lastname' => $this->_request ['lastname'],
|
370 |
+
'confirmation' => FALSE,
|
371 |
+
'newsletter' => $this->_request ['newsletter'],
|
372 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
373 |
+
'device_token' => $this->_request ['device_token'],
|
374 |
+
'device_type' => $this->_request ['device_type']
|
375 |
+
) );
|
376 |
+
$headers = array (
|
377 |
+
'Content-Type' => 'application/json',
|
378 |
+
'Accept' => '*/*'
|
379 |
+
);
|
380 |
+
$resourceUrl = "$apiUrl/customer/social_login/";
|
381 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
382 |
+
$result = $oauthClient->getLastResponse ();
|
383 |
+
|
384 |
+
$this->sendResponse ( 200, ($result) );
|
385 |
+
}
|
386 |
+
break;
|
387 |
+
|
388 |
+
case "add_tocart" :
|
389 |
+
|
390 |
+
if ($this->get_request_method () != "POST") {
|
391 |
+
$this->sendResponse ( 400, json_encode ( array (
|
392 |
+
'error' => true,
|
393 |
+
'message' => 'Bad Request'
|
394 |
+
) ) );
|
395 |
+
} else {
|
396 |
+
$requestData = json_encode ( array (
|
397 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
398 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
399 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
400 |
+
'product_id' => ( int ) $this->_request ['product_id'],
|
401 |
+
'token' => $this->_request ['token'],
|
402 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
403 |
+
'qty' => ( int ) $this->_request ['qty'],
|
404 |
+
'currencyCode' => $this->_request ['currencyCode'],
|
405 |
+
'super_attribute' => json_decode ( $this->_request ['super_attribute'] ),
|
406 |
+
'links' => ( $this->_request ['links'] ),
|
407 |
+
'custom_option' => json_decode ( $this->_request ['custom_option'] )
|
408 |
+
) );
|
409 |
+
|
410 |
+
$resourceUrl = "$apiUrl/cart/add/";
|
411 |
+
$headers = array (
|
412 |
+
'Content-Type' => 'application/json',
|
413 |
+
'Accept' => '*/*'
|
414 |
+
);
|
415 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
416 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
417 |
+
if (! $result ['isValidToken']) {
|
418 |
+
$this->sendResponse ( 401, json_encode ( array (
|
419 |
+
'error' => true,
|
420 |
+
'message' => 'Unauthorized'
|
421 |
+
) ) );
|
422 |
+
} else {
|
423 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
424 |
+
}
|
425 |
+
}
|
426 |
+
break;
|
427 |
+
case "cart_list" :
|
428 |
+
|
429 |
+
if ($this->get_request_method () != "POST") {
|
430 |
+
$this->sendResponse ( 400, json_encode ( array (
|
431 |
+
'error' => true,
|
432 |
+
'message' => 'Bad Request'
|
433 |
+
) ) );
|
434 |
+
} else {
|
435 |
+
|
436 |
+
$requestData = array (
|
437 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
438 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
439 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
440 |
+
'token' => $this->_request ['token']
|
441 |
+
);
|
442 |
+
|
443 |
+
$resourceUrl = "$apiUrl/cart/productlist/";
|
444 |
+
|
445 |
+
$headers = array (
|
446 |
+
'Content-Type' => 'application/json',
|
447 |
+
'Accept' => '*/*'
|
448 |
+
);
|
449 |
+
|
450 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
451 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
452 |
+
if (! $result ['isValidToken']) {
|
453 |
+
$this->sendResponse ( 401, json_encode ( array (
|
454 |
+
'error' => true,
|
455 |
+
'message' => 'Unauthorized'
|
456 |
+
) ) );
|
457 |
+
} else {
|
458 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
459 |
+
}
|
460 |
+
}
|
461 |
+
break;
|
462 |
+
|
463 |
+
case "update_cart" :
|
464 |
+
|
465 |
+
if ($this->get_request_method () != "POST") {
|
466 |
+
$this->sendResponse ( 400, json_encode ( array (
|
467 |
+
'error' => true,
|
468 |
+
'message' => 'Bad Request'
|
469 |
+
) ) );
|
470 |
+
} else {
|
471 |
+
$requestData = json_encode ( array (
|
472 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
473 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
474 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
475 |
+
'product_id' => ( int ) $this->_request ['product_id'],
|
476 |
+
'token' => $this->_request ['token'],
|
477 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
478 |
+
'qty' => ( int ) $this->_request ['qty'],
|
479 |
+
'currencyCode' => $this->_request ['currencyCode'],
|
480 |
+
'super_attribute' => json_decode ( $this->_request ['super_attribute'] ),
|
481 |
+
'custom_option' => json_decode ( $this->_request ['custom_option'] ) ,
|
482 |
+
'links' => ( $this->_request ['links'] )
|
483 |
+
) );
|
484 |
+
|
485 |
+
$resourceUrl = "$apiUrl/cart/update/";
|
486 |
+
$headers = array (
|
487 |
+
'Content-Type' => 'application/json',
|
488 |
+
'Accept' => '*/*'
|
489 |
+
);
|
490 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
491 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
492 |
+
|
493 |
+
if (! $result ['isValidToken']) {
|
494 |
+
$this->sendResponse ( 401, json_encode ( array (
|
495 |
+
'error' => true,
|
496 |
+
'message' => 'Unauthorized'
|
497 |
+
) ) );
|
498 |
+
} else {
|
499 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
500 |
+
}
|
501 |
+
}
|
502 |
+
break;
|
503 |
+
case "deletefromcart" :
|
504 |
+
|
505 |
+
if ($this->get_request_method () != "DELETE") {
|
506 |
+
$this->sendResponse ( 400, json_encode ( array (
|
507 |
+
'error' => true,
|
508 |
+
'message' => 'Bad Request'
|
509 |
+
) ) );
|
510 |
+
} else {
|
511 |
+
|
512 |
+
if ($this->_request ['website_id'] && $this->_request ['website_id'] != '') {
|
513 |
+
$websiteId = $this->_request ['website_id'];
|
514 |
+
} else {
|
515 |
+
$websiteId = Mage::app ()->getWebsite ( 'base' )->getId ();
|
516 |
+
}
|
517 |
+
if ($this->_request ['store_id'] && $this->_request ['store_id'] != '') {
|
518 |
+
$storeId = $this->_request ['store_id'];
|
519 |
+
} else {
|
520 |
+
$storeId = Mage::app ()->getWebsite ( $websiteId )->getDefaultGroup ()->getDefaultStoreId ();
|
521 |
+
}
|
522 |
+
if ($this->_request ['quote_id'] && $this->_request ['quote_id'] != '') {
|
523 |
+
$quote_id = $this->_request ['quote_id']; // asc desc
|
524 |
+
} else {
|
525 |
+
$quote_id = '';
|
526 |
+
}
|
527 |
+
if ($this->_request ['product_id'] && $this->_request ['product_id'] != '') {
|
528 |
+
$product_id = $this->_request ['product_id'];
|
529 |
+
} else {
|
530 |
+
$product_id = '';
|
531 |
+
}
|
532 |
+
if ($this->_request ['customer_id'] && $this->_request ['customer_id'] != '') {
|
533 |
+
$customer_id = $this->_request ['customer_id'];
|
534 |
+
} else {
|
535 |
+
$customer_id = '';
|
536 |
+
}
|
537 |
+
if ($this->_request ['custom_option'] && $this->_request ['custom_option'] != '') {
|
538 |
+
$custom_option = ($this->_request ['custom_option']);
|
539 |
+
foreach ((json_decode($custom_option)) as $key => $option){
|
540 |
+
if(is_string($option)){
|
541 |
+
$option = str_replace(' ','$$$$', $option);
|
542 |
+
}
|
543 |
+
$new_option [$key] = $option;
|
544 |
+
|
545 |
+
}
|
546 |
+
$custom_option = json_encode($new_option);
|
547 |
+
} else {
|
548 |
+
$custom_option = '';
|
549 |
+
}
|
550 |
+
|
551 |
+
if ($this->_request ['super_attribute'] && $this->_request ['super_attribute'] != '') {
|
552 |
+
$super_attribute = ($this->_request ['super_attribute']);
|
553 |
+
} else {
|
554 |
+
$super_attribute = '';
|
555 |
+
}
|
556 |
+
if ($this->_request ['links'] && $this->_request ['links'] != '') {
|
557 |
+
$links = ($this->_request ['links']);
|
558 |
+
} else {
|
559 |
+
$links = '';
|
560 |
+
}
|
561 |
+
|
562 |
+
$token = $this->_request ['token'];
|
563 |
+
$resourceUrl = "$apiUrl/cart/delete/links/". $links ."/super_attribute/" . $super_attribute . "/custom_option/" . $custom_option . "/quote_id/" . $quote_id . "/product_id/" . $product_id . "/customer_id/" . $customer_id . "/store_id/" . $storeId . "/website_id/" . $websiteId . "/token/" . $token;
|
564 |
+
|
565 |
+
$headers = array (
|
566 |
+
'Content-Type' => 'application/json',
|
567 |
+
'Accept' => '*/*'
|
568 |
+
);
|
569 |
+
$oauthClient->fetch ( $resourceUrl, '', OAUTH_HTTP_METHOD_DELETE, $headers );
|
570 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
571 |
+
if (! $result ['isValidToken']) {
|
572 |
+
$this->sendResponse ( 401, json_encode ( array (
|
573 |
+
'error' => true,
|
574 |
+
'message' => 'Unauthorized'
|
575 |
+
) ) );
|
576 |
+
} else {
|
577 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
578 |
+
}
|
579 |
+
}
|
580 |
+
break;
|
581 |
+
|
582 |
+
case "cart_count" :
|
583 |
+
if ($this->get_request_method () != "POST") {
|
584 |
+
$this->sendResponse ( 400, json_encode ( array (
|
585 |
+
'error' => true,
|
586 |
+
'message' => 'Bad Request'
|
587 |
+
) ) );
|
588 |
+
} else {
|
589 |
+
|
590 |
+
$requestData = array (
|
591 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
592 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
593 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
594 |
+
'token' => $this->_request ['token']
|
595 |
+
);
|
596 |
+
$headers = array (
|
597 |
+
'Content-Type' => 'application/json',
|
598 |
+
'Accept' => '*/*'
|
599 |
+
);
|
600 |
+
|
601 |
+
$resourceUrl = "$apiUrl/cart/item_count/";
|
602 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
603 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
604 |
+
if (! $result ['isValidToken']) {
|
605 |
+
$this->sendResponse ( 401, json_encode ( array (
|
606 |
+
'error' => true,
|
607 |
+
'message' => 'Unauthorized'
|
608 |
+
) ) );
|
609 |
+
} else {
|
610 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
611 |
+
}
|
612 |
+
}
|
613 |
+
break;
|
614 |
+
case "searchproducts" :
|
615 |
+
$search_term = str_replace ( ' ','%20', $this->_request ['search_term'] );
|
616 |
+
if ($this->get_request_method () != "GET") {
|
617 |
+
$this->sendResponse ( 400, json_encode ( array (
|
618 |
+
'error' => true,
|
619 |
+
'message' => 'Bad Request'
|
620 |
+
) ) );
|
621 |
+
} else {
|
622 |
+
$requestData = array (
|
623 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
624 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
625 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
626 |
+
'category_id' => ( int ) $this->_request ['category_id'],
|
627 |
+
|
628 |
+
'search_term' => $this->_request ['search_term'],
|
629 |
+
'page' => $this->_request ['page'],
|
630 |
+
'limit' => $this->_request ['limit'] ,
|
631 |
+
'image_size' => (int) $this->_request ['image_size']
|
632 |
+
);
|
633 |
+
$headers = array (
|
634 |
+
'Content-Type' => 'application/json',
|
635 |
+
'Accept' => '*/*'
|
636 |
+
);
|
637 |
+
$oauthClient->fetch ( "$apiUrl/search/products/", $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
638 |
+
|
639 |
+
$result = $oauthClient->getLastResponse ();
|
640 |
+
|
641 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
642 |
+
}
|
643 |
+
break;
|
644 |
+
|
645 |
+
case "country" :
|
646 |
+
if ($this->get_request_method () != "GET") {
|
647 |
+
$this->sendResponse ( 400, json_encode ( array (
|
648 |
+
'error' => true,
|
649 |
+
'message' => 'Bad Request'
|
650 |
+
) ) );
|
651 |
+
} else {
|
652 |
+
$headers = array (
|
653 |
+
'Content-Type' => 'application/json',
|
654 |
+
'Accept' => '*/*'
|
655 |
+
);
|
656 |
+
|
657 |
+
$oauthClient->fetch ( "$apiUrl/countrycollection/", array(), OAUTH_HTTP_METHOD_GET, $headers );
|
658 |
+
$result = $oauthClient->getLastResponse ();
|
659 |
+
$result = $oauthClient->getLastResponse ();
|
660 |
+
|
661 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
662 |
+
}
|
663 |
+
break;
|
664 |
+
|
665 |
+
case "state" :
|
666 |
+
if ($this->get_request_method () != "GET") {
|
667 |
+
$this->sendResponse ( 400, json_encode ( array (
|
668 |
+
'error' => true,
|
669 |
+
'message' => 'Bad Request'
|
670 |
+
) ) );
|
671 |
+
} else {
|
672 |
+
if ($this->_request ['countrycode'] && $this->_request ['countrycode'] != '') {
|
673 |
+
$countryCode = $this->_request ['countrycode'];
|
674 |
+
} else {
|
675 |
+
$countryCode = '';
|
676 |
+
}
|
677 |
+
$headers = array (
|
678 |
+
'Content-Type' => 'application/json',
|
679 |
+
'Accept' => '*/*'
|
680 |
+
);
|
681 |
+
$oauthClient->fetch ( "$apiUrl/statecollection/$countryCode" , array(), OAUTH_HTTP_METHOD_GET, $headers );
|
682 |
+
$result = $oauthClient->getLastResponse ();
|
683 |
+
|
684 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
685 |
+
}
|
686 |
+
break;
|
687 |
+
|
688 |
+
case "address_collection" :
|
689 |
+
if ($this->get_request_method () != "POST") {
|
690 |
+
$this->sendResponse ( 400, json_encode ( array (
|
691 |
+
'error' => true,
|
692 |
+
'message' => 'Bad Request'
|
693 |
+
) ) );
|
694 |
+
} else {
|
695 |
+
$requestData = array (
|
696 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
697 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
698 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
699 |
+
'token' => $this->_request ['token']
|
700 |
+
);
|
701 |
+
$headers = array (
|
702 |
+
'Content-Type' => 'application/json',
|
703 |
+
'Accept' => '*/*'
|
704 |
+
);
|
705 |
+
$oauthClient->fetch ( "$apiUrl/addressbook/", $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
706 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
707 |
+
$result1 = json_decode ( $result, true );
|
708 |
+
|
709 |
+
if (! $result1 ['isValidToken']) {
|
710 |
+
$this->sendResponse ( 401, json_encode ( array (
|
711 |
+
'error' => true,
|
712 |
+
'message' => 'Unauthorized'
|
713 |
+
) ) );
|
714 |
+
} else {
|
715 |
+
$this->sendResponse ( 200, ($result) );
|
716 |
+
}
|
717 |
+
}
|
718 |
+
break;
|
719 |
+
|
720 |
+
case "address_add" :
|
721 |
+
if ($this->get_request_method () != "POST") {
|
722 |
+
$this->sendResponse ( 400, json_encode ( array (
|
723 |
+
'error' => true,
|
724 |
+
'message' => 'Bad Request'
|
725 |
+
) ) );
|
726 |
+
} else {
|
727 |
+
$requestData = json_encode ( array (
|
728 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
729 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
730 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
731 |
+
'token' => $this->_request ['token'],
|
732 |
+
'firstname' => $this->_request ['firstname'],
|
733 |
+
'lastname' => $this->_request ['lastname'],
|
734 |
+
'street' => $this->_request ['street'],
|
735 |
+
'city' => $this->_request ['city'],
|
736 |
+
'region' => $this->_request ['region'],
|
737 |
+
'country_id' => $this->_request ['country_id'],
|
738 |
+
'postcode' => $this->_request ['postcode'],
|
739 |
+
'telephone' => $this->_request ['telephone'],
|
740 |
+
'is_default_billing' => ( int ) $this->_request ['is_default_billing'],
|
741 |
+
'is_default_shipping' => ( int ) $this->_request ['is_default_shipping']
|
742 |
+
) );
|
743 |
+
$resourceUrl = "$apiUrl/addressbook/add/";
|
744 |
+
$headers = array (
|
745 |
+
'Content-Type' => 'application/json',
|
746 |
+
'Accept' => '*/*'
|
747 |
+
);
|
748 |
+
|
749 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
750 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
751 |
+
if (! $result ['isValidToken']) {
|
752 |
+
$this->sendResponse ( 401, json_encode ( array (
|
753 |
+
'error' => true,
|
754 |
+
'message' => 'Unauthorized'
|
755 |
+
) ) );
|
756 |
+
} else {
|
757 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
758 |
+
}
|
759 |
+
}
|
760 |
+
break;
|
761 |
+
|
762 |
+
case "address_detail" :
|
763 |
+
|
764 |
+
if ($this->get_request_method () != "POST") {
|
765 |
+
$this->sendResponse ( 400, json_encode ( array (
|
766 |
+
'error' => true,
|
767 |
+
'message' => 'Bad Request'
|
768 |
+
) ) );
|
769 |
+
} else {
|
770 |
+
$requestData = (array (
|
771 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
772 |
+
'token' => $this->_request ['token'],
|
773 |
+
'id' => ( int ) $this->_request ['address_id']
|
774 |
+
));
|
775 |
+
$headers = array (
|
776 |
+
'Content-Type' => 'application/json',
|
777 |
+
'Accept' => '*/*'
|
778 |
+
);
|
779 |
+
$resourceUrl = "$apiUrl/address_detail/";
|
780 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
781 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
782 |
+
if (! $result ['isValidToken']) {
|
783 |
+
$this->sendResponse ( 401, json_encode ( array (
|
784 |
+
'error' => true,
|
785 |
+
'message' => 'Unauthorized'
|
786 |
+
) ) );
|
787 |
+
} else {
|
788 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
789 |
+
}
|
790 |
+
}
|
791 |
+
break;
|
792 |
+
case "address_update" :
|
793 |
+
if ($this->get_request_method () != "POST") {
|
794 |
+
$this->sendResponse ( 400, json_encode ( array (
|
795 |
+
'error' => true,
|
796 |
+
'message' => 'Bad Request'
|
797 |
+
) ) );
|
798 |
+
} else {
|
799 |
+
$requestData = json_encode ( array (
|
800 |
+
'address_id' => ( int ) $this->_request ['address_id'],
|
801 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
802 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
803 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
804 |
+
'token' => $this->_request ['token'],
|
805 |
+
'firstname' => $this->_request ['firstname'],
|
806 |
+
'lastname' => $this->_request ['lastname'],
|
807 |
+
'street' => $this->_request ['street'],
|
808 |
+
'city' => $this->_request ['city'],
|
809 |
+
'region' => $this->_request ['region'],
|
810 |
+
'country_id' => $this->_request ['country_id'],
|
811 |
+
'postcode' => $this->_request ['postcode'],
|
812 |
+
'telephone' => $this->_request ['telephone'],
|
813 |
+
'is_default_billing' => ( int ) $this->_request ['is_default_billing'],
|
814 |
+
'is_default_shipping' => ( int ) $this->_request ['is_default_shipping']
|
815 |
+
) );
|
816 |
+
$resourceUrl = "$apiUrl/addressbook/update/";
|
817 |
+
$headers = array (
|
818 |
+
'Content-Type' => 'application/json',
|
819 |
+
'Accept' => '*/*'
|
820 |
+
);
|
821 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
822 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
823 |
+
if (! $result ['isValidToken']) {
|
824 |
+
$this->sendResponse ( 401, json_encode ( array (
|
825 |
+
'error' => true,
|
826 |
+
'message' => 'Unauthorized'
|
827 |
+
) ) );
|
828 |
+
} else {
|
829 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
830 |
+
}
|
831 |
+
}
|
832 |
+
break;
|
833 |
+
case "address_delete" :
|
834 |
+
|
835 |
+
if ($this->get_request_method () != "DELETE") {
|
836 |
+
$this->sendResponse ( 400, json_encode ( array (
|
837 |
+
'error' => true,
|
838 |
+
'message' => 'Bad Request'
|
839 |
+
) ) );
|
840 |
+
} else {
|
841 |
+
|
842 |
+
$storeId = $this->_request ['store_id'];
|
843 |
+
$websiteId = $this->_request ['website_id'];
|
844 |
+
|
845 |
+
if ($this->_request ['customer_id'] && $this->_request ['customer_id'] != '') {
|
846 |
+
$customerId = $this->_request ['customer_id'];
|
847 |
+
} else {
|
848 |
+
$customerId = '';
|
849 |
+
}
|
850 |
+
|
851 |
+
if ($this->_request ['address_id'] && $this->_request ['address_id'] != '') {
|
852 |
+
$addressId = $this->_request ['address_id'];
|
853 |
+
} else {
|
854 |
+
$addressId = '';
|
855 |
+
}
|
856 |
+
$token = $this->_request ['token'];
|
857 |
+
|
858 |
+
$resourceUrl = "$apiUrl/addressbook/delete/address_id/$addressId/customer_id/$customerId/store_id/$storeId/website_id/$websiteId/token/$token";
|
859 |
+
$headers = array (
|
860 |
+
'Content-Type' => 'application/json',
|
861 |
+
'Accept' => '*/*'
|
862 |
+
);
|
863 |
+
$oauthClient->fetch ( $resourceUrl, '', OAUTH_HTTP_METHOD_DELETE, $headers );
|
864 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
865 |
+
if (! $result ['isValidToken']) {
|
866 |
+
$this->sendResponse ( 401, json_encode ( array (
|
867 |
+
'error' => true,
|
868 |
+
'message' => 'Unauthorized'
|
869 |
+
) ) );
|
870 |
+
} else {
|
871 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
872 |
+
}
|
873 |
+
}
|
874 |
+
break;
|
875 |
+
case "apply_coupon" :
|
876 |
+
if ($this->get_request_method () != "POST") {
|
877 |
+
$this->sendResponse ( 400, json_encode ( array (
|
878 |
+
'error' => true,
|
879 |
+
'message' => 'Bad Request'
|
880 |
+
) ) );
|
881 |
+
} else {
|
882 |
+
$requestData = json_encode ( array (
|
883 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
884 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
885 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
886 |
+
'token' => $this->_request ['token'],
|
887 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
888 |
+
'coupon_code' => $this->_request ['coupon_code']
|
889 |
+
) );
|
890 |
+
$resourceUrl = "$apiUrl/coupon/apply/";
|
891 |
+
$headers = array (
|
892 |
+
'Content-Type' => 'application/json',
|
893 |
+
'Accept' => '*/*'
|
894 |
+
);
|
895 |
+
|
896 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
897 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
898 |
+
if (! $result ['isValidToken']) {
|
899 |
+
$this->sendResponse ( 401, json_encode ( array (
|
900 |
+
'error' => true,
|
901 |
+
'message' => 'Unauthorized'
|
902 |
+
) ) );
|
903 |
+
} else {
|
904 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
905 |
+
}
|
906 |
+
}
|
907 |
+
break;
|
908 |
+
|
909 |
+
case "cancel_coupon" :
|
910 |
+
if ($this->get_request_method () != "POST") {
|
911 |
+
$this->sendResponse ( 400, json_encode ( array (
|
912 |
+
'error' => true,
|
913 |
+
'message' => 'Bad Request'
|
914 |
+
) ) );
|
915 |
+
} else {
|
916 |
+
$requestData = json_encode ( array (
|
917 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
918 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
919 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
920 |
+
'token' => $this->_request ['token'],
|
921 |
+
'quote_id' => ( int ) $this->_request ['quote_id']
|
922 |
+
) );
|
923 |
+
$resourceUrl = "$apiUrl/coupon/cancel/";
|
924 |
+
$headers = array (
|
925 |
+
'Content-Type' => 'application/json',
|
926 |
+
'Accept' => '*/*'
|
927 |
+
);
|
928 |
+
|
929 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
930 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
931 |
+
if (! $result ['isValidToken']) {
|
932 |
+
$this->sendResponse ( 401, json_encode ( array (
|
933 |
+
'error' => true,
|
934 |
+
'message' => 'Unauthorized'
|
935 |
+
) ) );
|
936 |
+
} else {
|
937 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
938 |
+
}
|
939 |
+
}
|
940 |
+
break;
|
941 |
+
|
942 |
+
case "add_address_tocart" :
|
943 |
+
if ($this->get_request_method () != "POST") {
|
944 |
+
$this->sendResponse ( 400, json_encode ( array (
|
945 |
+
'error' => true,
|
946 |
+
'message' => 'Bad Request'
|
947 |
+
) ) );
|
948 |
+
} else {
|
949 |
+
$requestData = json_encode ( array (
|
950 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
951 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
952 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
953 |
+
'token' => $this->_request ['token'],
|
954 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
955 |
+
'billing_address_id' => ( int ) $this->_request ['billing_address_id'],
|
956 |
+
'shipping_address_id' => ( int ) $this->_request ['shipping_address_id']
|
957 |
+
) );
|
958 |
+
$headers = array (
|
959 |
+
'Content-Type' => 'application/json',
|
960 |
+
'Accept' => '*/*'
|
961 |
+
);
|
962 |
+
$resourceUrl = "$apiUrl/cart_address/add/";
|
963 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
964 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
965 |
+
if (! $result ['isValidToken']) {
|
966 |
+
$this->sendResponse ( 401, json_encode ( array (
|
967 |
+
'error' => true,
|
968 |
+
'message' => 'Unauthorized'
|
969 |
+
) ) );
|
970 |
+
} else {
|
971 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
972 |
+
}
|
973 |
+
}
|
974 |
+
break;
|
975 |
+
|
976 |
+
case "add_shipping_payment_tocart" :
|
977 |
+
|
978 |
+
if ($this->get_request_method () != "POST") {
|
979 |
+
$this->sendResponse ( 400, json_encode ( array (
|
980 |
+
'error' => true,
|
981 |
+
'message' => 'Bad Request'
|
982 |
+
) ) );
|
983 |
+
} else {
|
984 |
+
$requestData = json_encode ( array (
|
985 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
986 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
987 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
988 |
+
'token' => $this->_request ['token'],
|
989 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
990 |
+
'shipping_method' => $this->_request ['shipping_method'],
|
991 |
+
'payment_method' => $this->_request ['payment_method']
|
992 |
+
) );
|
993 |
+
$headers = array (
|
994 |
+
'Content-Type' => 'application/json',
|
995 |
+
'Accept' => '*/*'
|
996 |
+
);
|
997 |
+
$oauthClient->fetch ( "$apiUrl/cart/add_shipping_payment/", $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
998 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
999 |
+
if (! $result ['isValidToken']) {
|
1000 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1001 |
+
'error' => true,
|
1002 |
+
'message' => 'Unauthorized'
|
1003 |
+
) ) );
|
1004 |
+
} else {
|
1005 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1006 |
+
}
|
1007 |
+
}
|
1008 |
+
break;
|
1009 |
+
case "place_order" :
|
1010 |
+
|
1011 |
+
if ($this->get_request_method () != "POST") {
|
1012 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1013 |
+
'error' => true,
|
1014 |
+
'message' => 'Bad Request'
|
1015 |
+
) ) );
|
1016 |
+
} else {
|
1017 |
+
$requestData = json_encode ( array (
|
1018 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1019 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1020 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1021 |
+
'token' => $this->_request ['token'],
|
1022 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
1023 |
+
'shipping_method' => $this->_request ['shipping_method'],
|
1024 |
+
'payment_method' => $this->_request ['payment_method']
|
1025 |
+
) );
|
1026 |
+
$headers = array (
|
1027 |
+
'Content-Type' => 'application/json',
|
1028 |
+
'Accept' => '*/*'
|
1029 |
+
);
|
1030 |
+
$resourceUrl = "$apiUrl/place_order/";
|
1031 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1032 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1033 |
+
if (! $result ['isValidToken']) {
|
1034 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1035 |
+
'error' => true,
|
1036 |
+
'message' => 'Unauthorized'
|
1037 |
+
) ) );
|
1038 |
+
} else {
|
1039 |
+
|
1040 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
break;
|
1044 |
+
|
1045 |
+
case "paypal_standard" :
|
1046 |
+
|
1047 |
+
if ($this->get_request_method () != "POST") {
|
1048 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1049 |
+
'error' => true,
|
1050 |
+
'message' => 'Bad Request'
|
1051 |
+
) ) );
|
1052 |
+
} else {
|
1053 |
+
$requestData = (array (
|
1054 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1055 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1056 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1057 |
+
'token' => $this->_request ['token'],
|
1058 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
1059 |
+
'shipping_method' => $this->_request ['shipping_method'],
|
1060 |
+
'payment_method' => $this->_request ['payment_method']
|
1061 |
+
));
|
1062 |
+
$headers = array (
|
1063 |
+
'Content-Type' => 'application/json',
|
1064 |
+
'Accept' => '*/*'
|
1065 |
+
);
|
1066 |
+
$resourceUrl = "$apiUrl/paypal_standard/place_order/";
|
1067 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1068 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1069 |
+
if (! $result ['isValidToken']) {
|
1070 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1071 |
+
'error' => true,
|
1072 |
+
'message' => 'Unauthorized'
|
1073 |
+
) ) );
|
1074 |
+
} else {
|
1075 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1076 |
+
}
|
1077 |
+
}
|
1078 |
+
break;
|
1079 |
+
|
1080 |
+
case "myorders_list" :
|
1081 |
+
if ($this->get_request_method () != "POST") {
|
1082 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1083 |
+
'error' => true,
|
1084 |
+
'message' => 'Bad Request'
|
1085 |
+
) ) );
|
1086 |
+
} else {
|
1087 |
+
$page = (( int ) $this->_request ['page'] > 0 ? ( int ) $this->_request ['page'] : 1);
|
1088 |
+
$limit = (( int ) $this->_request ['limit'] > 0 ? ( int ) $this->_request ['limit'] : 10);
|
1089 |
+
$requestData = (array (
|
1090 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1091 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1092 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1093 |
+
'token' => $this->_request ['token'],
|
1094 |
+
'page' => $page,
|
1095 |
+
'limit' => $limit
|
1096 |
+
));
|
1097 |
+
$headers = array (
|
1098 |
+
'Content-Type' => 'application/json',
|
1099 |
+
'Accept' => '*/*'
|
1100 |
+
);
|
1101 |
+
$oauthClient->fetch ( "$apiUrl/myorders/", $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1102 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1103 |
+
$result1 = json_decode ( $result, true );
|
1104 |
+
if (! $result1 ['isValidToken']) {
|
1105 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1106 |
+
'error' => true,
|
1107 |
+
'message' => 'Unauthorized'
|
1108 |
+
) ) );
|
1109 |
+
} else {
|
1110 |
+
|
1111 |
+
$this->sendResponse ( 200, (($result)) );
|
1112 |
+
}
|
1113 |
+
}
|
1114 |
+
break;
|
1115 |
+
|
1116 |
+
case "myorder_detail" :
|
1117 |
+
if ($this->get_request_method () != "POST") {
|
1118 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1119 |
+
'error' => true,
|
1120 |
+
'message' => 'Bad Request'
|
1121 |
+
) ) );
|
1122 |
+
} else {
|
1123 |
+
$requestData = (array (
|
1124 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1125 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1126 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1127 |
+
'token' => $this->_request ['token'],
|
1128 |
+
'id' => ( int ) $this->_request ['order_id']
|
1129 |
+
));
|
1130 |
+
$headers = array (
|
1131 |
+
'Content-Type' => 'application/json',
|
1132 |
+
'Accept' => '*/*'
|
1133 |
+
);
|
1134 |
+
$oauthClient->fetch ( "$apiUrl/myorder_detail/", $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1135 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1136 |
+
$result1 = json_decode ( $result, true );
|
1137 |
+
if (! $result1 ['isValidToken']) {
|
1138 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1139 |
+
'error' => true,
|
1140 |
+
'message' => 'Unauthorized'
|
1141 |
+
) ) );
|
1142 |
+
} else {
|
1143 |
+
|
1144 |
+
$this->sendResponse ( 200, ($result) );
|
1145 |
+
}
|
1146 |
+
}
|
1147 |
+
break;
|
1148 |
+
|
1149 |
+
case "add_wishlist" :
|
1150 |
+
if ($this->get_request_method () != "POST") {
|
1151 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1152 |
+
'error' => true,
|
1153 |
+
'message' => 'Bad Request'
|
1154 |
+
) ) );
|
1155 |
+
} else {
|
1156 |
+
$requestData = json_encode ( array (
|
1157 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1158 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1159 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1160 |
+
'token' => $this->_request ['token'],
|
1161 |
+
'product_id' => ( int ) $this->_request ['product_id'],
|
1162 |
+
'qty' => ( int ) $this->_request ['qty']
|
1163 |
+
) );
|
1164 |
+
$headers = array (
|
1165 |
+
'Content-Type' => 'application/json',
|
1166 |
+
'Accept' => '*/*'
|
1167 |
+
);
|
1168 |
+
$resourceUrl = "$apiUrl//wishlist/add/";
|
1169 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1170 |
+
|
1171 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1172 |
+
|
1173 |
+
if (! $result ['isValidToken']) {
|
1174 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1175 |
+
'error' => true,
|
1176 |
+
'message' => 'Unauthorized'
|
1177 |
+
) ) );
|
1178 |
+
} else {
|
1179 |
+
|
1180 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1181 |
+
}
|
1182 |
+
}
|
1183 |
+
break;
|
1184 |
+
case "wishlist_list" :
|
1185 |
+
if ($this->get_request_method () != "POST") {
|
1186 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1187 |
+
'error' => true,
|
1188 |
+
'message' => 'Bad Request'
|
1189 |
+
) ) );
|
1190 |
+
} else {
|
1191 |
+
$requestData = (array (
|
1192 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1193 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1194 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1195 |
+
'token' => $this->_request ['token'],
|
1196 |
+
'page' => ( int ) $this->_request ['page'],
|
1197 |
+
'limit' => ( int ) $this->_request ['limit'],
|
1198 |
+
'image_size' => (int) $this->_request ['image_size']
|
1199 |
+
));
|
1200 |
+
$headers = array (
|
1201 |
+
'Content-Type' => 'application/json',
|
1202 |
+
'Accept' => '*/*'
|
1203 |
+
);
|
1204 |
+
$resourceUrl = "$apiUrl/wishlist/productlist/";
|
1205 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1206 |
+
|
1207 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1208 |
+
if (! $result ['isValidToken']) {
|
1209 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1210 |
+
'error' => true,
|
1211 |
+
'message' => 'Unauthorized'
|
1212 |
+
) ) );
|
1213 |
+
} else {
|
1214 |
+
|
1215 |
+
$this->sendResponse ( 200, ($result) );
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
break;
|
1219 |
+
|
1220 |
+
case "delete_wishlist" :
|
1221 |
+
if ($this->get_request_method () != "DELETE") {
|
1222 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1223 |
+
'error' => true,
|
1224 |
+
'message' => 'Bad Request'
|
1225 |
+
) ) );
|
1226 |
+
} else {
|
1227 |
+
|
1228 |
+
$storeId = $this->_request ['store_id'];
|
1229 |
+
$websiteId = $this->_request ['website_id'];
|
1230 |
+
|
1231 |
+
if ($this->_request ['customer_id'] && $this->_request ['customer_id'] != '') {
|
1232 |
+
$customerId = $this->_request ['customer_id'];
|
1233 |
+
} else {
|
1234 |
+
$customerId = '';
|
1235 |
+
}
|
1236 |
+
|
1237 |
+
if ($this->_request ['product_id'] && $this->_request ['product_id'] != '') {
|
1238 |
+
$productId = $this->_request ['product_id'];
|
1239 |
+
} else {
|
1240 |
+
$productId = '';
|
1241 |
+
}
|
1242 |
+
$token = $this->_request ['token'];
|
1243 |
+
|
1244 |
+
$resourceUrl = "$apiUrl/wishlist/delete/token/$token/product_id/$productId/customer_id/$customerId/store_id/$storeId/website_id/$websiteId/";
|
1245 |
+
$headers = array (
|
1246 |
+
'Content-Type' => 'application/json',
|
1247 |
+
'Accept' => '*/*'
|
1248 |
+
);
|
1249 |
+
$oauthClient->fetch ( $resourceUrl, '', OAUTH_HTTP_METHOD_DELETE, $headers );
|
1250 |
+
|
1251 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1252 |
+
if (! $result ['isValidToken']) {
|
1253 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1254 |
+
'error' => true,
|
1255 |
+
'message' => 'Unauthorized'
|
1256 |
+
) ) );
|
1257 |
+
} else {
|
1258 |
+
|
1259 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1260 |
+
}
|
1261 |
+
}
|
1262 |
+
break;
|
1263 |
+
|
1264 |
+
case "add_review" :
|
1265 |
+
if ($this->get_request_method () != "POST") {
|
1266 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1267 |
+
'error' => true,
|
1268 |
+
'message' => 'Bad Request'
|
1269 |
+
) ) );
|
1270 |
+
} else {
|
1271 |
+
$requestData = json_encode ( array (
|
1272 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1273 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1274 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1275 |
+
'token' => $this->_request ['token'],
|
1276 |
+
'product_id' => ( int ) $this->_request ['product_id'],
|
1277 |
+
'customer_name' => $this->_request ['customer_name'],
|
1278 |
+
'review_title' => $this->_request ['review_title'],
|
1279 |
+
'review_description' => $this->_request ['review_description'],
|
1280 |
+
'review_status' => ( int ) $this->_request ['review_status'],
|
1281 |
+
'rating' => $this->_request ['rating']
|
1282 |
+
) );
|
1283 |
+
$headers = array (
|
1284 |
+
'Content-Type' => 'application/json',
|
1285 |
+
'Accept' => '*/*'
|
1286 |
+
);
|
1287 |
+
$resourceUrl = "$apiUrl/add/reviews/";
|
1288 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1289 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1290 |
+
if (! $result ['isValidToken']) {
|
1291 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1292 |
+
'error' => true,
|
1293 |
+
'message' => 'Unauthorized'
|
1294 |
+
) ) );
|
1295 |
+
} else {
|
1296 |
+
|
1297 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1298 |
+
}
|
1299 |
+
}
|
1300 |
+
break;
|
1301 |
+
|
1302 |
+
case "reviews_list" :
|
1303 |
+
if ($this->get_request_method () != "GET") {
|
1304 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1305 |
+
'error' => true,
|
1306 |
+
'message' => 'Bad Request'
|
1307 |
+
) ) );
|
1308 |
+
} else {
|
1309 |
+
$requestData = (array (
|
1310 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1311 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1312 |
+
'product_id' => ( int ) $this->_request ['product_id'],
|
1313 |
+
'page' => ( int ) $this->_request ['page'],
|
1314 |
+
'limit' => ( int ) $this->_request ['limit']
|
1315 |
+
));
|
1316 |
+
$headers = array (
|
1317 |
+
'Content-Type' => 'application/json',
|
1318 |
+
'Accept' => '*/*'
|
1319 |
+
);
|
1320 |
+
$resourceUrl = "$apiUrl/reviews/list/";
|
1321 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1322 |
+
$result = $oauthClient->getLastResponse ();
|
1323 |
+
$this->sendResponse ( 200, ($result) );
|
1324 |
+
}
|
1325 |
+
break;
|
1326 |
+
|
1327 |
+
case "filters" :
|
1328 |
+
|
1329 |
+
if ($this->get_request_method () != "GET") {
|
1330 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1331 |
+
'error' => true,
|
1332 |
+
'message' => 'Bad Request'
|
1333 |
+
) ) );
|
1334 |
+
} else {
|
1335 |
+
$requestData = array (
|
1336 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1337 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1338 |
+
'category_id' => ( int ) $this->_request ['category_id']
|
1339 |
+
)
|
1340 |
+
;
|
1341 |
+
$headers = array (
|
1342 |
+
'Content-Type' => 'application/json',
|
1343 |
+
'Accept' => '*/*'
|
1344 |
+
);
|
1345 |
+
$resourceUrl = "$apiUrl/category/filters/";
|
1346 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1347 |
+
$result = $oauthClient->getLastResponse ();
|
1348 |
+
|
1349 |
+
$this->sendResponse ( 200, json_decode ( $result ) );
|
1350 |
+
}
|
1351 |
+
break;
|
1352 |
+
|
1353 |
+
case "my_downloadable" :
|
1354 |
+
|
1355 |
+
$page = (( int ) $this->_request ['page'] > 0 ? ( int ) $this->_request ['page'] : 1);
|
1356 |
+
$limit = (( int ) $this->_request ['limit'] > 0 ? ( int ) $this->_request ['limit'] : 10);
|
1357 |
+
if ($this->get_request_method () != "POST") {
|
1358 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1359 |
+
'error' => true,
|
1360 |
+
'message' => 'Bad Request'
|
1361 |
+
) ) );
|
1362 |
+
} else {
|
1363 |
+
$requestData = json_encode ( array (
|
1364 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1365 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1366 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1367 |
+
'token' => $this->_request ['token'],
|
1368 |
+
|
1369 |
+
'page' => $page,
|
1370 |
+
'limit' => $limit
|
1371 |
+
|
1372 |
+
) );
|
1373 |
+
$headers = array (
|
1374 |
+
'Content-Type' => 'application/json',
|
1375 |
+
'Accept' => '*/*'
|
1376 |
+
);
|
1377 |
+
$resourceUrl = "$apiUrl/my_download/products/";
|
1378 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1379 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1380 |
+
if (! $result ['isValidToken']) {
|
1381 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1382 |
+
'error' => true,
|
1383 |
+
'message' => 'Unauthorized'
|
1384 |
+
) ) );
|
1385 |
+
} else {
|
1386 |
+
|
1387 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
break;
|
1391 |
+
|
1392 |
+
case "bulk_add_tocart" :
|
1393 |
+
|
1394 |
+
if ($this->get_request_method () != "POST") {
|
1395 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1396 |
+
'error' => true,
|
1397 |
+
'message' => 'Bad Request'
|
1398 |
+
) ) );
|
1399 |
+
} else {
|
1400 |
+
$requestData = json_encode ( array (
|
1401 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1402 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1403 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1404 |
+
'token' => $this->_request ['token'],
|
1405 |
+
'currencyCode' => $this->_request ['currencyCode'],
|
1406 |
+
'detail' => json_decode($this->_request ['detail']),
|
1407 |
+
|
1408 |
+
) );
|
1409 |
+
|
1410 |
+
$resourceUrl = "$apiUrl/cart/bulk_add/";
|
1411 |
+
$headers = array (
|
1412 |
+
'Content-Type' => 'application/json',
|
1413 |
+
'Accept' => '*/*'
|
1414 |
+
);
|
1415 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1416 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1417 |
+
if (! $result ['isValidToken']) {
|
1418 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1419 |
+
'error' => true,
|
1420 |
+
'message' => 'Unauthorized'
|
1421 |
+
) ) );
|
1422 |
+
} else {
|
1423 |
+
|
1424 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1425 |
+
}
|
1426 |
+
}
|
1427 |
+
break;
|
1428 |
+
|
1429 |
+
case "bulk_update_cart" :
|
1430 |
+
|
1431 |
+
if ($this->get_request_method () != "POST") {
|
1432 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1433 |
+
'error' => true,
|
1434 |
+
'message' => 'Bad Request'
|
1435 |
+
) ) );
|
1436 |
+
} else {
|
1437 |
+
$requestData = json_encode ( array (
|
1438 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1439 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1440 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1441 |
+
'token' => $this->_request ['token'],
|
1442 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
1443 |
+
'currencyCode' => $this->_request ['currencyCode'],
|
1444 |
+
'detail' => json_decode($this->_request ['detail']),
|
1445 |
+
|
1446 |
+
) );
|
1447 |
+
|
1448 |
+
$resourceUrl = "$apiUrl/cart/bulk_update/";
|
1449 |
+
$headers = array (
|
1450 |
+
'Content-Type' => 'application/json',
|
1451 |
+
'Accept' => '*/*'
|
1452 |
+
);
|
1453 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
1454 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1455 |
+
if (! $result ['isValidToken']) {
|
1456 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1457 |
+
'error' => true,
|
1458 |
+
'message' => 'Unauthorized'
|
1459 |
+
) ) );
|
1460 |
+
} else {
|
1461 |
+
|
1462 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1463 |
+
}
|
1464 |
+
}
|
1465 |
+
break;
|
1466 |
+
|
1467 |
+
case "cart_add_address" :
|
1468 |
+
if ($this->get_request_method () != "POST") {
|
1469 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1470 |
+
'error' => true,
|
1471 |
+
'message' => 'Bad Request'
|
1472 |
+
) ) );
|
1473 |
+
} else {
|
1474 |
+
$requestData = json_encode ( array (
|
1475 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1476 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1477 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1478 |
+
'token' => $this->_request ['token'],
|
1479 |
+
'quote_id' => ( int ) $this->_request ['quote_id'],
|
1480 |
+
'billing_address_id' => ( int ) $this->_request ['billing_address_id'],
|
1481 |
+
'shipping_address_id' => ( int ) $this->_request ['shipping_address_id']
|
1482 |
+
) );
|
1483 |
+
$headers = array (
|
1484 |
+
'Content-Type' => 'application/json',
|
1485 |
+
'Accept' => '*/*'
|
1486 |
+
);
|
1487 |
+
$resourceUrl = "$apiUrl/cart_add_address/";
|
1488 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_POST, $headers );
|
1489 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1490 |
+
if (! $result ['isValidToken']) {
|
1491 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1492 |
+
'error' => true,
|
1493 |
+
'message' => 'Unauthorized'
|
1494 |
+
) ) );
|
1495 |
+
} else {
|
1496 |
+
|
1497 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1498 |
+
}
|
1499 |
+
}
|
1500 |
+
break;
|
1501 |
+
|
1502 |
+
case "clear_wishlist" :
|
1503 |
+
|
1504 |
+
if ($this->get_request_method () != "POST") {
|
1505 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1506 |
+
'error' => true,
|
1507 |
+
'message' => 'Bad Request'
|
1508 |
+
) ) );
|
1509 |
+
} else {
|
1510 |
+
|
1511 |
+
$requestData = json_encode ( array (
|
1512 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1513 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1514 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1515 |
+
'token' => $this->_request ['token'],
|
1516 |
+
) );
|
1517 |
+
|
1518 |
+
$resourceUrl = "$apiUrl/wishlist/clear/";
|
1519 |
+
$headers = array (
|
1520 |
+
'Content-Type' => 'application/json',
|
1521 |
+
'Accept' => '*/*'
|
1522 |
+
);
|
1523 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
1524 |
+
$result = json_decode ( $oauthClient->getLastResponse (), true );
|
1525 |
+
if (! $result ['isValidToken']) {
|
1526 |
+
$this->sendResponse ( 401, json_encode ( array (
|
1527 |
+
'error' => true,
|
1528 |
+
'message' => 'Unauthorized'
|
1529 |
+
) ) );
|
1530 |
+
} else {
|
1531 |
+
$this->sendResponse ( 200, json_encode ( $result ) );
|
1532 |
+
}
|
1533 |
+
}
|
1534 |
+
break;
|
1535 |
+
|
1536 |
+
|
1537 |
+
case "offer_products" :
|
1538 |
+
|
1539 |
+
if ($this->get_request_method () != "GET") {
|
1540 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1541 |
+
'error' => true,
|
1542 |
+
'message' => 'Bad Request'
|
1543 |
+
) ) );
|
1544 |
+
} else {
|
1545 |
+
|
1546 |
+
$requestData = array (
|
1547 |
+
'offer_id' => ( int ) $this->_request ['offer_id'],
|
1548 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1549 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1550 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1551 |
+
'page' => ( int ) $this->_request ['page'],
|
1552 |
+
'limit' => ( int ) $this->_request ['limit']
|
1553 |
+
|
1554 |
+
);
|
1555 |
+
$headers = array (
|
1556 |
+
'Content-Type' => 'application/json',
|
1557 |
+
'Accept' => '*/*'
|
1558 |
+
);
|
1559 |
+
$resourceUrl = "$apiUrl/offer_products/";
|
1560 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_GET, $headers );
|
1561 |
+
|
1562 |
+
$this->sendResponse ( 200, $oauthClient->getLastResponse () );
|
1563 |
+
|
1564 |
+
}
|
1565 |
+
break;
|
1566 |
+
|
1567 |
+
case "gcmtoken_update" :
|
1568 |
+
|
1569 |
+
if ($this->get_request_method () != "POST") {
|
1570 |
+
$this->sendResponse ( 400, json_encode ( array (
|
1571 |
+
'error' => true,
|
1572 |
+
'message' => 'Bad Request'
|
1573 |
+
) ) );
|
1574 |
+
} else {
|
1575 |
+
$requestData = json_encode ( array (
|
1576 |
+
'website_id' => ( int ) $this->_request ['website_id'],
|
1577 |
+
'store_id' => ( int ) $this->_request ['store_id'],
|
1578 |
+
'customer_id' => ( int ) $this->_request ['customer_id'],
|
1579 |
+
'device_token' => $this->_request ['device_token'],
|
1580 |
+
'device_type' => $this->_request ['device_type']
|
1581 |
+
|
1582 |
+
) );
|
1583 |
+
|
1584 |
+
$resourceUrl = "$apiUrl/customer/gcmtoken_update/";
|
1585 |
+
$headers = array (
|
1586 |
+
'Content-Type' => 'application/json',
|
1587 |
+
'Accept' => '*/*'
|
1588 |
+
);
|
1589 |
+
$oauthClient->fetch ( $resourceUrl, $requestData, OAUTH_HTTP_METHOD_PUT, $headers );
|
1590 |
+
$this->sendResponse ( 200, $oauthClient->getLastResponse());
|
1591 |
+
}
|
1592 |
+
break;
|
1593 |
+
|
1594 |
+
default :
|
1595 |
+
$this->sendResponse ( 405, json_encode ( array (
|
1596 |
+
'error' => true,
|
1597 |
+
'message' => 'Method Not Allowed'
|
1598 |
+
) ) );
|
1599 |
+
break;
|
1600 |
+
}
|
1601 |
+
} catch ( OAuthException $e ) {
|
1602 |
+
|
1603 |
+
$errorMessage = json_decode ( $e->lastResponse );
|
1604 |
+
$error ['message'] = $errorMessage->messages->error [0]->message;
|
1605 |
+
$error ['code'] = $errorMessage->messages->error [0]->code;
|
1606 |
+
|
1607 |
+
$this->sendResponse ( $error ['code'], json_encode ( array (
|
1608 |
+
'error' => true,
|
1609 |
+
'message' => (isset ( $error ['message'] )) ? $error ['message'] : $e->getMessage() ,
|
1610 |
+
'success' => 0
|
1611 |
+
) ) );
|
1612 |
+
}
|
1613 |
+
} catch ( OAuthException $e ) {
|
1614 |
+
$errorMessage = json_decode ( $e->lastResponse );
|
1615 |
+
$error ['message'] = $errorMessage->messages->error [0]->message;
|
1616 |
+
$error ['code'] = $errorMessage->messages->error [0]->code;
|
1617 |
+
$this->sendResponse ( $error ['code'], json_encode ( array (
|
1618 |
+
'error' => true,
|
1619 |
+
'message' => (isset ( $error ['message'] )) ? $error ['message'] : 'Unexpected error occurs.' ,
|
1620 |
+
'success' => 0
|
1621 |
+
) ) );
|
1622 |
+
}
|
1623 |
+
}
|
1624 |
+
|
1625 |
+
// Encode array into JSON
|
1626 |
+
private function json($data) {
|
1627 |
+
if (is_array ( $data )) {
|
1628 |
+
return json_encode ( $data );
|
1629 |
+
}
|
1630 |
+
}
|
1631 |
+
}
|
1632 |
+
// instantiated Library
|
1633 |
+
$api = new API ();
|
1634 |
+
$api->processApi ();
|
1635 |
+
?>
|
skin/adminhtml/default/default/popup.css
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
.simplemodal-overlay {
|
3 |
+
background: #000;
|
4 |
+
}
|
5 |
+
|
6 |
+
.simplemodal-container {
|
7 |
+
left: 0 !important;
|
8 |
+
width: 80% !important;
|
9 |
+
}
|
10 |
+
|
11 |
+
.simplemodal-wrap {
|
12 |
+
width: 20% !important;
|
13 |
+
margin: 0 auto;
|
14 |
+
}
|
15 |
+
|
16 |
+
.pop-up {
|
17 |
+
background: #FFF;
|
18 |
+
padding: 15PX;
|
19 |
+
width: 500px !important;
|
20 |
+
}
|
21 |
+
|
22 |
+
.pop-up input, .pop-up textarea{
|
23 |
+
border-width: 1px;
|
24 |
+
border-style: solid;
|
25 |
+
border-color: #AAA #C8C8C8 #C8C8C8 #AAA;
|
26 |
+
background: none repeat scroll 0% 0% #FFF;
|
27 |
+
font: 12px arial,helvetica,sans-serif;
|
28 |
+
display: block;
|
29 |
+
width: 98%;
|
30 |
+
padding: 5px;
|
31 |
+
margin-bottom: 10px;
|
32 |
+
|
33 |
+
}
|
34 |
+
|
35 |
+
.pop-up input[type="text"]:disabled {
|
36 |
+
background: #dddddd;
|
37 |
+
}
|
38 |
+
|
39 |
+
.pop-up input.cancel {
|
40 |
+
border-width: 1px;
|
41 |
+
border-style: solid;
|
42 |
+
border-color: #ED6502 #A04300 #A04300 #ED6502;
|
43 |
+
padding: 0px 7px 2px;
|
44 |
+
|
45 |
+
background: url(images/btn_bg.gif) repeat-x scroll 0px 100% #FFAC47;
|
46 |
+
color: #FFF;
|
47 |
+
font: bold 12px arial,helvetica,sans-serif;
|
48 |
+
cursor: pointer;
|
49 |
+
text-align: center !important;
|
50 |
+
white-space: nowrap;
|
51 |
+
vertical-align: middle;
|
52 |
+
display: inline-block;
|
53 |
+
width: auto;
|
54 |
+
margin-bottom: 0;}
|