Version Notes
Stable
Download this release
Release Info
Developer | Lexity |
Extension | Lexity_GoogleShopping |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.3.1
- app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit.php +23 -0
- app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Form.php +20 -0
- app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Tab/Form.php +47 -0
- app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Tabs.php +23 -0
- app/code/local/LexityGoogleShopping/Block/Embed.php +10 -0
- app/code/local/LexityGoogleShopping/Model/Core.php +119 -98
- app/code/local/LexityGoogleShopping/controllers/CoreController.php +0 -20
- app/code/local/LexityGoogleShopping/controllers/MarketingController.php +53 -6
- app/code/local/LexityGoogleShopping/etc/api.xml +6 -6
- app/code/local/LexityGoogleShopping/etc/config.xml +29 -14
- package.xml +9 -15
app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LexityGoogleShopping_Block_Credentials_Form_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
|
3 |
+
|
4 |
+
public function __construct() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit');
|
6 |
+
parent::__construct();
|
7 |
+
$this->_objectId = 'credentials';
|
8 |
+
$this->_blockGroup = 'lexitygoogleshopping';
|
9 |
+
$this->_controller = 'credentials_form';
|
10 |
+
$this->_mode = 'edit';
|
11 |
+
$this->_removeButton('reset')
|
12 |
+
->_removeButton('back')
|
13 |
+
->_removeButton('save');
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getHeaderText() {
|
17 |
+
Mage::log('Lexity: You got the header text');
|
18 |
+
return Mage::helper('lexitygoogleshopping')->__('Account Information');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
?>
|
app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Form.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LexityGoogleShopping_Block_Credentials_Form_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
|
3 |
+
|
4 |
+
protected function _prepareForm() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Form');
|
6 |
+
$form = new Varien_Data_Form(array(
|
7 |
+
'id' => 'edit_form',
|
8 |
+
'action' => $this->getUrl(
|
9 |
+
'*/*/newapp',
|
10 |
+
array('credentials' => $this->getRequest()->getParam('credentials'))
|
11 |
+
),
|
12 |
+
'method' => 'post',
|
13 |
+
'enctype' => 'multipart/form-data'
|
14 |
+
));
|
15 |
+
|
16 |
+
$form->setUseContainer(true);
|
17 |
+
$this->setForm($form);
|
18 |
+
return parent::_prepareForm();
|
19 |
+
}
|
20 |
+
}
|
app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LexityGoogleShopping_Block_Credentials_Form_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
3 |
+
|
4 |
+
protected function _prepareForm() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Tab Form');
|
6 |
+
$form = new Varien_Data_Form();
|
7 |
+
$this->setForm($form);
|
8 |
+
$fieldset = $form->addFieldset(
|
9 |
+
'form_form',
|
10 |
+
array('legend'=>Mage::helper('lexitygoogleshopping')->__('Account Information')));
|
11 |
+
Mage::log('Lexity: fieldset');
|
12 |
+
$fieldset->addField('email', 'text', array(
|
13 |
+
'label' => Mage::helper('lexitygoogleshopping')->__('Email'),
|
14 |
+
'class' => 'required-entry',
|
15 |
+
'required' => true,
|
16 |
+
'name' => 'email',
|
17 |
+
'value' => Mage::getSingleton('admin/session')->getUser()->getEmail(),
|
18 |
+
'tabindex' => 1
|
19 |
+
));
|
20 |
+
Mage::log('Lexity: addfield email');
|
21 |
+
$fieldset->addField('password', 'password', array(
|
22 |
+
'label' => Mage::helper('lexitygoogleshopping')->__('Password'),
|
23 |
+
'class' => 'required-entry',
|
24 |
+
'required' => true,
|
25 |
+
'name' => 'password',
|
26 |
+
'after_element_html' => '<small>This is your Lexity account password</small>',
|
27 |
+
'tabindex' => 2
|
28 |
+
));
|
29 |
+
Mage::log('Lexity: addfield password');
|
30 |
+
$fieldset->addField('domain', 'text', array(
|
31 |
+
'label' => Mage::helper('lexitygoogleshopping')->__('Domain'),
|
32 |
+
'class' => 'required-entry',
|
33 |
+
'required' => true,
|
34 |
+
'name' => 'domain',
|
35 |
+
'value' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
|
36 |
+
'readonly' => true,
|
37 |
+
'tabindex' => 3
|
38 |
+
));
|
39 |
+
Mage::log('Lexity: addfield domain');
|
40 |
+
$fieldset->addField('submit', 'submit', array(
|
41 |
+
'value' => 'Create Account',
|
42 |
+
'tabindex' => 4
|
43 |
+
));
|
44 |
+
Mage::log('Lexity: addfield submit');
|
45 |
+
return parent::_prepareForm();
|
46 |
+
}
|
47 |
+
}
|
app/code/local/LexityGoogleShopping/Block/Credentials/Form/Edit/Tabs.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LexityGoogleShopping_Block_Credentials_Form_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
|
3 |
+
|
4 |
+
public function __construct() {
|
5 |
+
Mage::log('Lexity: In Block Form Edit Tabs');
|
6 |
+
parent::__construct();
|
7 |
+
$this->setId('form_tabs');
|
8 |
+
// this should be same as the form id in Credentials_Form_Edit_Form.php
|
9 |
+
$this->setDestElementId('edit_form');
|
10 |
+
$this->setTitle(Mage::helper('lexitygoogleshopping')->__('Lexity Account'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml() {
|
14 |
+
Mage::log('Lexity: Writing form to html');
|
15 |
+
$this->addTab('form_section', array(
|
16 |
+
'label' => Mage::helper('lexitygoogleshopping')->__('Account Information'),
|
17 |
+
'title' => Mage::helper('lexitygoogleshopping')->__('Account Information'),
|
18 |
+
'content' => $this->getLayout()->createBlock('lexitygoogleshopping/credentials_form_edit_tab_form')->toHtml(),
|
19 |
+
));
|
20 |
+
|
21 |
+
return parent::_beforeToHtml();
|
22 |
+
}
|
23 |
+
}
|
app/code/local/LexityGoogleShopping/Block/Embed.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LexityLive_Block_Embed extends Mage_Adminhtml_Block_Template
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->setTemplate('lexitygoogleshopping/embed.phtml');
|
8 |
+
}
|
9 |
+
}
|
10 |
+
?>
|
app/code/local/LexityGoogleShopping/Model/Core.php
CHANGED
@@ -1,11 +1,20 @@
|
|
1 |
<?php
|
2 |
-
class LexityGoogleShopping_Model_Core extends Mage_Core_Model_Config
|
3 |
-
|
4 |
-
public $app_name = 'google_shopping';
|
5 |
public $platform = 'magento';
|
6 |
|
7 |
-
public function
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
$resource = Mage::getSingleton('core/resource');
|
10 |
$readConnection = $resource->getConnection('core_read');
|
11 |
$tableName = $resource->getTableName('api/user');
|
@@ -13,150 +22,162 @@ class LexityGoogleShopping_Model_Core extends Mage_Core_Model_Config
|
|
13 |
return isset($results[0]);
|
14 |
}
|
15 |
|
16 |
-
public function
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
->setName('lexity_google_shopping')
|
20 |
->setPid(false)
|
|
|
|
|
21 |
->setRoleType('G')
|
22 |
->save();
|
|
|
|
|
|
|
23 |
|
24 |
-
|
|
|
25 |
->setRoleId($role->getId())
|
26 |
->setResources(array('all'))
|
27 |
->saveRel();
|
28 |
-
|
|
|
|
|
29 |
$user = Mage::getModel('api/user');
|
30 |
$user->setData(array(
|
31 |
'username' => 'lexity_google_shopping',
|
32 |
'firstname' => 'lexity',
|
33 |
'lastname' => 'lexity',
|
34 |
'email' => 'support+google_shopping@lexity.com',
|
35 |
-
'api_key' => $
|
36 |
-
'api_key_confirmation' => $
|
37 |
'is_active' => 1,
|
38 |
'user_roles' => '',
|
39 |
'assigned_user_role' => '',
|
40 |
'role_name' => '',
|
41 |
'roles' => array($role->getId())
|
42 |
));
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
public function create_account($new_token = null)
|
52 |
-
{
|
53 |
-
$user = Mage::getModel('api/user');
|
54 |
-
$user->loadByUsername('lexity_google_shopping');
|
55 |
-
|
56 |
-
$hash = $user->getApiKey();
|
57 |
-
$hashArr = explode(':', $hash);
|
58 |
-
switch (count($hashArr)) {
|
59 |
-
case 1:
|
60 |
-
$token = $hash;
|
61 |
-
break;
|
62 |
-
case 2:
|
63 |
-
$token = $hashArr[0];
|
64 |
-
$skey = $hashArr[1];
|
65 |
-
break;
|
66 |
}
|
67 |
-
$hashed_token = $token;
|
68 |
|
69 |
-
|
70 |
-
|
|
|
|
|
71 |
}
|
72 |
|
73 |
-
$admin_user = Mage::getSingleton('admin/session');
|
74 |
-
$admin_email = $admin_user->getUser()->getEmail();
|
75 |
$uri = "https://lexity.com/api/account/create?app="
|
76 |
-
.
|
77 |
. "&platform=" . $this->platform . "&password=" . $token
|
78 |
. "&login=lexity_google_shopping"
|
79 |
-
. "&email=" . urlencode($
|
80 |
. "&url=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
81 |
-
|
82 |
if (isset($skey)) {
|
83 |
-
$uri .= "&skey
|
84 |
}
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
87 |
$client = new Varien_Http_Client($uri);
|
88 |
$response = $client->request('GET');
|
89 |
$body = $response->getBody();
|
90 |
-
|
91 |
$decode = json_decode($body);
|
92 |
if (!isset($decode->error) && isset($decode->public_id)) {
|
93 |
-
$this->saveConfig('lexity/
|
94 |
-
$this->saveConfig('lexity/
|
95 |
Mage::getConfig()->reinit();
|
96 |
Mage::app()->reinitStores();
|
|
|
|
|
97 |
}
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
. "&email=" . urlencode($admin_email)
|
102 |
-
. "&platform=" . $this->platform . "&token=" . $hashed_token
|
103 |
-
. "&public_id=" . $decode->public_id
|
104 |
-
. "&domain=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
105 |
-
}
|
106 |
-
|
107 |
-
public function get_lexity_login_url($target = null)
|
108 |
-
{
|
109 |
-
$user = Mage::getModel('api/user');
|
110 |
-
$user->loadByUsername('lexity_google_shopping');
|
111 |
-
|
112 |
-
$hash = $user->getApiKey();
|
113 |
-
$hashArr = explode(':', $hash);
|
114 |
-
switch (count($hashArr)) {
|
115 |
-
case 1:
|
116 |
-
$token = $hash;
|
117 |
-
break;
|
118 |
-
case 2:
|
119 |
-
$token = $hashArr[0];
|
120 |
-
$skey = $hashArr[1];
|
121 |
-
break;
|
122 |
}
|
|
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
Mage::app()->getCacheInstance()->cleanType('config');
|
125 |
-
$public_id = Mage::getStoreConfig('lexity/
|
126 |
-
$
|
127 |
-
|
128 |
-
|
129 |
-
. $this->app_name
|
130 |
. "&platform=" . $this->platform . "&token=" . $token
|
131 |
. "&public_id=" . $public_id
|
132 |
-
. "&email=" . urlencode($
|
133 |
. "&domain=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
134 |
-
|
135 |
if (!empty($target)) {
|
136 |
$redirect_url .= "&target=${target}";
|
137 |
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
if (!$this->has_lexity_user()) {
|
150 |
-
$this->add_lexity_user($token);
|
151 |
-
} else {
|
152 |
-
$user = Mage::getModel('api/user')->loadByUsername("lexity_google_shopping");
|
153 |
-
$user->setApiKey($token);
|
154 |
-
$user->save();
|
155 |
}
|
156 |
-
|
|
|
157 |
}
|
158 |
|
159 |
-
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
}
|
162 |
?>
|
1 |
<?php
|
2 |
+
class LexityGoogleShopping_Model_Core extends Mage_Core_Model_Config {
|
3 |
+
|
|
|
4 |
public $platform = 'magento';
|
5 |
|
6 |
+
public function report_error($errors) {
|
7 |
+
$message = 'An error has occured <br>';
|
8 |
+
foreach ($errors as $sub => $msg) {
|
9 |
+
$message .= $sub . ': ' . $msg . '<br>';
|
10 |
+
}
|
11 |
+
$message .= 'Please contact Lexity support for more assistance <br> '
|
12 |
+
.' support@lexity.com or 1-855-533-8144';
|
13 |
+
// Mage::getSingleton('core/session')->addError($message);
|
14 |
+
die($message);
|
15 |
+
}
|
16 |
+
|
17 |
+
public function has_lexity_user() {
|
18 |
$resource = Mage::getSingleton('core/resource');
|
19 |
$readConnection = $resource->getConnection('core_read');
|
20 |
$tableName = $resource->getTableName('api/user');
|
22 |
return isset($results[0]);
|
23 |
}
|
24 |
|
25 |
+
public function get_api_key() {
|
26 |
+
if ($this->has_lexity_user()) {
|
27 |
+
$user = Mage::getModel('api/user');
|
28 |
+
$user->loadByUsername('lexity_google_shopping');
|
29 |
+
return $user->getApiKey();
|
30 |
+
} else {
|
31 |
+
return null;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
public function check_credentials() {
|
36 |
+
$token = $this->get_api_key();
|
37 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
38 |
+
$public_id = Mage::getStoreConfig('lexity/public_id');
|
39 |
+
$email = Mage::getStoreConfig('lexity/email');
|
40 |
+
if ($token == null && $public_id == null && $email == null) {
|
41 |
+
return 'getcredentials';
|
42 |
+
} else if (isset($public_id) && isset($email) && $token == null) {
|
43 |
+
return 'newapp';
|
44 |
+
} else {
|
45 |
+
return 'redirect';
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
public function create_account($email=null, $password=null) {
|
50 |
+
$token = md5(uniqid());
|
51 |
+
$errors = array();
|
52 |
+
if ($email == null) {
|
53 |
+
$email = Mage::getStoreConfig('lexity/email');
|
54 |
+
}
|
55 |
+
|
56 |
+
try {
|
57 |
+
$role = Mage::getModel('api/roles')
|
58 |
->setName('lexity_google_shopping')
|
59 |
->setPid(false)
|
60 |
+
// RoleType is either 'G' for group or 'U' for user since we create
|
61 |
+
// a new api and role for each app maybe we should change it to 'U'
|
62 |
->setRoleType('G')
|
63 |
->save();
|
64 |
+
} catch (Exception $e) {
|
65 |
+
$errors['Role'] = 'Api Role could not be made: ' . $e->getMessage();
|
66 |
+
}
|
67 |
|
68 |
+
try {
|
69 |
+
Mage::getModel("api/rules")
|
70 |
->setRoleId($role->getId())
|
71 |
->setResources(array('all'))
|
72 |
->saveRel();
|
73 |
+
} catch (Exception $e) {
|
74 |
+
$errors['Rule'] = 'Api Rule could not be made: ' . $e->getMessage();
|
75 |
+
}
|
76 |
$user = Mage::getModel('api/user');
|
77 |
$user->setData(array(
|
78 |
'username' => 'lexity_google_shopping',
|
79 |
'firstname' => 'lexity',
|
80 |
'lastname' => 'lexity',
|
81 |
'email' => 'support+google_shopping@lexity.com',
|
82 |
+
'api_key' => $token,
|
83 |
+
'api_key_confirmation' => $token,
|
84 |
'is_active' => 1,
|
85 |
'user_roles' => '',
|
86 |
'assigned_user_role' => '',
|
87 |
'role_name' => '',
|
88 |
'roles' => array($role->getId())
|
89 |
));
|
90 |
+
try {
|
91 |
+
$user->save()->load($user->getId());
|
92 |
+
$user->setRoleIds(array($role->getId()))
|
93 |
+
->setRoleUserId($user->getUserId())
|
94 |
+
->saveRelations();
|
95 |
+
} catch (Exception $e) {
|
96 |
+
$errors['User'] = 'Api User could not be made: ' . $e->getMessage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
|
|
98 |
|
99 |
+
$hash = $this->get_api_key();
|
100 |
+
$hash_array = explode(':', $hash);
|
101 |
+
if (count($hash_array) == 2) {
|
102 |
+
$skey = $hash_array[1];
|
103 |
}
|
104 |
|
|
|
|
|
105 |
$uri = "https://lexity.com/api/account/create?app="
|
106 |
+
. "google_shopping"
|
107 |
. "&platform=" . $this->platform . "&password=" . $token
|
108 |
. "&login=lexity_google_shopping"
|
109 |
+
. "&email=" . urlencode($email)
|
110 |
. "&url=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
|
|
111 |
if (isset($skey)) {
|
112 |
+
$uri .= "&skey=" . $skey;
|
113 |
}
|
114 |
+
if (isset($password)) {
|
115 |
+
// should I hash this password?...at least urlencode it
|
116 |
+
$uri .= "&user_password=" . urlencode($password);
|
117 |
+
}
|
118 |
+
// initiate handshake
|
119 |
$client = new Varien_Http_Client($uri);
|
120 |
$response = $client->request('GET');
|
121 |
$body = $response->getBody();
|
122 |
+
// interpret response
|
123 |
$decode = json_decode($body);
|
124 |
if (!isset($decode->error) && isset($decode->public_id)) {
|
125 |
+
$this->saveConfig('lexity/public_id', $decode->public_id);
|
126 |
+
$this->saveConfig('lexity/email', $email);
|
127 |
Mage::getConfig()->reinit();
|
128 |
Mage::app()->reinitStores();
|
129 |
+
} else {
|
130 |
+
$errors['Registration'] = $decode->error . '<br>' . $uri;
|
131 |
}
|
132 |
|
133 |
+
if ($errors) {
|
134 |
+
$this->report_error($errors);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
+
}
|
137 |
|
138 |
+
public function get_lexity_login_url($target = null) {
|
139 |
+
Mage::log('Lexity: getting lexity login url');
|
140 |
+
$errors = array();
|
141 |
+
$token = $this->get_api_key();
|
142 |
+
$token_array = explode(':', $token);
|
143 |
+
if (count($token_array) == 2) {
|
144 |
+
$token = $token_array[0];
|
145 |
+
} else {
|
146 |
+
$redirect['errors']['API User'] = 'token does not have hash key';
|
147 |
+
} // else the token has no skey
|
148 |
+
// Clean Cache
|
149 |
Mage::app()->getCacheInstance()->cleanType('config');
|
150 |
+
$public_id = Mage::getStoreConfig('lexity/public_id');
|
151 |
+
$email = Mage::getStoreConfig('lexity/email');
|
152 |
+
$redirect_url= "https://lexity.com/api/account/login?app="
|
153 |
+
. "google_shopping"
|
|
|
154 |
. "&platform=" . $this->platform . "&token=" . $token
|
155 |
. "&public_id=" . $public_id
|
156 |
+
. "&email=" . urlencode($email)
|
157 |
. "&domain=" . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
|
|
158 |
if (!empty($target)) {
|
159 |
$redirect_url .= "&target=${target}";
|
160 |
}
|
161 |
+
Mage::log('Lexity: this is the url: ' . $redirect_url);
|
162 |
+
try {
|
163 |
+
$client = new Varien_Http_Client($redirect_url);
|
164 |
+
$response = $client->request('GET');
|
165 |
+
$body = $response->getBody();
|
166 |
+
// interpret response
|
167 |
+
$decode = json_decode($body);
|
168 |
+
if (isset($decode->error)) {
|
169 |
+
Mage::log('Lexity: Error encountered while getting redirect');
|
170 |
+
$errors['Redirect URL'] = $decode->error . '<br>' . $redirect_url;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
+
} catch (Exception $e) {
|
173 |
+
Mage::log('Lexity: Redirect successful');
|
174 |
}
|
175 |
|
176 |
+
if ($errors) {
|
177 |
+
$this->report_error($errors);
|
178 |
+
} else {
|
179 |
+
return $redirect_url;
|
180 |
+
}
|
181 |
}
|
182 |
}
|
183 |
?>
|
app/code/local/LexityGoogleShopping/controllers/CoreController.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class LexityGoogleShopping_CoreController extends Mage_Adminhtml_Controller_Action
|
3 |
-
{
|
4 |
-
public function golexityAction()
|
5 |
-
{
|
6 |
-
if (Mage::getModel('lexitygoogle_shopping/core')->has_lexity_user()) {
|
7 |
-
Mage::Log('Found lexity user, redirecting for login.');
|
8 |
-
}
|
9 |
-
else {
|
10 |
-
Mage::Log('No lexity user found, redirecting for account creation.');
|
11 |
-
|
12 |
-
$token = uniqid();
|
13 |
-
Mage::Log("Shared public key is: " . Mage::getModel('lexitygoogle_shopping/core')->shared_key);
|
14 |
-
Mage::Log("Token is: ${token}");
|
15 |
-
Mage::getModel('lexitygoogle_shopping/core')->add_lexity_user($token);
|
16 |
-
//$this->getResponse()->setRedirect("http://lexity.com/?token=${token}");
|
17 |
-
}
|
18 |
-
}
|
19 |
-
}
|
20 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/LexityGoogleShopping/controllers/MarketingController.php
CHANGED
@@ -1,10 +1,57 @@
|
|
1 |
<?php
|
2 |
-
class LexityGoogleShopping_MarketingController extends Mage_Adminhtml_Controller_Action
|
3 |
-
|
4 |
-
public
|
5 |
-
|
6 |
-
|
7 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
}
|
9 |
}
|
10 |
?>
|
1 |
<?php
|
2 |
+
class LexityGoogleShopping_MarketingController extends Mage_Adminhtml_Controller_Action {
|
3 |
+
|
4 |
+
public $embed = false;
|
5 |
+
|
6 |
+
public function goLexityAction() {
|
7 |
+
$core = Mage::getModel('lexitygoogleshopping/core');
|
8 |
+
$action = $core->check_credentials();
|
9 |
+
$this->_forward($action);
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getCredentialsAction() {
|
13 |
+
Mage::log('Lexity: forworded to getCredentialsAction');
|
14 |
+
$this->_title('Confirm Credentials');
|
15 |
+
$this->loadLayout()->_setActiveMenu('Marketing');
|
16 |
+
$block = $this->getLayout()->createBlock('lexitygoogleshopping/credentials_form_edit');
|
17 |
+
$left_block = $this->getLayout()->createBlock('lexitygoogleshopping/credentials_form_edit_tabs');
|
18 |
+
$this->_addContent($block)->_addLeft($left_block);
|
19 |
+
$this->renderLayout();
|
20 |
+
}
|
21 |
+
|
22 |
+
public function newAppAction() {
|
23 |
+
Mage::log('Lexity: submitted to newAppAction');
|
24 |
+
$core = Mage::getModel('lexitygoogleshopping/core');
|
25 |
+
if ($data = $this->getRequest()->getPost()) {
|
26 |
+
$email = $data['email'];
|
27 |
+
$password = $data['password'];
|
28 |
+
$core->create_account($email, $password);
|
29 |
+
} else {
|
30 |
+
$core->create_account();
|
31 |
+
}
|
32 |
+
$this->_forward('goLexity');
|
33 |
+
}
|
34 |
+
|
35 |
+
public function redirectAction() {
|
36 |
+
$core = Mage::getModel('lexitygoogleshopping/core');
|
37 |
+
if ($this->embed) {
|
38 |
+
$target = urlencode('admin/google_shopping?embed=true');
|
39 |
+
} else {
|
40 |
+
$target = null;
|
41 |
+
}
|
42 |
+
$url = $core->get_lexity_login_url($target);
|
43 |
+
if ($this->embed) {
|
44 |
+
Mage::log('Lexity: forwarded to embedAction');
|
45 |
+
Mage::register('embed_url', $url);
|
46 |
+
$this->_title('Lexity Google Shopping');
|
47 |
+
$this->loadLayout()->_setActiveMenu('Marketing');
|
48 |
+
$block = $this->getLayout()->createBlock('lexitygoogleshopping/embed');
|
49 |
+
$this->_addContent($block);
|
50 |
+
$this->renderLayout();
|
51 |
+
} else {
|
52 |
+
Mage::log('Lexity: forwarded to redirectAction');
|
53 |
+
$this->getResponse()->setRedirect($url);
|
54 |
+
}
|
55 |
}
|
56 |
}
|
57 |
?>
|
app/code/local/LexityGoogleShopping/etc/api.xml
CHANGED
@@ -2,21 +2,21 @@
|
|
2 |
<config>
|
3 |
<api>
|
4 |
<resources>
|
5 |
-
<
|
6 |
-
<model>
|
7 |
<title>Lexity Core API</title>
|
8 |
-
<acl>
|
9 |
<methods>
|
10 |
-
<getMisc translate="title" module="
|
11 |
<title>Get header scripts</title>
|
12 |
<method>getMisc</method>
|
13 |
</getMisc>
|
14 |
-
<setMisc translate="title" module="
|
15 |
<title>Set header scripts</title>
|
16 |
<method>setMisc</method>
|
17 |
</setMisc>
|
18 |
</methods>
|
19 |
-
</
|
20 |
</resources>
|
21 |
</api>
|
22 |
</config>
|
2 |
<config>
|
3 |
<api>
|
4 |
<resources>
|
5 |
+
<lexitygoogleshopping_core translate="title" module="lexitygoogleshopping">
|
6 |
+
<model>lexitygoogleshopping/core_api</model>
|
7 |
<title>Lexity Core API</title>
|
8 |
+
<acl>lexitygoogleshopping/core</acl>
|
9 |
<methods>
|
10 |
+
<getMisc translate="title" module="lexitygoogleshopping">
|
11 |
<title>Get header scripts</title>
|
12 |
<method>getMisc</method>
|
13 |
</getMisc>
|
14 |
+
<setMisc translate="title" module="lexitygoogleshopping">
|
15 |
<title>Set header scripts</title>
|
16 |
<method>setMisc</method>
|
17 |
</setMisc>
|
18 |
</methods>
|
19 |
+
</lexitygoogleshopping_core>
|
20 |
</resources>
|
21 |
</api>
|
22 |
</config>
|
app/code/local/LexityGoogleShopping/etc/config.xml
CHANGED
@@ -1,37 +1,52 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
<modules>
|
4 |
-
<
|
5 |
<version>0.1.0</version>
|
6 |
-
</
|
7 |
</modules>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
<global>
|
9 |
<helpers>
|
10 |
-
<
|
11 |
<class>LexityGoogleShopping_Helper</class>
|
12 |
-
</
|
13 |
</helpers>
|
14 |
<models>
|
15 |
-
<
|
16 |
<class>LexityGoogleShopping_Model</class>
|
17 |
-
</
|
18 |
</models>
|
19 |
<blocks>
|
20 |
-
<
|
21 |
<class>LexityGoogleShopping_Block</class>
|
22 |
-
</
|
23 |
</blocks>
|
24 |
</global>
|
25 |
|
26 |
<admin>
|
27 |
<routers>
|
28 |
-
<
|
29 |
<use>admin</use>
|
30 |
<args>
|
31 |
<module>LexityGoogleShopping</module>
|
32 |
-
<frontName>
|
33 |
</args>
|
34 |
-
</
|
35 |
</routers>
|
36 |
</admin>
|
37 |
|
@@ -40,11 +55,11 @@
|
|
40 |
<Lexity translate="title">
|
41 |
<title>Marketing</title>
|
42 |
<children>
|
43 |
-
<
|
44 |
<title>Lexity Google Shopping</title>
|
45 |
-
<action>
|
46 |
<sort_order>0</sort_order>
|
47 |
-
</
|
48 |
</children>
|
49 |
<sort_order>900</sort_order>
|
50 |
</Lexity>
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
<modules>
|
4 |
+
<lexitygoogleshopping>
|
5 |
<version>0.1.0</version>
|
6 |
+
</lexitygoogleshopping>
|
7 |
</modules>
|
8 |
+
<adminhtml>
|
9 |
+
<menu>
|
10 |
+
<Lexity translate="title">
|
11 |
+
<title>Marketing</title>
|
12 |
+
<children>
|
13 |
+
<lexitygoogleshopping translate="title" module="lexitygoogleshopping">
|
14 |
+
<title>Lexity Google Shopping</title>
|
15 |
+
<action>lexitygoogleshopping/marketing/golexity</action>
|
16 |
+
<sort_order>0</sort_order>
|
17 |
+
</lexitygoogleshopping>
|
18 |
+
</children>
|
19 |
+
<sort_order>900</sort_order>
|
20 |
+
</Lexity>
|
21 |
+
</menu>
|
22 |
+
</adminhtml>
|
23 |
<global>
|
24 |
<helpers>
|
25 |
+
<lexitygoogleshopping>
|
26 |
<class>LexityGoogleShopping_Helper</class>
|
27 |
+
</lexitygoogleshopping>
|
28 |
</helpers>
|
29 |
<models>
|
30 |
+
<lexitygoogleshopping>
|
31 |
<class>LexityGoogleShopping_Model</class>
|
32 |
+
</lexitygoogleshopping>
|
33 |
</models>
|
34 |
<blocks>
|
35 |
+
<lexitygoogleshopping>
|
36 |
<class>LexityGoogleShopping_Block</class>
|
37 |
+
</lexitygoogleshopping>
|
38 |
</blocks>
|
39 |
</global>
|
40 |
|
41 |
<admin>
|
42 |
<routers>
|
43 |
+
<lexitygoogleshopping>
|
44 |
<use>admin</use>
|
45 |
<args>
|
46 |
<module>LexityGoogleShopping</module>
|
47 |
+
<frontName>lexitygoogleshopping</frontName>
|
48 |
</args>
|
49 |
+
</lexitygoogleshopping>
|
50 |
</routers>
|
51 |
</admin>
|
52 |
|
55 |
<Lexity translate="title">
|
56 |
<title>Marketing</title>
|
57 |
<children>
|
58 |
+
<lexitygoogleshopping translate="title" module="lexitygoogleshopping">
|
59 |
<title>Lexity Google Shopping</title>
|
60 |
+
<action>lexitygoogleshopping/marketing/golexity</action>
|
61 |
<sort_order>0</sort_order>
|
62 |
+
</lexitygoogleshopping>
|
63 |
</children>
|
64 |
<sort_order>900</sort_order>
|
65 |
</Lexity>
|
package.xml
CHANGED
@@ -1,28 +1,22 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lexity_GoogleShopping</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license>BSD License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>Transition painlessly to new Google Shopping from Google Product Search
|
11 |

|
12 |
-
Google is moving from a free model to a paid model, with its transition from the old Google Product Search to the new Google Shopping. We built Lexity Google Shopping to make your onboarding to the new Google Shopping as easy as possible
|
|
|
13 |

|
14 |
-
|
15 |
-
|
16 |
-
Item out of stock? No problem! We’ll update your listings without your needing to lift a finger. Lexity automatically synchronizes with your store and automatically updates your feeds with current information on your inventory and catalog, including stock, pricing, and product images.
|
17 |
-

|
18 |
-
Fine control over product selection
|
19 |
-

|
20 |
-
We give you fine control over exactly which products you want advertised, so you won’t waste a cent. Focus your campaigns where you want them focused, whether that’s your top selling products, a new line you’re launching, or something else.</description>
|
21 |
-
<notes>Initial Release</notes>
|
22 |
<authors><author><name>Lexity</name><user>lexity</user><email>support@lexity.com</email></author></authors>
|
23 |
-
<date>
|
24 |
-
<time>
|
25 |
-
<contents><target name="magelocal"><dir name="LexityGoogleShopping"><dir name="Helper"><file name="Data.php" hash="9e4c8fe0f1c2c6c58779d6eab5abc155"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="7cb5721dc220cff5c90e7f0012b481f6"/></dir><file name="Core.php" hash="
|
26 |
<compatible/>
|
27 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
28 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Lexity_GoogleShopping</name>
|
4 |
+
<version>1.3.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>BSD License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Transition painlessly to new Google Shopping from Google Product Search
|
|
|
10 |

|
11 |
+
Google is moving from a free model to a paid model, with its transition from the old Google Product Search to the new Google Shopping. We built Lexity Google Shopping to make your onboarding to the new Google Shopping as easy as possible.</summary>
|
12 |
+
<description>Automatically synchronize listings with store inventory
|
13 |

|
14 |
+
Item out of stock? No problem! We’ll update your listings without your needing to lift a finger. Lexity automatically synchronizes with your store and automatically updates your feeds with current information on your inventory and catalog, including stock, pricing, and product images.</description>
|
15 |
+
<notes>Stable</notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<authors><author><name>Lexity</name><user>lexity</user><email>support@lexity.com</email></author></authors>
|
17 |
+
<date>2013-03-05</date>
|
18 |
+
<time>20:51:47</time>
|
19 |
+
<contents><target name="magelocal"><dir name="LexityGoogleShopping"><dir name="Block"><dir name="Credentials"><dir name="Form"><dir name="Edit"><file name="Form.php" hash="1f7d4bdc6be0a59fd4afad6e5ee9038c"/><dir name="Tab"><file name="Form.php" hash="5bcf53277215e2510a1023c32f2ced0c"/></dir><file name="Tabs.php" hash="aad45913633dbf00e332d38a0ea81e58"/></dir><file name="Edit.php" hash="0fbb803e4ba772263f3c75c4de3ded32"/></dir></dir><file name="Embed.php" hash="abac60fc5e4aba01cadf7446d2cd301a"/></dir><dir name="Helper"><file name="Data.php" hash="9e4c8fe0f1c2c6c58779d6eab5abc155"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="7cb5721dc220cff5c90e7f0012b481f6"/></dir><file name="Core.php" hash="7658d32905a179a866b57e034f22383c"/><dir name="Order"><file name="Api.php" hash="1cc4747b57196c793e73a3e130e0c9b2"/></dir></dir><dir name="controllers"><file name="MarketingController.php" hash="a03f5ed92c2d0ac65ade8d56675f3682"/></dir><dir name="etc"><file name="api.xml" hash="125d3011e9255bb0b3b915645f14cd89"/><file name="config.xml" hash="50ef4e69ccd4f10d20a9fcebcf7a7a54"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="LexityGoogleShopping.xml" hash="9deb73045bba529c3ebbd8374eb14d3c"/></dir></target></contents>
|
20 |
<compatible/>
|
21 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
22 |
</package>
|