veeqo_bridge - Version 0.1.0

Version Notes

First stable release

Download this release

Release Info

Developer Veeqo
Extension veeqo_bridge
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Veeqo/Bridge/Block/Adminhtml/Veeqo.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Veeqo_Bridge_Block_Adminhtml_Veeqo extends Mage_Adminhtml_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setTemplate('veeqo/veeqo.phtml');
8
+
9
+ }
10
+ }
app/code/community/Veeqo/Bridge/Helper/Data.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Veeqo_Bridge_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ const XML_PATH_BRIDGE2CART_URL = 'veeqo/general/bridge2cart_url';
6
+ const XML_VALIDATION_URL = 'veeqo/general/validation_url';
7
+
8
+ public function getBridge2CartUrlXmlPath()
9
+ {
10
+ return self::XML_PATH_BRIDGE2CART_URL;
11
+ }
12
+
13
+ public function getBridge2CartUrl()
14
+ {
15
+ return Mage::getStoreConfig(self::XML_PATH_BRIDGE2CART_URL);
16
+ }
17
+
18
+ public function getValidationUrl()
19
+ {
20
+ return Mage::getStoreConfig(self::XML_VALIDATION_URL);
21
+ }
22
+ }
app/code/community/Veeqo/Bridge/Model/Installer.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Veeqo_Bridge_Model_Installer
4
+ {
5
+ public function downloadAndCheck($download_url)
6
+ {
7
+ try {
8
+ $download_result = $this->downloadFile($download_url);
9
+ if ($download_result['status'] != 1) {
10
+ Mage::getSingleton('adminhtml/session')->addError($download_result['message']);
11
+ return false;
12
+ }
13
+
14
+ $check_result = $this->CheckBridge($download_url);
15
+ if ($check_result['status'] == 200) {
16
+ Mage::getConfig()->saveConfig(Mage::helper('veeqo')->getBridge2CartUrlXmlPath(), $download_url);
17
+ Mage::app()->getCacheInstance()->cleanType('config');
18
+ return true;
19
+ } elseif ($check_result['status'] == 400) {
20
+ Mage::getSingleton('adminhtml/session')->addError($this->__($check_result['error_messages']));
21
+ return false;
22
+ } else {
23
+ $error_msg = $this->__("Please check Veeqo Validation Url. Response code: %d", $check_result['status']);
24
+ Mage::getSingleton('adminhtml/session')->addError($error_msg);
25
+ return false;
26
+ }
27
+
28
+ if (!isset($check_result['status'])) {
29
+ Mage::getSingleton('adminhtml/session')->addError($this->__($check_result['error']));
30
+ return false;
31
+ }
32
+ }
33
+ catch (Mage_Core_Exception $e) {
34
+ Mage::getSingleton('adminhtml/session')->addError($this->__('An error occured during the installation. See exception.log.'));
35
+ Mage::throwException($e->getMessages());
36
+ return false;
37
+ }
38
+ catch (exception $e) {
39
+ Mage::getSingleton('adminhtml/session')->addError($e);
40
+ Mage::logException($e);
41
+ return false;
42
+ }
43
+ return false;
44
+ }
45
+
46
+ private function downloadFile($remote_url)
47
+ {
48
+ $mage_root = dirname(Mage::getRoot());
49
+ $dest_dir = $mage_root . DIRECTORY_SEPARATOR . 'bridge2cart';
50
+ $tmp_filename = 'bridge.zip';
51
+ $result = array('status' => 1);
52
+
53
+ // create the destination directory if doesn't exists
54
+ if (!file_exists($dest_dir) || !is_dir($dest_dir)) {
55
+ mkdir($dest_dir, 0755);
56
+ }
57
+
58
+ // Download the file from remote server to temporary file
59
+ $destinationFilePath = $dest_dir . DIRECTORY_SEPARATOR . $tmp_filename;
60
+ $client = new Varien_Http_Client($remote_url, array('keepalive' => true));
61
+ $client ->setUri($remote_url)->setMethod('GET');
62
+ $response = $client->request();
63
+ $status = $response->getStatus();
64
+ if ($status == 200) {
65
+ $body = $response->getRawBody();
66
+ $content_type = $response->getHeader('content-type');
67
+ if ($content_type=='application/zip'){
68
+ $fp = fopen($destinationFilePath, 'w');
69
+ file_put_contents($destinationFilePath, $response->getBody());
70
+ fclose($fp);
71
+
72
+ // return the error message if download failed
73
+ if (!file_exists($destinationFilePath)) {
74
+ $result['status'] = 0;
75
+ $result['message'] = $this->__("Can't download the file from server.");
76
+ return $result;
77
+ }
78
+
79
+ // Unzip temporary file to destination directory
80
+ try {
81
+
82
+ $filter = new Zend_Filter_Decompress(array('adapter' =>
83
+ 'Zend_Filter_Compress_Zip', 'options' => array('target' => $mage_root, )));
84
+ $filter->filter($destinationFilePath);
85
+ @unlink($mage_root . DIRECTORY_SEPARATOR . 'readme.txt');
86
+ }
87
+ catch (Mage_Core_Exception $e) {
88
+ $result['status'] = 0;
89
+ $result['message'] = $this->__($e);
90
+ return $result;
91
+ }
92
+ }
93
+ else
94
+ {
95
+ $xml_response = simplexml_load_string($body);
96
+ $msg = 'Error code '.$xml_response->return_code.' - '.$xml_response->return_message;
97
+ $result['status'] = 0;
98
+ $result['message'] = $this->__($msg);
99
+ return $result;
100
+ }
101
+ }
102
+
103
+ return $result;
104
+ }
105
+
106
+ private function CheckBridge($download_url)
107
+ {
108
+ $validation_url = Mage::helper('veeqo')->getValidationUrl();
109
+
110
+ $result = array('status' => null);
111
+
112
+ if (!$download_url) {
113
+ $result['error_messages'] = $this->__('Bridge2CartUrl Download Url is empty');
114
+ return $result;
115
+ }
116
+
117
+ $parts = parse_url($download_url);
118
+ $query = array();
119
+ parse_str($parts['query'], $query);
120
+
121
+ if (!isset($query['store_key']) || $query['store_key'] == '') {
122
+ $result['error_messages'] = $this->__('Bridge2CartUrl Download Url have not "store_key" param.');
123
+ return $result;
124
+ }
125
+
126
+ if (!$validation_url) {
127
+ $result['error_messages'] = $this->__('Veeqo Validation Url is empty');
128
+ return $result;
129
+ }
130
+
131
+ $client = new Varien_Http_Client();
132
+ $raw_params = array("store_key" => $query['store_key']);
133
+ $raw_data = Mage::helper('core')->jsonEncode($raw_params);
134
+ $client->setUri($validation_url)->setMethod('POST')->setConfig(array(
135
+ 'maxredirects' => 0,
136
+ 'timeout' => 30,
137
+ ))->setRawData($raw_data,
138
+ "application/json;charset=UTF-8");
139
+
140
+ $response = $client->request();
141
+ $body = $response->getRawBody();
142
+
143
+ $result = Mage::helper('core')->jsonDecode($body);
144
+ $result['status'] = $response->getStatus();
145
+
146
+ return $result;
147
+ }
148
+
149
+ private function __($msg)
150
+ {
151
+ $args = func_get_args();
152
+ $expr = new Mage_Core_Model_Translate_Expr(array_shift($args), 'veeqo');
153
+ array_unshift($args, $expr);
154
+ return Mage::app()->getTranslator()->translate($args);
155
+ }
156
+ }
app/code/community/Veeqo/Bridge/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Veeqo_Bridge_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('veeqo');
9
+ return $this;
10
+ }
11
+
12
+ public function indexAction() {
13
+ if (!extension_loaded('zip'))
14
+ {
15
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please Enable PHP ZIP extension'));
16
+ }
17
+ $this->_initAction()
18
+ ->renderLayout();
19
+ }
20
+
21
+ }
app/code/community/Veeqo/Bridge/controllers/Adminhtml/InstallController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Veeqo_Bridge_Adminhtml_InstallController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ if (!$this->_validateFormKey() || !$this->getRequest()->isPost()) {
8
+ $this->_forward('noRoute');
9
+ return;
10
+ }
11
+
12
+ $download_url = $this->getRequest()->getPost('download_url', null);
13
+ if (!$download_url) {
14
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please enter Bridge2Cart Download Url'));
15
+ } else {
16
+ $installer_model = Mage::getModel('veeqo/installer');
17
+ $result = $installer_model->downloadAndCheck($download_url);
18
+
19
+ if ($result) {
20
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Bridge2Cart Installed Succesfully.'));
21
+ }
22
+ }
23
+
24
+ $redirectUrl = Mage::helper("adminhtml")->getUrl("veeqo/adminhtml_index/index");
25
+ $this->_redirectUrl($redirectUrl);
26
+ }
27
+ }
app/code/community/Veeqo/Bridge/etc/adminhtml.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <veeqo module="veeqo">
5
+ <title>Veeqo Bridge</title>
6
+ <sort_order>100</sort_order>
7
+ <action>veeqo/adminhtml_index</action>
8
+ </veeqo>
9
+ </menu>
10
+ <acl>
11
+ <resources>
12
+ <admin>
13
+ <children>
14
+ <veeqo translate="title" module="veeqo">
15
+ <title>Veeqo Bridge</title>
16
+ <sort_order>10</sort_order>
17
+ </veeqo>
18
+ </children>
19
+ </admin>
20
+ </resources>
21
+ </acl>
22
+ </config>
app/code/community/Veeqo/Bridge/etc/config.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Veeqo_Bridge>
5
+ <version>0.1.0</version>
6
+ </Veeqo_Bridge>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <veeqo>
11
+ <use>admin</use>
12
+ <args>
13
+ <module>Veeqo_Bridge</module>
14
+ <frontName>veeqo</frontName>
15
+ </args>
16
+ </veeqo>
17
+ </routers>
18
+ </admin>
19
+ <adminhtml>
20
+ <layout>
21
+ <updates>
22
+ <veeqo>
23
+ <file>veeqo.xml</file>
24
+ </veeqo>
25
+ </updates>
26
+ </layout>
27
+ <translate>
28
+ <modules>
29
+ <Veeqo_Bridge>
30
+ <files>
31
+ <default>Veeqo_Bridge.csv</default>
32
+ </files>
33
+ </Veeqo_Bridge>
34
+ </modules>
35
+ </translate>
36
+ </adminhtml>
37
+ <global>
38
+ <helpers>
39
+ <veeqo>
40
+ <class>Veeqo_Bridge_Helper</class>
41
+ </veeqo>
42
+ </helpers>
43
+ <blocks>
44
+ <veeqo>
45
+ <class>Veeqo_Bridge_Block</class>
46
+ </veeqo>
47
+ </blocks>
48
+ <models>
49
+ <veeqo>
50
+ <class>Veeqo_Bridge_Model</class>
51
+ </veeqo>
52
+ </models>
53
+ <resources>
54
+ <veeqo_setup>
55
+ <setup>
56
+ <module>Veeqo_Bridge</module>
57
+ </setup>
58
+ <connection>
59
+ <use>core_setup</use>
60
+ </connection>
61
+ </veeqo_setup>
62
+ <veeqo_write>
63
+ <connection>
64
+ <use>core_write</use>
65
+ </connection>
66
+ </veeqo_write>
67
+ <veeqo_read>
68
+ <connection>
69
+ <use>core_read</use>
70
+ </connection>
71
+ </veeqo_read>
72
+ </resources>
73
+ </global>
74
+ <default>
75
+ <veeqo>
76
+ <general>
77
+ <validation_url>http://veeqo.com/channels/magento_webhook</validation_url>
78
+ </general>
79
+ </veeqo>
80
+ </default>
81
+ </config>
app/design/adminhtml/default/default/layout/veeqo.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <veeqo_adminhtml_index_index>
4
+ <reference name="head">
5
+ <action method="addItem"><type>skin_css</type><name>veeqo/css/styles.css</name></action>
6
+ </reference>
7
+ <reference name="content">
8
+ <block type="veeqo/adminhtml_veeqo" name="veeqo"/>
9
+ </reference>
10
+ </veeqo_adminhtml_index_index>
11
+ </layout>
app/design/adminhtml/default/default/template/veeqo/veeqo.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $btn_title = $this->__('Install Script');
3
+ $text = $this->__('<p>Thank you for installing the Veeqo Magento Extension!</p><p>To complete the link between Magento and Veeqo you need to do the following:</p><ul><li>(1) Sign up for a free account on <a href="http://Veeqo.com" target="_blank" title="Veeqo">Veeqo.com</a></li><li>(2) Create Magento sales channel in Veeqo</li><li>(3) Copy the special URL Veeqo gives you after creating the sales channel and paste it in the field below and press "Install".</li><li>(4) All done, Veeqo will start syncing your products and orders, the first time might take 30 minutes</li></ul>');
4
+ if (Mage::helper('veeqo')->getBridge2CartUrl()) {
5
+ $btn_title = $this->__('Re-Install/Update Script');
6
+ $text = $this->__('<p>Magento and Veeqo already connected</p><p>Your Magento store is already connected to <a href="http://Veeqo.com" target="_blank" title="Veeqo">Veeqo.com</a> and you do not need to do anything on this page.</p>');
7
+ }
8
+ ?>
9
+ <div class="content-header">
10
+ <table cellspacing="0">
11
+ <tr>
12
+ <td><h3 class="head-veeqo"><?php echo $this->__('Veeqo Bridge') ?></h3></td>
13
+ </tr>
14
+ </table>
15
+ </div>
16
+ <div class="veeqo-container">
17
+ <div id="veeqo_messages"><?php echo $text?></div>
18
+ <div class="veeqo_uploader">
19
+ <form id="veeqo_install_form" method="post" action="<?php echo Mage::helper("adminhtml")->getUrl('veeqo/adminhtml_install/index')?>">
20
+ <div>
21
+ <input type="hidden" value="<?php echo $this->getFormKey()?>" name="form_key"/>
22
+ </div>
23
+ <div class="fieldset ">
24
+ <div class="label">
25
+ <label for="bridge2cart_url"><?php echo $this->__('Bridge2Cart Download Url')?>: </label>
26
+ </div>
27
+ <div class="value">
28
+ <input id="bridge2cart_url" type="text" name="download_url" class="input-text required-entry validate-url" value="<?php echo Mage::helper('veeqo')->getBridge2CartUrl()?>"/>
29
+ </div>
30
+ </div>
31
+ <div class="actions">
32
+ <button id="bridge2cart_run" class="scalable" style="" onclick="installForm.submit();" type="button" title="<?php echo $btn_title?>">
33
+ <span><span><span><?php echo $btn_title?></span></span></span>
34
+ </button>
35
+ </div>
36
+ </form>
37
+ </div>
38
+ <script type="text/javascript">
39
+ Validation.add('validate-url', 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', function(v) {
40
+ v = (v || '').replace(/^\s+/, '').replace(/\s+$/, '');
41
+ return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(v)
42
+ });
43
+ var installForm = new varienForm('veeqo_install_form', '');
44
+ </script>
45
+ </div>
app/etc/modules/Veeqo_Bridge.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Veeqo_Bridge>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Veeqo_Bridge>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>veeqo_bridge</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Multi-Channel order and inventory management software, bulk ship orders with Royal Mail integration.</summary>
10
+ <description>&lt;p&gt;Multi-Channel order and inventory management software, syncing your data across all your channels.&lt;/p&gt;&#xD;
11
+ &#xD;
12
+ &lt;h2&gt;Key Features &lt;/h2&gt;&#xD;
13
+ &#xD;
14
+ &lt;li&gt;Bulk ship orders and print &lt;strong&gt;Royal Mail&lt;/strong&gt; and FedEx labels. &lt;/li&gt;&#xD;
15
+ &lt;li&gt; Web based, works on tablets/phones/Pc's and Mac's&lt;/li&gt;&#xD;
16
+ &lt;li&gt;Create and send purchase orders to suppliers&lt;/li&gt;&#xD;
17
+ &lt;li&gt;Multiple inventory locations and transfer items between locations.&lt;/li&gt;&#xD;
18
+ &lt;li&gt; Sync inventory to your other marketplaces such as Amazon so you can manage stock in one place&lt;/li&gt;&#xD;
19
+ &lt;li&gt;Download orders from Amazon and Magento to manage them all in one place and use advance tools like tags and custom filters &lt;/li&gt;&#xD;
20
+ &lt;li&gt;Works with barcode scanners to search for products&lt;/li&gt;&#xD;
21
+ &lt;li&gt; Beautiful to look at and very easy to use &lt;/li&gt;</description>
22
+ <notes>First stable release</notes>
23
+ <authors><author><name>Veeqo</name><user>Veeqo</user><email>helpme@veeqo.com</email></author></authors>
24
+ <date>2014-01-16</date>
25
+ <time>14:18:49</time>
26
+ <contents><target name="magecommunity"><dir><dir name="Veeqo"><dir name="Bridge"><dir name="Block"><dir name="Adminhtml"><file name="Veeqo.php" hash="715b2aa2ad291b4410fe9575ae593a77"/></dir></dir><dir name="Helper"><file name="Data.php" hash="11cc7e2958d7545424b4c94226e9bc5a"/></dir><dir name="Model"><file name="Installer.php" hash="a402167b5bb9981f0b65a97f5a7b0b5e"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="44cf0afc6fda8f333fc7b9bac068896a"/><file name="InstallController.php" hash="896718b4d7df17ec2a04cc18318b5281"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="5c0990f04a9dc2bdc17f1379ffd692da"/><file name="config.xml" hash="7052c54357b55bda2678545d8db7eb14"/></dir></dir></dir></dir></target><target name="mage"><dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Veeqo_Bridge.xml" hash="b0020889060ad13cd00142fef74e8479"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="veeqo.xml" hash="cdd078a0e10be1d457ae3d8af723fea2"/></dir><dir name="template"><dir name="veeqo"><file name="veeqo.phtml" hash="5ac132fa5e2047feedf0b0a658307924"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="veeqo"><dir name="css"><file name="styles.css" hash="62c1eb55527467abd31c531561537352"/></dir></dir></dir></dir></dir></dir></target></contents>
27
+ <compatible/>
28
+ <dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
29
+ </package>
skin/adminhtml/default/default/veeqo/css/styles.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ .veeqo-container {
2
+ padding:20px; background-color:#EAF7FF; border:1px solid #CCCCCC;
3
+ }
4
+ .veeqo-container .label,
5
+ .veeqo-container .value {float:left; margin-right:10px;}
6
+ #bridge2cart_url {width:450px;}
7
+ #veeqo_messages {margin-bottom:20px;}