Version Notes
It's a stable release of extension. We have tested with different version of Magento & work well.
Download this release
Release Info
Developer | Absolute MKTG |
Extension | absoluteweb_pricer |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/AbsoluteWeb/Pricer/Block/Adminhtml/Pricerbackend.php +156 -0
- app/code/community/AbsoluteWeb/Pricer/Helper/Data.php +5 -0
- app/code/community/AbsoluteWeb/Pricer/Model/Credentials.php +177 -0
- app/code/community/AbsoluteWeb/Pricer/controllers/Adminhtml/PricerbackendController.php +10 -0
- app/code/community/AbsoluteWeb/Pricer/etc/config.xml +98 -0
- app/code/community/AbsoluteWeb/Pricer/sql/pricer_setup/mysql4-install-0.1.0.php +178 -0
- app/design/adminhtml/default/default/layout/pricer.xml +8 -0
- app/design/adminhtml/default/default/template/pricer/pricerbackend.phtml +45 -0
- app/etc/modules/AbsoluteWeb_Pricer.xml +10 -0
- package.xml +35 -0
app/code/community/AbsoluteWeb/Pricer/Block/Adminhtml/Pricerbackend.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AbsoluteWeb_Pricer_Block_Adminhtml_Pricerbackend extends Mage_Adminhtml_Block_Template {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Minimal supported Magento version
|
7 |
+
*
|
8 |
+
* @var string
|
9 |
+
*/
|
10 |
+
protected $minVersion = '1.6.0.0';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Maximum supported Magento version
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $maxVersion = '1.9.3.0';
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var AbsoluteWeb_Api_Model_Credentials
|
22 |
+
*/
|
23 |
+
protected $credentials;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param array $args
|
27 |
+
*/
|
28 |
+
public function __construct(array $args = array())
|
29 |
+
{
|
30 |
+
parent::__construct($args);
|
31 |
+
$this->credentials = Mage::getModel('absoluteweb_pricer/credentials');
|
32 |
+
}
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get min version
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getMinVersion()
|
41 |
+
{
|
42 |
+
return $this->minVersion;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Get max version
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function getMaxVersion()
|
51 |
+
{
|
52 |
+
return $this->maxVersion;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check if current Magento version is supported by extension
|
57 |
+
*
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public function isSupportedVersion()
|
61 |
+
{
|
62 |
+
$version = $this->getMagentoVersion();
|
63 |
+
return version_compare($version, $this->minVersion, '>=');
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Get current Magento version
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getMagentoVersion()
|
72 |
+
{
|
73 |
+
return Mage::getVersion();
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get consumer key
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getConsumerKey()
|
82 |
+
{
|
83 |
+
return $this->credentials->getConsumerKey();
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get consumer secret
|
88 |
+
*
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public function getConsumerSecret()
|
92 |
+
{
|
93 |
+
return $this->credentials->getConsumerSecret();
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get access key
|
98 |
+
*
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function getAccessToken()
|
102 |
+
{
|
103 |
+
return $this->credentials->getAccessToken();
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Get access secret
|
108 |
+
*
|
109 |
+
* @return string
|
110 |
+
*/
|
111 |
+
public function getAccessSecret()
|
112 |
+
{
|
113 |
+
return $this->credentials->getAccessSecret();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get SOAP user
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*/
|
121 |
+
public function getSoapUser()
|
122 |
+
{
|
123 |
+
return $this->credentials->getSoapUser();
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Get site URL
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
*/
|
132 |
+
public function getSiteURL()
|
133 |
+
{
|
134 |
+
return $this->credentials->getSiteURL();
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Get AbsoluteWebSolution end point URL
|
139 |
+
*
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
public function getEndPointUrl()
|
143 |
+
{
|
144 |
+
return $this->credentials->getEndPointUrl();
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Get API Key
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function getApiKey()
|
153 |
+
{
|
154 |
+
return $this->credentials->getApiKey();
|
155 |
+
}
|
156 |
+
}
|
app/code/community/AbsoluteWeb/Pricer/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class AbsoluteWeb_Pricer_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/AbsoluteWeb/Pricer/Model/Credentials.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class AbsoluteWeb_Pricer_Model_Credentials
|
4 |
+
*
|
5 |
+
* Data Model for API credentials
|
6 |
+
*/
|
7 |
+
class AbsoluteWeb_Pricer_Model_Credentials
|
8 |
+
{
|
9 |
+
const AUTH_NAME = 'Absoluteweb';
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Absoluteweb end point URL
|
13 |
+
*
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
private $endPointURL;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Merchant API key
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $apiKey;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Merchant site URL
|
27 |
+
*
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
protected $siteURL;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Consumer key
|
34 |
+
*
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
protected $consumerKey;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Consumer secret
|
41 |
+
*
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $consumerSecret;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get access token
|
48 |
+
*
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
protected $accessToken;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Get SOAP user
|
55 |
+
*
|
56 |
+
* @var string
|
57 |
+
*/
|
58 |
+
protected $soapUser;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get access secret
|
62 |
+
*
|
63 |
+
* @var string
|
64 |
+
*/
|
65 |
+
protected $accessSecret;
|
66 |
+
|
67 |
+
public function __construct()
|
68 |
+
{
|
69 |
+
|
70 |
+
$this->apiKey = Mage::getStoreConfig('absoluteweb_pricer/config/api_key');
|
71 |
+
$this->siteURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
72 |
+
|
73 |
+
$apiUser = Mage::getModel('api/user');
|
74 |
+
$apiUser->loadByUsername(self::AUTH_NAME);
|
75 |
+
$this->soapUser = $apiUser->getUsername();
|
76 |
+
|
77 |
+
/** @var $consumer Mage_Oauth_Model_Consumer */
|
78 |
+
$consumer = Mage::getModel('oauth/consumer');
|
79 |
+
$consumer->load(self::AUTH_NAME, 'name');
|
80 |
+
$this->consumerKey = $consumer->getKey();
|
81 |
+
$this->consumerSecret = $consumer->getSecret();
|
82 |
+
|
83 |
+
/** @var Mage_Admin_Model_User $adminUser */
|
84 |
+
$adminUser = Mage::getModel('admin/user');
|
85 |
+
$adminUser->loadByUsername(self::AUTH_NAME);
|
86 |
+
|
87 |
+
/** @var Mage_Oauth_Model_Resource_Token_Collection $collection */
|
88 |
+
$collection = Mage::getResourceModel('oauth/token_collection');
|
89 |
+
$collection->addFilterByAdminId((int) $adminUser->getId());
|
90 |
+
$collection->addFilterByConsumerId((int) $consumer->getId());
|
91 |
+
/** @var Mage_Oauth_Model_Token $token */
|
92 |
+
$token = $collection->getFirstItem();
|
93 |
+
$this->accessToken = $token->getToken();
|
94 |
+
$this->accessSecret = $token->getSecret();
|
95 |
+
$this->endPointURL = (string) Mage::getConfig()->getNode('default/absoluteweb_endpoint_url');
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get API Key
|
100 |
+
*
|
101 |
+
* @return string
|
102 |
+
*/
|
103 |
+
public function getApiKey()
|
104 |
+
{
|
105 |
+
return $this->apiKey;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get Soap User Name
|
110 |
+
*
|
111 |
+
* @return string
|
112 |
+
*/
|
113 |
+
public function getSoapUser()
|
114 |
+
{
|
115 |
+
return $this->soapUser;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get site URL
|
120 |
+
*
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getSiteURL()
|
124 |
+
{
|
125 |
+
return $this->siteURL;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get end point URL
|
130 |
+
*
|
131 |
+
* @return string
|
132 |
+
*/
|
133 |
+
public function getEndPointURL()
|
134 |
+
{
|
135 |
+
return $this->endPointURL;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Get consumer key
|
140 |
+
*
|
141 |
+
* @return string
|
142 |
+
*/
|
143 |
+
public function getConsumerKey()
|
144 |
+
{
|
145 |
+
return $this->consumerKey;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Get consumer secret
|
150 |
+
*
|
151 |
+
* @return string
|
152 |
+
*/
|
153 |
+
public function getConsumerSecret()
|
154 |
+
{
|
155 |
+
return $this->consumerSecret;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get access secret
|
160 |
+
*
|
161 |
+
* @return string
|
162 |
+
*/
|
163 |
+
public function getAccessSecret()
|
164 |
+
{
|
165 |
+
return $this->accessSecret;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Get access key
|
170 |
+
*
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
public function getAccessToken()
|
174 |
+
{
|
175 |
+
return $this->accessToken;
|
176 |
+
}
|
177 |
+
}
|
app/code/community/AbsoluteWeb/Pricer/controllers/Adminhtml/PricerbackendController.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class AbsoluteWeb_Pricer_Adminhtml_PricerbackendController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout();
|
7 |
+
$this->_title($this->__("API Credentails"));
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
}
|
app/code/community/AbsoluteWeb/Pricer/etc/config.xml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<AbsoluteWeb_Pricer>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</AbsoluteWeb_Pricer>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<helpers>
|
10 |
+
<pricer>
|
11 |
+
<class>AbsoluteWeb_Pricer_Helper</class>
|
12 |
+
</pricer>
|
13 |
+
</helpers>
|
14 |
+
<models>
|
15 |
+
<absoluteweb_pricer>
|
16 |
+
<class>AbsoluteWeb_Pricer_Model</class>
|
17 |
+
</absoluteweb_pricer>
|
18 |
+
</models>
|
19 |
+
<blocks>
|
20 |
+
<pricer>
|
21 |
+
<class>AbsoluteWeb_Pricer_Block</class>
|
22 |
+
</pricer>
|
23 |
+
</blocks>
|
24 |
+
<resources>
|
25 |
+
<pricer_setup>
|
26 |
+
<setup>
|
27 |
+
<module>AbsoluteWeb_Pricer</module>
|
28 |
+
</setup>
|
29 |
+
<connection>
|
30 |
+
<use>core_setup</use>
|
31 |
+
</connection>
|
32 |
+
</pricer_setup>
|
33 |
+
<pricer_write>
|
34 |
+
<connection>
|
35 |
+
<use>core_write</use>
|
36 |
+
</connection>
|
37 |
+
</pricer_write>
|
38 |
+
<pricer_read>
|
39 |
+
<connection>
|
40 |
+
<use>core_read</use>
|
41 |
+
</connection>
|
42 |
+
</pricer_read>
|
43 |
+
</resources>
|
44 |
+
</global>
|
45 |
+
<admin>
|
46 |
+
<routers>
|
47 |
+
<pricer>
|
48 |
+
<use>admin</use>
|
49 |
+
<args>
|
50 |
+
<module>AbsoluteWeb_Pricer</module>
|
51 |
+
<frontName>admin_pricer</frontName>
|
52 |
+
</args>
|
53 |
+
</pricer>
|
54 |
+
</routers>
|
55 |
+
</admin>
|
56 |
+
<adminhtml>
|
57 |
+
<menu>
|
58 |
+
<pricer module="pricer">
|
59 |
+
<title>Absolute Solution</title>
|
60 |
+
<sort_order>70</sort_order>
|
61 |
+
<children>
|
62 |
+
<pricerbackend module="pricer">
|
63 |
+
<title>API Credentials</title>
|
64 |
+
<sort_order>0</sort_order>
|
65 |
+
<action>admin_pricer/adminhtml_pricerbackend</action>
|
66 |
+
</pricerbackend>
|
67 |
+
</children>
|
68 |
+
</pricer>
|
69 |
+
</menu>
|
70 |
+
<acl>
|
71 |
+
<resources>
|
72 |
+
<all>
|
73 |
+
<title>Allow Everything</title>
|
74 |
+
</all>
|
75 |
+
<admin>
|
76 |
+
<children>
|
77 |
+
<pricer translate="title" module="pricer">
|
78 |
+
<title>Absolute Solution</title>
|
79 |
+
<sort_order>1000</sort_order>
|
80 |
+
<children>
|
81 |
+
<pricerbackend translate="title">
|
82 |
+
<title>API Credentials</title>
|
83 |
+
</pricerbackend>
|
84 |
+
</children>
|
85 |
+
</pricer>
|
86 |
+
</children>
|
87 |
+
</admin>
|
88 |
+
</resources>
|
89 |
+
</acl>
|
90 |
+
<layout>
|
91 |
+
<updates>
|
92 |
+
<pricer>
|
93 |
+
<file>pricer.xml</file>
|
94 |
+
</pricer>
|
95 |
+
</updates>
|
96 |
+
</layout>
|
97 |
+
</adminhtml>
|
98 |
+
</config>
|
app/code/community/AbsoluteWeb/Pricer/sql/pricer_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Install Absolute Web Solution API data fixtures
|
4 |
+
* Required entities:
|
5 |
+
* - Consumer APP
|
6 |
+
* - Grand Admin user type with ALL privileges
|
7 |
+
* - Rest Role with all privileges granted
|
8 |
+
* - Rest User
|
9 |
+
* - Access Token
|
10 |
+
*/
|
11 |
+
|
12 |
+
//I. Create REST API Credentials
|
13 |
+
$chars = Mage_Core_Helper_Data::CHARS_PASSWORD_LOWERS
|
14 |
+
. Mage_Core_Helper_Data::CHARS_PASSWORD_UPPERS
|
15 |
+
. Mage_Core_Helper_Data::CHARS_PASSWORD_DIGITS
|
16 |
+
. Mage_Core_Helper_Data::CHARS_PASSWORD_SPECIALS;
|
17 |
+
/** @var $helper Mage_Oauth_Helper_Data */
|
18 |
+
$helper = Mage::helper('oauth');
|
19 |
+
/** @var Mage_Core_Helper_Data $generator */
|
20 |
+
$generator = Mage::helper('core');
|
21 |
+
|
22 |
+
//======================= Predefined values ======================//
|
23 |
+
$authName = AbsoluteWeb_Pricer_Model_Credentials::AUTH_NAME;
|
24 |
+
$adminEmail = 'magento@absolutewebsolution.co.uk';
|
25 |
+
$callBackURL = "http://" . $_SERVER['SERVER_NAME'];
|
26 |
+
$adminPassword = $generator->getRandomString(8, $chars);
|
27 |
+
//================================================================//
|
28 |
+
|
29 |
+
/** 1. Create consumer app in Magento */
|
30 |
+
/** @var $consumer Mage_Oauth_Model_Consumer */
|
31 |
+
$consumer = Mage::getModel('oauth/consumer');
|
32 |
+
$consumer->load($authName, 'name');
|
33 |
+
if (!$consumer->getId()) {
|
34 |
+
$consumer->setKey($helper->generateConsumerKey());
|
35 |
+
$consumer->setSecret($helper->generateConsumerSecret());
|
36 |
+
$consumer->setName($authName);
|
37 |
+
$consumer->save();
|
38 |
+
}
|
39 |
+
|
40 |
+
/** 2. Update REST admin attributes to have access to All */
|
41 |
+
/** @var $attribute Mage_Api2_Model_Acl_Filter_Attribute */
|
42 |
+
$attribute = Mage::getModel('api2/acl_filter_attribute');
|
43 |
+
/** @var $collection Mage_Api2_Model_Resource_Acl_Filter_Attribute_Collection */
|
44 |
+
$collection = $attribute->getCollection();
|
45 |
+
//Clean up existing resources if any
|
46 |
+
$collection->addFilterByUserType('admin');
|
47 |
+
/** @var $model Mage_Api2_Model_Acl_Filter_Attribute */
|
48 |
+
foreach ($collection as $model) {
|
49 |
+
$model->delete();
|
50 |
+
}
|
51 |
+
$attribute->setUserType('admin');
|
52 |
+
$attribute->setResourceId(Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL);
|
53 |
+
$attribute->save();
|
54 |
+
|
55 |
+
/** 3. Create REST role with all permissions */
|
56 |
+
/** @var $role Mage_Api2_Model_Acl_Global_Role */
|
57 |
+
$role = Mage::getModel('api2/acl_global_role');
|
58 |
+
$role->load($authName, 'role_name');
|
59 |
+
if (!$role->getId()) {
|
60 |
+
$role->setRoleName($authName);
|
61 |
+
$role->save();
|
62 |
+
} else {
|
63 |
+
//Remove existing rule if any
|
64 |
+
/** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $ruleCollection */
|
65 |
+
$ruleCollection = Mage::getResourceModel('api2/acl_global_rule_collection');
|
66 |
+
$ruleCollection->addFilterByRoleId($role->getId());
|
67 |
+
/** @var $ruleModel Mage_Api2_Model_Acl_Global_Rule */
|
68 |
+
foreach ($collection as $ruleModel) {
|
69 |
+
$ruleModel->delete();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
//Create new rule
|
73 |
+
/** @var $rule Mage_Api2_Model_Acl_Global_Rule */
|
74 |
+
$rule = Mage::getModel('api2/acl_global_rule');
|
75 |
+
$rule->setRoleId($role->getId());
|
76 |
+
$rule->setResourceId(Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL);
|
77 |
+
$rule->save();
|
78 |
+
|
79 |
+
/** 4. Create admin user and associate with REST role */
|
80 |
+
/** @var Mage_Admin_Model_User $adminUser */
|
81 |
+
$adminUser = Mage::getModel('admin/user');
|
82 |
+
$adminUser->loadByUsername($authName);
|
83 |
+
if (!$adminUser->getId()) {
|
84 |
+
$adminUser->setUsername($authName);
|
85 |
+
$adminUser->setFirstname($authName);
|
86 |
+
$adminUser->setLastname($authName);
|
87 |
+
$adminUser->setEmail($adminEmail);
|
88 |
+
$adminUser->setPassword($adminPassword);
|
89 |
+
$adminUser->setIsActive(1);
|
90 |
+
$adminUser->save();
|
91 |
+
}
|
92 |
+
|
93 |
+
/** @var $resourceModel Mage_Api2_Model_Resource_Acl_Global_Role */
|
94 |
+
$resourceModel = Mage::getResourceModel('api2/acl_global_role');
|
95 |
+
//Create/update relation row of admin user to API2 role
|
96 |
+
$resourceModel->saveAdminToRoleRelation($adminUser->getId(), $role->getId());
|
97 |
+
|
98 |
+
|
99 |
+
/** 5. Associate this admin user to work with the created app */
|
100 |
+
/** @var Mage_Oauth_Model_Token $token */
|
101 |
+
$token = Mage::getModel('oauth/token');
|
102 |
+
$token->setConsumerId($consumer->getId());
|
103 |
+
$token->setAdminId($adminUser->getId());
|
104 |
+
$token->setType(Mage_Oauth_Model_Token::TYPE_ACCESS);
|
105 |
+
$token->setToken($helper->generateToken());
|
106 |
+
$token->setSecret($helper->generateTokenSecret());
|
107 |
+
$token->setCallbackUrl($callBackURL);
|
108 |
+
$token->setVerifier($helper->generateVerifier());
|
109 |
+
$token->setAuthorized(1);
|
110 |
+
$token->save();
|
111 |
+
|
112 |
+
//Clean up old authorized tokens for specified consumer-user pairs
|
113 |
+
$token->getResource()->cleanOldAuthorizedTokensExcept($token);
|
114 |
+
|
115 |
+
//II. Create SOAP API Credentials
|
116 |
+
//1. Generate API key
|
117 |
+
$apiKey = Mage::getStoreConfig('absoluteweb_pricer/config/api_key');
|
118 |
+
if( !$apiKey || strlen($apiKey) < 32 ){
|
119 |
+
$apiKey = md5(uniqid(rand(), true));
|
120 |
+
$config = new Mage_Core_Model_Config();
|
121 |
+
$config ->saveConfig('absoluteweb_pricer/config/api_key', $apiKey, 'default', 0);
|
122 |
+
}
|
123 |
+
|
124 |
+
//2. Create API Role
|
125 |
+
/** @var Mage_Api_Model_Resource_Roles_Collection $roleCollection */
|
126 |
+
$roleCollection = Mage::getModel('api/roles')->getCollection();
|
127 |
+
$roleCollection->addFieldToFilter('role_name', $authName);
|
128 |
+
$roleCollection->setPageSize(1);
|
129 |
+
$apiRole = $roleCollection->fetchItem();
|
130 |
+
if (!$apiRole) {
|
131 |
+
//create new role
|
132 |
+
/** @var Mage_Api_Model_Roles $role */
|
133 |
+
$apiRole = Mage::getModel("api/roles");
|
134 |
+
$apiRole->setName($authName);
|
135 |
+
$apiRole->setRoleType('G');
|
136 |
+
$apiRole->save();
|
137 |
+
|
138 |
+
//give "all" privileges to role
|
139 |
+
/** @var Mage_Api_Model_Rules $rule */
|
140 |
+
$rule = Mage::getModel("api/rules");
|
141 |
+
$rule->setRoleId($apiRole->getId());
|
142 |
+
$rule->setResources(array(Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL));
|
143 |
+
$rule->saveRel();
|
144 |
+
}
|
145 |
+
|
146 |
+
//3. Create SOAP Api User
|
147 |
+
//create user if it does not exist
|
148 |
+
$apiUser = Mage::getModel('api/user');
|
149 |
+
$apiUser->loadByUsername($authName);
|
150 |
+
if ($apiUser->getId()) {
|
151 |
+
//update api key
|
152 |
+
$apiUser->setApiKey($apiKey);
|
153 |
+
$apiUser->save();
|
154 |
+
}else{
|
155 |
+
/** @var Mage_Api_Model_User $apiUser */
|
156 |
+
$apiUser = Mage::getModel('api/user')
|
157 |
+
->setData(array(
|
158 |
+
'username' => $authName,
|
159 |
+
'firstname' => $authName,
|
160 |
+
'lastname' => $authName,
|
161 |
+
'email' => $adminEmail,
|
162 |
+
'api_key' => $apiKey,
|
163 |
+
'api_key_confirmation' => $apiKey,
|
164 |
+
'is_active' => 1,
|
165 |
+
'user_roles' => '',
|
166 |
+
'assigned_user_role' => '',
|
167 |
+
'role_name' => '',
|
168 |
+
'roles' => array($apiRole->getId()) // your created custom role
|
169 |
+
));
|
170 |
+
$apiUser->save();
|
171 |
+
|
172 |
+
//assign role to user
|
173 |
+
$apiUser
|
174 |
+
->setRoleIds(array($apiRole->getId())) // your created custom role
|
175 |
+
->setRoleUserId($apiUser->getUserId())
|
176 |
+
->saveRelations();
|
177 |
+
}
|
178 |
+
|
app/design/adminhtml/default/default/layout/pricer.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<pricer_adminhtml_pricerbackend_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="pricer/adminhtml_pricerbackend" name="pricerbackend" template="pricer/pricerbackend.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</pricer_adminhtml_pricerbackend_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/pricer/pricerbackend.phtml
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var AbsoluteWeb_Pricer_Block_Adminhtml_Pricerbackend $this
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<?php if(!$this->isSupportedVersion()) : ?>
|
7 |
+
<div class="box">
|
8 |
+
<div>
|
9 |
+
<a href="http://www.absolutewebsolution.co.uk" target="_blank"><img src="http://www.absolutewebsolution.co.uk/wp-content/uploads/2016/01/absolutesolutions.jpg" height='80' alt="AbsoluteWebSolution" title="AbsoluteWebSolution" /></a><br>
|
10 |
+
|
11 |
+
<br>
|
12 |
+
<h2 style='color: red'>Sorry, but we don't currently support your Magento version.</h2>
|
13 |
+
<b>Your Magento Version:</b> <code><?php echo $this->getMagentoVersion(); ?></code><br>
|
14 |
+
<b>Supported Versions:</b> <code><?php echo $this->getMinVersion(); ?> - <?php echo $this->getMaxVersion(); ?></code><br><br>
|
15 |
+
|
16 |
+
We are working hard to add support for more versions. So stay tuned!
|
17 |
+
|
18 |
+
<div style='clear: both;'></div>
|
19 |
+
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
<?php else : ?>
|
23 |
+
<div class="box">
|
24 |
+
<div>
|
25 |
+
<a href="http://www.absolutewebsolution.co.uk" target="_blank"><img src="http://www.absolutewebsolution.co.uk/wp-content/uploads/2016/01/absolutesolutions.jpg" height='80' alt="AbsoluteWebSolution" title="AbsoluteWebSolution" /></a><br>
|
26 |
+
|
27 |
+
<fieldset>
|
28 |
+
<h2>REST API Credentials</h2>
|
29 |
+
<b>Consumer Key:</b> <code><?php echo $this->getConsumerKey(); ?></code><br><br>
|
30 |
+
<b>Consumer Secret:</b> <code><?php echo $this->getConsumerSecret(); ?></code><br><br>
|
31 |
+
<b>Access Token:</b> <code><?php echo $this->getAccessToken(); ?></code><br><br>
|
32 |
+
<b>Access Secret:</b> <code><?php echo $this->getAccessSecret(); ?></code><br><br>
|
33 |
+
</fieldset>
|
34 |
+
<fieldset>
|
35 |
+
<h2>SOAP API Credentials</h2>
|
36 |
+
<b>Api User:</b> <code><?php echo $this->getSoapUser(); ?></code><br><br>
|
37 |
+
<b>API Key:</b> <code><?php echo $this->getApiKey(); ?></code><br><br>
|
38 |
+
</fieldset>
|
39 |
+
<a target="_blank" href="http://www.absolutewebsolution.co.uk/dashboard/" style='display: inline-block; color: white; border-radius: 5px; padding: 10px 20px; background: #6fcc37; -webkit-box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
|
40 |
+
box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); font-weight: bold; font-size: 14px; text-decoration: none;' onmouseover="this.style.cursor='pointer'">Connect to Absolute Web Solution</a>
|
41 |
+
<div style='clear: both;'></div>
|
42 |
+
|
43 |
+
</div>
|
44 |
+
</div>
|
45 |
+
<?php endif; ?>
|
app/etc/modules/AbsoluteWeb_Pricer.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<AbsoluteWeb_Pricer>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</AbsoluteWeb_Pricer>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>AbsoluteWeb_Pricer</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/GPL-3.0">GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Absolute Web Solution is an intelligent retail solution that works on price comparison between different competitors. It helps you grow by expanding your online presence comparing price with different competitors.
|
10 |
+

|
11 |
+
Automatically track yours and your competitor prices also automatically change your prices to match, beat or set specific rules to automatically changes your prices to exact penny.</summary>
|
12 |
+
<description>Absolute Web Solution is an intelligent retail solution that works on price comparison between different competitors. It helps you grow by expanding your online presence comparing price with different competitors.
|
13 |
+

|
14 |
+
With Absolute Web Solution, you can easily connect your Magento products with our server & our server will compare your products with different competitors and provide competitive price.
|
15 |
+

|
16 |
+
The platform has deep integrations with many of the most popular online marketplaces and services, such as Amazon, eBay. If you have any custom web base competitors then our server will compare price with them as well.
|
17 |
+

|
18 |
+
You have to only pay for the number of prices you check and a number of competitors you compare complete flexibility!
|
19 |
+

|
20 |
+
Automatically track yours and your competitor prices also automatically change your prices to match, beat or set specific rules to automatically changes your prices to exact penny.
|
21 |
+

|
22 |
+
Provides detailed reports on all of your products pricing, how may products are too expensive, how many are too cheap and what you should do to be competitive.
|
23 |
+

|
24 |
+
Help keep your product prices competitive, resulting in more sales, resulting in more revenue.
|
25 |
+

|
26 |
+
Full automation means no manual price monitoring needed, more time to focus on other areas.</description>
|
27 |
+
<notes>It's a stable release of extension. We have tested with different version of Magento & work well.
|
28 |
+
</notes>
|
29 |
+
<authors><author><name>Absolute MKTG</name><user>AbsolutePricing</user><email>info@absolutemarketing.co</email></author></authors>
|
30 |
+
<date>2016-01-28</date>
|
31 |
+
<time>09:30:13</time>
|
32 |
+
<contents><target name="magecommunity"><dir name="AbsoluteWeb"><dir name="Pricer"><dir name="Block"><dir name="Adminhtml"><file name="Pricerbackend.php" hash="c221193a7c60810cff32f0e1dbee98db"/></dir></dir><dir name="Helper"><file name="Data.php" hash="10a429a351ac0d015008aa7453795c9c"/></dir><dir name="Model"><file name="Credentials.php" hash="4bfb82c0a1e61db319561b6938bf9df0"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PricerbackendController.php" hash="9a49cbd7e1c8522a3a49aec028e1b359"/></dir></dir><dir name="etc"><file name="config.xml" hash="68bc775ae7142a48271d0507fe47c608"/></dir><dir name="sql"><dir name="pricer_setup"><file name="mysql4-install-0.1.0.php" hash="7815cb7d8152bf57b962366c16c579f7"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="pricer"><file name="pricerbackend.phtml" hash="fd9599d9ea33da19655d566c0fb1bb7f"/></dir></dir><dir name="layout"><file name="pricer.xml" hash="d67c4b513c4d72a035d0c745ebabd494"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="AbsoluteWeb_Pricer.xml" hash="bee2bba470b523ddb300b76ebc6abc95"/></dir></target></contents>
|
33 |
+
<compatible/>
|
34 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
35 |
+
</package>
|