Version Notes
Reference API
Download this release
Release Info
Developer | H5mag |
Extension | h5mage-commerceapi |
Version | 0.0.1 |
Comparing to | |
See all releases |
Version 0.0.1
- app/code/community/H5mag/ShopApi/Model/Generic.php +148 -0
- app/code/community/H5mag/ShopApi/Model/Order/Observer.php +56 -0
- app/code/community/H5mag/ShopApi/Model/Product.php +63 -0
- app/code/community/H5mag/ShopApi/controllers/CheckoutController.php +55 -0
- app/code/community/H5mag/ShopApi/controllers/IndexController.php +46 -0
- app/code/community/H5mag/ShopApi/etc/adminhtml.xml +25 -0
- app/code/community/H5mag/ShopApi/etc/config.xml +44 -0
- app/code/community/H5mag/ShopApi/etc/system.xml +69 -0
- app/design/frontend/base/default/template/h5mag/shopapi/emptycart.phtml +6 -0
- app/etc/modules/H5mag_ShopApi.xml +9 -0
- package.xml +18 -0
app/code/community/H5mag/ShopApi/Model/Generic.php
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* H5mag
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
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://opensource.org/licenses/osl-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@h5mag.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @copyright Copyright (c) 2013 H5mag Inc. (http://www.h5mag.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Generic Product model for H5mag
|
21 |
+
*
|
22 |
+
* @category H5mag ShopApi
|
23 |
+
* @package H5mag_ShopApi
|
24 |
+
*/
|
25 |
+
class H5mag_ShopApi_Model_Generic extends H5mag_ShopApi_Model_Product {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Constructor of this object
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
$this->_init('h5mag_shopapi/generic');
|
33 |
+
parent::_construct();
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Set the locale that will be used when fetching product information
|
38 |
+
*
|
39 |
+
* @param string $locale Locale to be used. e.g. en_us
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function setLocale($locale) {
|
43 |
+
$stores = Mage::getModel('core/store')->getCollection();
|
44 |
+
foreach ($stores as $store) {
|
45 |
+
$store->load();
|
46 |
+
if (strtolower($store->getConfig('general/locale/code')) == strtolower($locale)) {
|
47 |
+
$this->storeId = $store->getId();
|
48 |
+
$this->locale = $locale;
|
49 |
+
break;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get the JSON representation of this product
|
56 |
+
*
|
57 |
+
* @return string json encoded string
|
58 |
+
*/
|
59 |
+
public function fetch($id) {
|
60 |
+
if (empty($id)) throw new Exception(E_NO_PRODUCT_ID_SPECIFIED);
|
61 |
+
|
62 |
+
// Use locale to set current store or use the default one
|
63 |
+
if (empty($this->storeId)) $this->storeId = Mage::app()->getStore()->getId();
|
64 |
+
Mage::app()->setCurrentStore($this->storeId);
|
65 |
+
|
66 |
+
// Fetch our product
|
67 |
+
$product = Mage::getModel('catalog/product')->load($id);
|
68 |
+
|
69 |
+
|
70 |
+
if ($product->getId()) {
|
71 |
+
// Add product description to data
|
72 |
+
$this->data = array(
|
73 |
+
'id' => $product->getId(),
|
74 |
+
'name' => $product->getName(),
|
75 |
+
'text' => $product->getDescription(),
|
76 |
+
);
|
77 |
+
$this->data['locale'] = (!empty($this->locale)) ? $this->locale : Mage::app()->getStore()->getConfig('general/locale/code');
|
78 |
+
|
79 |
+
// Get variants of this product
|
80 |
+
$variants = array();
|
81 |
+
if ($product->isConfigurable()) {
|
82 |
+
$variants = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
|
83 |
+
$this->data['variants'] = array();
|
84 |
+
} else if ($product->getTypeId() == 'simple') {
|
85 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
86 |
+
if(!$parentIds) {
|
87 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
88 |
+
if(isset($parentIds[0])){
|
89 |
+
$parent = Mage::getModel('catalog/product')->load($parentIds[0]);
|
90 |
+
$variants = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $parent);
|
91 |
+
} else {
|
92 |
+
$variants[] = $product;
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
$variants[] = $product;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
// Add variants to data
|
100 |
+
foreach ($variants as $variant) {
|
101 |
+
$store = Mage::getModel('core/store')->load($variant->getStoreId());
|
102 |
+
$data = array();
|
103 |
+
$data['currency'] = $store->getCurrentCurrencyCode();
|
104 |
+
$data['id'] = $variant->getSku(); // Send the SKU instead of the actual database id
|
105 |
+
$data['name'] = $variant->getName();
|
106 |
+
$data['price'] = $variant->getPrice() * 100; // H5mag uses cents
|
107 |
+
$data['pictures'] = array();
|
108 |
+
$data['stock'] = 0;
|
109 |
+
$data['available'] = false;
|
110 |
+
if ($variant->isAvailable()) {
|
111 |
+
$inventory = Mage::getModel('cataloginventory/stock_item')->loadByProduct($variant);
|
112 |
+
$data['stock'] = (int)$inventory->getQty();
|
113 |
+
$data['available'] = true;
|
114 |
+
}
|
115 |
+
// Get images
|
116 |
+
if ($image = $variant->getImageUrl()) $data['pictures'][] = $image;
|
117 |
+
if ($image = $variant->getSmallImageUrl()) $data['pictures'][] = $image;
|
118 |
+
if ($image = $variant->getThumbnailUrl()) $data['pictures'][] = $image;
|
119 |
+
|
120 |
+
// Optional properties
|
121 |
+
// TODO: Move these to config.xml and make an admin panel where these can be configured
|
122 |
+
/*if ($variant->offsetExists('color') && $color = $variant->getAttributeText('color') ) {
|
123 |
+
$data['color'] = $color;
|
124 |
+
}
|
125 |
+
if ($variant->offsetExists('hexcolor') && $hex_color = $variant->getAttributeText('hexcolor') ) {
|
126 |
+
$data['display-color'] = "#{$hex_color}";
|
127 |
+
}*/
|
128 |
+
|
129 |
+
if ($dimensions = $variant->getDimensions()) $data['dimensions'] = $dimensions;
|
130 |
+
$this->data['variants'][] = $data;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get the JSON representation of this product
|
137 |
+
*
|
138 |
+
* @return string json encoded string
|
139 |
+
*/
|
140 |
+
public function json() {
|
141 |
+
if (!empty($this->data)) {
|
142 |
+
return json_encode($this->data);
|
143 |
+
} else {
|
144 |
+
return json_encode(array('message' => self::E_PRODUCT_NOT_FOUND));
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
app/code/community/H5mag/ShopApi/Model/Order/Observer.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* H5mag
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
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://opensource.org/licenses/osl-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@h5mag.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @copyright Copyright (c) 2013 H5mag Inc. (http://www.h5mag.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Observer for H5mag
|
21 |
+
*
|
22 |
+
* @category H5mag ShopApi
|
23 |
+
* @package H5mag_ShopApi
|
24 |
+
*/
|
25 |
+
class H5mag_ShopApi_Model_Order_Observer {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Constructor
|
29 |
+
*/
|
30 |
+
public function __construct() {
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Empty shopping cart
|
35 |
+
*
|
36 |
+
* @param Varien_Event_Observer $observer
|
37 |
+
* @return H5mag_ShopApi_Model_Order_Observer
|
38 |
+
*/
|
39 |
+
public function emptyCart($observer) {
|
40 |
+
$controller = $observer->getAction();
|
41 |
+
if ($controller instanceOf Mage_Checkout_OnepageController) {
|
42 |
+
$action = $controller->getFullActionName();
|
43 |
+
if ($action == 'checkout_onepage_success') {
|
44 |
+
$layout = $observer->getLayout();
|
45 |
+
$layout->getUpdate()->addUpdate('
|
46 |
+
<reference name="content">
|
47 |
+
<block name="shopapi.cart" type="core/template" template="h5mag/shopapi/emptycart.phtml">
|
48 |
+
</block>
|
49 |
+
</reference>
|
50 |
+
');
|
51 |
+
}
|
52 |
+
}
|
53 |
+
return $this;
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
app/code/community/H5mag/ShopApi/Model/Product.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* H5mag
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
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://opensource.org/licenses/osl-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@h5mag.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @copyright Copyright (c) 2013 H5mag Inc. (http://www.h5mag.com)
|
16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
17 |
+
*/
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Abstract model for Product
|
21 |
+
* @category H5mag ShopApi
|
22 |
+
* @package H5mag_ShopApi
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
abstract class H5mag_ShopApi_Model_Product extends Mage_Core_Model_Abstract {
|
26 |
+
|
27 |
+
/* Loaded data goes here */
|
28 |
+
protected $data;
|
29 |
+
|
30 |
+
/* Locale */
|
31 |
+
protected $locale;
|
32 |
+
|
33 |
+
/* Store id to use */
|
34 |
+
protected $storeId;
|
35 |
+
|
36 |
+
/* Error messages */
|
37 |
+
const E_NO_PRODUCT_ID_SPECIFIED = 'No product ID specified';
|
38 |
+
const E_PRODUCT_NOT_FOUND = 'Sorry, we cannot find the requested product in our shop.';
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Set the locale that will be used when fetching product information
|
42 |
+
*
|
43 |
+
* @param string $locale Locale to be used. e.g. en_us
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
abstract public function setLocale($locale);
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Load the product.
|
50 |
+
*
|
51 |
+
* @param integer $id product ID
|
52 |
+
* @return void
|
53 |
+
*/
|
54 |
+
abstract public function fetch($id);
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Get the JSON representation of this product
|
58 |
+
*
|
59 |
+
* @return string json encoded string
|
60 |
+
*/
|
61 |
+
abstract public function json();
|
62 |
+
|
63 |
+
}
|
app/code/community/H5mag/ShopApi/controllers/CheckoutController.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* H5mag
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
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://opensource.org/licenses/osl-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@h5mag.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category H5mag ShopApi
|
16 |
+
* @package H5mag_ShopApi
|
17 |
+
* @copyright Copyright (c) 2013 H5mag (http://www.h5mag.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
class H5mag_ShopApi_CheckoutController extends Mage_Core_Controller_Front_Action {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Put products in shopping cart, update session and redirect to checkout/cart
|
24 |
+
*/
|
25 |
+
public function indexAction() {
|
26 |
+
$skus = $this->getRequest()->getParam('sku');
|
27 |
+
// Redirect user to checkout cart if no skus have been sent
|
28 |
+
if (empty($skus)) $this->_redirect('checkout/cart');
|
29 |
+
|
30 |
+
// Add products to shopping cart
|
31 |
+
$cart = Mage::getModel('checkout/cart')->init()->truncate();
|
32 |
+
foreach ($skus as $sku => $quantity) {
|
33 |
+
$product = Mage::getModel('catalog/product');
|
34 |
+
$product->load($product->getIdBySku($sku));
|
35 |
+
if ($product->getId() && $product->isAvailable()) {
|
36 |
+
$cart->addProduct($product, array('qty' => $quantity));
|
37 |
+
}
|
38 |
+
}
|
39 |
+
$cart->save();
|
40 |
+
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
|
41 |
+
|
42 |
+
// Update cart in session
|
43 |
+
if ($cart->getItemsCount() > 0) {
|
44 |
+
$empty_cart = $this->getRequest()->getParam('cart');
|
45 |
+
$url = strtolower(Mage::app()->getStore()->getConfig('h5mag_shopapi_magazine/general/url'));
|
46 |
+
if (preg_match('/^http:\/\//', $url) == false) $url = "http://{$url}";
|
47 |
+
if (preg_match('\/$') == false) $url .= '/';
|
48 |
+
Mage::getSingleton('core/session')->setH5magShopApiCartUrl("{$url}system/shop/empty-cart?cart={$empty_cart}");
|
49 |
+
$this->_redirect('checkout/cart');
|
50 |
+
} else {
|
51 |
+
echo 'Products out-of-stock.';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
app/code/community/H5mag/ShopApi/controllers/IndexController.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* H5mag
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
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://opensource.org/licenses/osl-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@h5mag.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category H5mag ShopApi
|
16 |
+
* @package H5mag_ShopApi
|
17 |
+
* @copyright Copyright (c) 2013 H5mag (http://www.h5mag.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
class H5mag_ShopApi_IndexController extends Mage_Core_Controller_Front_Action {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Get product and variants
|
24 |
+
*/
|
25 |
+
public function indexAction() {
|
26 |
+
$product_id = $this->getRequest()->getParam('id');
|
27 |
+
$callback = $this->getRequest()->getParam('callback');
|
28 |
+
if (empty($product_id)) throw new Exception(E_NO_PRODUCT_ID_SPECIFIED);
|
29 |
+
$product = Mage::getModel('h5mag_shopapi/'. Mage::app()->getStore()->getConfig('h5mag_shopapi_developer/general/model'));
|
30 |
+
if (!$product) $product = Mage::getModel('h5mag_shopapi/generic');
|
31 |
+
$locale = $this->getRequest()->getParam('locale');
|
32 |
+
if (!empty($locale)) $product->setLocale($locale);
|
33 |
+
$product->fetch($product_id);
|
34 |
+
$this->send($callback.'('.$product->json().')');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Send JSON data back to client
|
39 |
+
*/
|
40 |
+
private function send($data){
|
41 |
+
header('Content-Type: application/json; charset=utf-8');
|
42 |
+
header('Content-Length: '.strlen($data));
|
43 |
+
die($data);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
app/code/community/H5mag/ShopApi/etc/adminhtml.xml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<h5mag_shopapi_magazine>
|
12 |
+
<title>Magazine</title> <!-- Used in resources tree -->
|
13 |
+
</h5mag_shopapi_magazine>
|
14 |
+
<h5mag_shopapi_developer>
|
15 |
+
<title>Developer</title> <!-- Used in resources tree -->
|
16 |
+
</h5mag_shopapi_developer>
|
17 |
+
</children>
|
18 |
+
</config>
|
19 |
+
</children>
|
20 |
+
</system>
|
21 |
+
</children>
|
22 |
+
</admin>
|
23 |
+
</resources>
|
24 |
+
</acl>
|
25 |
+
</config>
|
app/code/community/H5mag/ShopApi/etc/config.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<frontend>
|
4 |
+
<routers>
|
5 |
+
<h5mag_shopapi>
|
6 |
+
<use>standard</use>
|
7 |
+
<args>
|
8 |
+
<module>H5mag_ShopApi</module>
|
9 |
+
<frontName>h5magshopapi</frontName>
|
10 |
+
</args>
|
11 |
+
</h5mag_shopapi>
|
12 |
+
</routers>
|
13 |
+
</frontend>
|
14 |
+
<modules>
|
15 |
+
<H5mag_ShopApi>
|
16 |
+
<version>0.0.1</version>
|
17 |
+
</H5mag_ShopApi>
|
18 |
+
</modules>
|
19 |
+
<global>
|
20 |
+
<models>
|
21 |
+
<h5mag_shopapi>
|
22 |
+
<class>H5mag_ShopApi_Model</class>
|
23 |
+
</h5mag_shopapi>
|
24 |
+
</models>
|
25 |
+
<events>
|
26 |
+
<controller_action_layout_generate_xml_before>
|
27 |
+
<observers>
|
28 |
+
<h5mag_shopapi_order_observer>
|
29 |
+
<type>singleton</type>
|
30 |
+
<class>H5mag_ShopApi_Model_Order_Observer</class>
|
31 |
+
<method>emptyCart</method>
|
32 |
+
</h5mag_shopapi_order_observer>
|
33 |
+
</observers>
|
34 |
+
</controller_action_layout_generate_xml_before>
|
35 |
+
</events>
|
36 |
+
</global>
|
37 |
+
<default>
|
38 |
+
<tab1>
|
39 |
+
<general>
|
40 |
+
<text_field></text_field>
|
41 |
+
</general>
|
42 |
+
</tab1>
|
43 |
+
</default>
|
44 |
+
</config>
|
app/code/community/H5mag/ShopApi/etc/system.xml
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<h5mag_shopapi translate="label">
|
5 |
+
<label>H5mag configuration</label>
|
6 |
+
<sort_order>150</sort_order>
|
7 |
+
</h5mag_shopapi>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<h5mag_shopapi_magazine translate="label" module="adminhtml">
|
11 |
+
<label>Magazine</label>
|
12 |
+
<tab>h5mag_shopapi</tab>
|
13 |
+
<sort_order>10</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 |
+
<groups>
|
18 |
+
<general translate="label comment">
|
19 |
+
<label>General</label>
|
20 |
+
<sort_order>50</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<comment></comment>
|
25 |
+
<fields>
|
26 |
+
<url translate="label comment">
|
27 |
+
<label>URL</label>
|
28 |
+
<comment>The URL of the H5mag magazine</comment>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>10</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</url>
|
35 |
+
</fields>
|
36 |
+
</general>
|
37 |
+
</groups>
|
38 |
+
</h5mag_shopapi_magazine>
|
39 |
+
<h5mag_shopapi_developer translate="label" module="adminhtml">
|
40 |
+
<label>Developer</label>
|
41 |
+
<tab>h5mag_shopapi</tab>
|
42 |
+
<sort_order>10</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
<groups>
|
47 |
+
<general translate="label comment">
|
48 |
+
<label>General</label>
|
49 |
+
<sort_order>50</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<comment></comment>
|
54 |
+
<fields>
|
55 |
+
<model translate="label comment">
|
56 |
+
<label>Model</label>
|
57 |
+
<comment><![CDATA[The Model used to fetch products.<br />If none is specified then the Generic model will be used.]]></comment>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
+
<sort_order>10</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>1</show_in_store>
|
63 |
+
</model>
|
64 |
+
</fields>
|
65 |
+
</general>
|
66 |
+
</groups>
|
67 |
+
</h5mag_shopapi_developer>
|
68 |
+
</sections>
|
69 |
+
</config>
|
app/design/frontend/base/default/template/h5mag/shopapi/emptycart.phtml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $url = Mage::getSingleton('core/session')->getH5magShopApiCartUrl();?>
|
2 |
+
<?php error_log($url);?>
|
3 |
+
<?php if (!empty($url)) :?>
|
4 |
+
<iframe src="<?php echo $url?>" width="1" height="1" scrolling="no" frameborder="0" border="0"></iframe>
|
5 |
+
<?php Mage::getSingleton('core/session')->unsH5magShopApiCartUrl() ?>
|
6 |
+
<?php endif;?>
|
app/etc/modules/H5mag_ShopApi.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<H5mag_ShopApi>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</H5mag_ShopApi>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>h5mage-commerceapi</name>
|
4 |
+
<version>0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.h5mag.com">Open Software License (OSL 3.0)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Connect your store with H5mag</summary>
|
10 |
+
<description>Sell your products through your H5mag online magazine</description>
|
11 |
+
<notes>Reference API</notes>
|
12 |
+
<authors><author><name>H5mag</name><user>h5mag</user><email>info@h5mag.com</email></author></authors>
|
13 |
+
<date>2015-08-19</date>
|
14 |
+
<time>08:03:53</time>
|
15 |
+
<contents><target name="mageetc"><dir><dir name="modules"><file name="H5mag_ShopApi.xml" hash="a7f3540be0ca960e3c4342c97ff10611"/></dir></dir></target><target name="magecommunity"><dir><dir name="H5mag"><dir name="ShopApi"><dir name="Model"><file name="Generic.php" hash="c8c85ff2d02afced85d889e35ff54274"/><dir name="Order"><file name="Observer.php" hash="d6d859b3d426db207a0f26b9c09dc8cf"/></dir><file name="Product.php" hash="61fc08e108376c890e4ad4cb60aba130"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="4198c5faf44b0d5896948cb9e3f48a14"/><file name="IndexController.php" hash="48f95ac755532b43f22b04dde8e85f19"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4d5313c01a1c7eb331ec9e14b05de9a3"/><file name="config.xml" hash="49001110e909ff73da3765fb9e6195a7"/><file name="system.xml" hash="87c0aa8a8201293ce9d3aa762ea37707"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="h5mag"><dir name="shopapi"><file name="emptycart.phtml" hash="858809d6c1b4f3301f7716fcc751ef05"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.10</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|