Version Notes
Initial launch 1.0.0, stable
Download this release
Release Info
Developer | shopry |
Extension | Stamped_Reviews |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Stamped/Core/ApiClient.php +202 -0
- app/code/community/Stamped/Core/Block/AdminHtml/System/Config/Form/Button.php +24 -0
- app/code/community/Stamped/Core/Block/Stamped.php +83 -0
- app/code/community/Stamped/Core/Helper/Data.php +105 -0
- app/code/community/Stamped/Core/Model/Mysql4/Richsnippet.php +8 -0
- app/code/community/Stamped/Core/Model/Mysql4/Richsnippet/Collection.php +8 -0
- app/code/community/Stamped/Core/Model/Order/Observer.php +71 -0
- app/code/community/Stamped/Core/Model/Resource/Mysql4/setup.php +5 -0
- app/code/community/Stamped/Core/controllers/Adminhtml/StampedController.php +123 -0
- app/code/community/Stamped/Core/etc/adminhtml.xml +26 -0
- app/code/community/Stamped/Core/etc/config.xml +122 -0
- app/code/community/Stamped/Core/etc/system.xml +146 -0
- app/design/adminhtml/default/default/template/stamped/system/config/button.phtml +29 -0
- app/design/frontend/base/default/layout/stamped.xml +31 -0
- app/design/frontend/base/default/template/stamped/badge.phtml +1 -0
- app/design/frontend/base/default/template/stamped/javascript.phtml +8 -0
- app/design/frontend/base/default/template/stamped/widget.phtml +9 -0
- app/design/frontend/base/default/template/stamped/widget2.phtml +7 -0
- app/etc/modules/Stamped_Stamped.xml +10 -0
- package.xml +21 -0
app/code/community/Stamped/Core/ApiClient.php
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Stamped_Core_ApiClient
|
4 |
+
{
|
5 |
+
const STAMPED_API_KEY_CONFIGURATION = 'stamped/stamped_settings_group/stamped_apikey';
|
6 |
+
const STAMPED_API_SECRET_CONFIGURATION = 'stamped/stamped_settings_group/stamped_apisecret';
|
7 |
+
const STAMPED_STORE_URL_CONFIGURATION = 'stamped/stamped_settings_group/stamped_storeurl';
|
8 |
+
|
9 |
+
const STAMPED_SECURED_API_URL_DEVELOPMENT = "http://requestb.in/102buqg1";
|
10 |
+
const STAMPED_UNSECURED_API_URL_DEVELOPMENT = "http://requestb.in/102buqg1";
|
11 |
+
|
12 |
+
const STAMPED_SECURED_API_URL = "https://%s:%s@stamped.io/api/%s";
|
13 |
+
|
14 |
+
public static function isConfigured($store)
|
15 |
+
{
|
16 |
+
//check if both app_key and secret exist
|
17 |
+
if((self::getApiKey($store) == null) or (self::getApiSecret($store) == null))
|
18 |
+
{
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
|
22 |
+
return true;
|
23 |
+
}
|
24 |
+
|
25 |
+
public static function getOrderProductsData($order)
|
26 |
+
{
|
27 |
+
Mage::app()->setCurrentStore($order->getStoreId());
|
28 |
+
|
29 |
+
$products = $order->getAllVisibleItems(); //filter out simple products
|
30 |
+
$products_arr = array();
|
31 |
+
|
32 |
+
foreach ($products as $product) {
|
33 |
+
//use configurable product instead of simple if still needed
|
34 |
+
$full_product = Mage::getModel('catalog/product')->load($product->getProductId());
|
35 |
+
|
36 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
37 |
+
$parentIds= $configurable_product_model->getParentIdsByChild($full_product->getId());
|
38 |
+
if (count($parentIds) > 0) {
|
39 |
+
$full_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
40 |
+
}
|
41 |
+
|
42 |
+
$product_data = array();
|
43 |
+
|
44 |
+
$product_data['productId'] = $full_product->getId();
|
45 |
+
$product_data['productDescription'] = Mage::helper('core')->htmlEscape(strip_tags($full_product->getDescription()));
|
46 |
+
$product_data['productTitle'] = $full_product->getName();
|
47 |
+
try
|
48 |
+
{
|
49 |
+
$product_data['productUrl'] = $full_product->getUrlInStore(array('_store' => $order->getStoreId()));
|
50 |
+
$product_data['productImageUrl'] = $full_product->getImageUrl();
|
51 |
+
} catch(Exception $e) {}
|
52 |
+
|
53 |
+
$product_data['productPrice'] = $product->getPrice();
|
54 |
+
|
55 |
+
$products_arr[] = $product_data;
|
56 |
+
}
|
57 |
+
|
58 |
+
return $products_arr;
|
59 |
+
}
|
60 |
+
|
61 |
+
public static function API_POST($path, $data, $store, $timeout=30) {
|
62 |
+
|
63 |
+
try {
|
64 |
+
$encodedData = json_encode($data);
|
65 |
+
$ch = curl_init(self::getApiUrlAuth($store).$path);
|
66 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
67 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $encodedData);
|
68 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
69 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
70 |
+
'Content-Type: application/json',
|
71 |
+
'Content-Length: ' . strlen($encodedData),
|
72 |
+
));
|
73 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
74 |
+
|
75 |
+
$result = curl_exec($ch);
|
76 |
+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
77 |
+
|
78 |
+
if (in_array($httpCode, array(200, 201))) {
|
79 |
+
return json_decode($result, true);
|
80 |
+
}
|
81 |
+
if (400 === $httpCode) {
|
82 |
+
$result = json_decode($result, true);
|
83 |
+
}
|
84 |
+
if (401 === $httpCode) {
|
85 |
+
throw new Exception('API Key or API Secret is invalid, please do check. If you need any assistance, please contact us.');
|
86 |
+
}
|
87 |
+
|
88 |
+
} catch (Exception $e) {
|
89 |
+
Mage::log('Failed execute API Post. Error: '.$e);
|
90 |
+
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
public static function API_GET2($path, $store, $timeout=30) {
|
96 |
+
try {
|
97 |
+
$ch = curl_init($path);
|
98 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
|
99 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
100 |
+
|
101 |
+
$result = curl_exec($ch);
|
102 |
+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
103 |
+
|
104 |
+
if (in_array($httpCode, array(200, 201))) {
|
105 |
+
return json_decode($result, true);
|
106 |
+
}
|
107 |
+
if (400 === $httpCode) {
|
108 |
+
$result = json_decode($result, true);
|
109 |
+
}
|
110 |
+
if (401 === $httpCode) {
|
111 |
+
throw new Exception('API Key or API Secret is invalid, please do check. If you need any assistance, please contact us.');
|
112 |
+
}
|
113 |
+
|
114 |
+
} catch (Exception $e) {
|
115 |
+
Mage::log('Failed execute API Get. Error: '.$e);
|
116 |
+
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
public static function API_GET($path, $store, $timeout=30)
|
122 |
+
{
|
123 |
+
try {
|
124 |
+
// Initiate curl
|
125 |
+
$ch = curl_init();
|
126 |
+
// Disable SSL verification
|
127 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
128 |
+
// Will return the response, if false it print the response
|
129 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
130 |
+
// Set the url
|
131 |
+
curl_setopt($ch, CURLOPT_URL,self::getApiUrlAuth($store).$path);
|
132 |
+
// Execute
|
133 |
+
$result=curl_exec($ch);
|
134 |
+
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
135 |
+
// Closing
|
136 |
+
curl_close($ch);
|
137 |
+
|
138 |
+
//$encodedData = json_encode($result);
|
139 |
+
//return $encodedData;
|
140 |
+
|
141 |
+
if (in_array($httpCode, array(200, 201))) {
|
142 |
+
return json_decode($result, true);
|
143 |
+
}
|
144 |
+
if (400 === $httpCode) {
|
145 |
+
$result = json_decode($result, true);
|
146 |
+
}
|
147 |
+
if (401 === $httpCode) {
|
148 |
+
throw new Exception('API Key or API Secret is invalid, please do check. If you need any assistance, please contact us.');
|
149 |
+
}
|
150 |
+
|
151 |
+
|
152 |
+
} catch (Exception $e) {
|
153 |
+
Mage::log('Failed execute API Get. Error: '.$e);
|
154 |
+
|
155 |
+
return;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
public static function getApiKey($store)
|
160 |
+
{
|
161 |
+
return (Mage::getStoreConfig(self::STAMPED_API_KEY_CONFIGURATION, $store));
|
162 |
+
}
|
163 |
+
|
164 |
+
public static function getApiSecret($store)
|
165 |
+
{
|
166 |
+
return (Mage::getStoreConfig(self::STAMPED_API_SECRET_CONFIGURATION, $store));
|
167 |
+
}
|
168 |
+
|
169 |
+
public static function getApiStoreUrl($store)
|
170 |
+
{
|
171 |
+
$store_url = (Mage::getStoreConfig(self::STAMPED_STORE_URL_CONFIGURATION, $store));
|
172 |
+
if (!$store_url){
|
173 |
+
$store_url = Mage::app()->getStore($store->getId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
174 |
+
}
|
175 |
+
|
176 |
+
return $store_url;
|
177 |
+
}
|
178 |
+
|
179 |
+
public static function getApiUrlAuth($store)
|
180 |
+
{
|
181 |
+
$apiKey = self::getApiKey($store);
|
182 |
+
$apiSecret = self::getApiSecret($store);
|
183 |
+
$store_url = self::getApiStoreUrl($store);
|
184 |
+
|
185 |
+
return sprintf(self::STAMPED_SECURED_API_URL, $apiKey, $apiSecret, $store_url);
|
186 |
+
}
|
187 |
+
|
188 |
+
public static function getRichSnippet($productId, $store)
|
189 |
+
{
|
190 |
+
return self::API_GET("/richsnippet?productId=".$productId, $store);
|
191 |
+
}
|
192 |
+
|
193 |
+
public static function createReviewRequest($order, $store)
|
194 |
+
{
|
195 |
+
return self::API_POST("/survey/reviews", $order, $store);
|
196 |
+
}
|
197 |
+
|
198 |
+
public static function createReviewRequestBulk($orders, $store)
|
199 |
+
{
|
200 |
+
return self::API_POST("/survey/reviews/bulk", $orders, $store);
|
201 |
+
}
|
202 |
+
}
|
app/code/community/Stamped/Core/Block/AdminHtml/System/Config/Form/Button.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class stamped_core_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
|
3 |
+
{
|
4 |
+
/*
|
5 |
+
* template
|
6 |
+
*/
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
parent::_construct();
|
10 |
+
$this->setTemplate('stamped/system/config/button.phtml');
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* return html
|
15 |
+
*
|
16 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
20 |
+
{
|
21 |
+
return $this->_toHtml();
|
22 |
+
}
|
23 |
+
}
|
24 |
+
?>
|
app/code/community/Stamped/Core/Block/Stamped.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class stamped_core_Block_Stamped extends Mage_Core_Block_Template
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getApiKey()
|
11 |
+
{
|
12 |
+
return trim(Mage::getStoreConfig('stamped/stamped_settings_group/stamped_apikey', Mage::app()->getStore()));
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getApiStoreUrl()
|
16 |
+
{
|
17 |
+
return trim(Mage::getStoreConfig('stamped/stamped_settings_group/stamped_storeurl', Mage::app()->getStore()));
|
18 |
+
}
|
19 |
+
|
20 |
+
public function setProduct($product)
|
21 |
+
{
|
22 |
+
$this->setData('product', $product);
|
23 |
+
$_product = $this->getProduct();
|
24 |
+
echo $_product->getName();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getProduct()
|
28 |
+
{
|
29 |
+
if (!$this->hasData('product'))
|
30 |
+
{
|
31 |
+
$this->setData('product', Mage::registry('product'));
|
32 |
+
}
|
33 |
+
|
34 |
+
$product = $this->getData('product');
|
35 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
36 |
+
$parentIds= $configurable_product_model->getParentIdsByChild($product->getId());
|
37 |
+
if (count($parentIds) > 0) {
|
38 |
+
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
39 |
+
}
|
40 |
+
return $product;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getProductId()
|
44 |
+
{
|
45 |
+
$_product = $this->getProduct();
|
46 |
+
$productId = $_product->getId();
|
47 |
+
return $productId;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function getProductName()
|
51 |
+
{
|
52 |
+
$_product = $this->getProduct();
|
53 |
+
$productName = $_product->getName();
|
54 |
+
|
55 |
+
return htmlspecialchars($productName);
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getProductImageUrl()
|
59 |
+
{
|
60 |
+
$image_url = Mage::getModel('catalog/product_media_config')->getMediaUrl($this->getProduct()->getSmallImage());
|
61 |
+
return $image_url;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function getProductModel()
|
65 |
+
{
|
66 |
+
$_product = $this->getProduct();
|
67 |
+
$productModel = $_product->getData('sku');
|
68 |
+
return htmlspecialchars($productModel);
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getProductDescription()
|
72 |
+
{
|
73 |
+
$_product = $this->getProduct();
|
74 |
+
$productDescription = Mage::helper('core')->htmlEscape(strip_tags($_product->getShortDescription()));
|
75 |
+
return $productDescription;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getProductUrl()
|
79 |
+
{
|
80 |
+
$productUrl = Mage::app()->getStore()->getCurrentUrl();
|
81 |
+
return $productUrl;
|
82 |
+
}
|
83 |
+
}
|
app/code/community/Stamped/Core/Helper/Data.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class stamped_core_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
private $_config;
|
6 |
+
|
7 |
+
public function __construct ()
|
8 |
+
{
|
9 |
+
$this->_config = Mage::getStoreConfig('stamped');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function showWidget($thisObj, $product = null, $print=true)
|
13 |
+
{
|
14 |
+
$res = $this->renderBlock($thisObj, 'stamped-reviews', $product, $print);
|
15 |
+
|
16 |
+
if ($print == false) {
|
17 |
+
return $res;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
public function showBadge($thisObj, $product = null, $print=true)
|
22 |
+
{
|
23 |
+
$res = $this->renderBlock($thisObj, 'stamped-badge', $product);
|
24 |
+
return $res;
|
25 |
+
|
26 |
+
if ($print == false){
|
27 |
+
return $res;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getRichSnippet()
|
32 |
+
{
|
33 |
+
try {
|
34 |
+
$productId = Mage::registry('product')->getId();
|
35 |
+
$snippet = Mage::getModel('stamped/richsnippet')->getSnippetByProductIdAndStoreId($productId, Mage::app()->getStore()->getId());
|
36 |
+
|
37 |
+
if (($snippet == null) || (!$snippet->isValid())) {
|
38 |
+
//no snippet for product or snippet isn't valid anymore. get valid snippet code from api
|
39 |
+
|
40 |
+
$res = Stamped_Core_ApiClient::getRichSnippet($productId, Mage::app()->getStore());
|
41 |
+
//$res2 = Stamped_Core_ApiClient::API_GET2('http://requestb.in/uq1k2fuq?id='.$productId.'1'.$res["data"].'bbb', Mage::app()->getStore());
|
42 |
+
|
43 |
+
if ($res["httpStatusCode"] != 200) {
|
44 |
+
return "";
|
45 |
+
}
|
46 |
+
|
47 |
+
$reviewsAverage = $res["reviewsAverage"];
|
48 |
+
$reviewsCount = $res["reviewsCount"];
|
49 |
+
$ttl = $res["ttl"];
|
50 |
+
|
51 |
+
if ($snippet == null) {
|
52 |
+
$snippet = Mage::getModel('stamped/richsnippet');
|
53 |
+
$snippet->setProductId($productId);
|
54 |
+
$snippet->setStoreId(Mage::app()->getStore()->getid());
|
55 |
+
}
|
56 |
+
|
57 |
+
$snippet->setAverageScore($reviewsAverage);
|
58 |
+
$snippet->setReviewsCount($reviewsCount);
|
59 |
+
$snippet->setExpirationTime(date('Y-m-d H:i:s', time() + $ttl));
|
60 |
+
$snippet->save();
|
61 |
+
|
62 |
+
return array("average_score" => $reviewsAverage, "reviews_count" => $reviewsCount);
|
63 |
+
}
|
64 |
+
|
65 |
+
return array( "average_score" => $snippet->getAverageScore(), "reviews_count" => $snippet->getReviewsCount());
|
66 |
+
|
67 |
+
} catch(Excpetion $e) {
|
68 |
+
Mage::log($e);
|
69 |
+
}
|
70 |
+
return array();
|
71 |
+
}
|
72 |
+
|
73 |
+
private function getAppKey()
|
74 |
+
{
|
75 |
+
return trim(Mage::getStoreConfig('stamped/stamped_settings_group/stamped_appkey',Mage::app()->getStore()));
|
76 |
+
}
|
77 |
+
|
78 |
+
private function renderBlock($thisObj, $blockName, $product = null, $print=true)
|
79 |
+
{
|
80 |
+
$block = $thisObj->getLayout()->getBlock('content')->getChild('stamped');
|
81 |
+
|
82 |
+
if ($block == null) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
$block = $block->getChild($blockName);
|
87 |
+
if ($block == null) {
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
|
91 |
+
if ($product != null)
|
92 |
+
{
|
93 |
+
$block->setAttribute('product', $product);
|
94 |
+
}
|
95 |
+
|
96 |
+
if ($block != null)
|
97 |
+
{
|
98 |
+
if ($print == true) {
|
99 |
+
echo $block->toHtml();
|
100 |
+
} else {
|
101 |
+
return $block->toHtml();
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
app/code/community/Stamped/Core/Model/Mysql4/Richsnippet.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class stamped_core_Model_Mysql4_Richsnippet extends Mage_Core_Model_Mysql4_Abstract {
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('stamped/richsnippet', 'rich_snippet_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Stamped/Core/Model/Mysql4/Richsnippet/Collection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class stamped_core_Model_Mysql4_Richsnippet_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
4 |
+
|
5 |
+
public function _construct() {
|
6 |
+
$this->_init ('stamped/richsnippet');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Stamped/Core/Model/Order/Observer.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Stamped_Core_Model_Order_Observer
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
}
|
9 |
+
|
10 |
+
public function add_review_request($observer)
|
11 |
+
{
|
12 |
+
try {
|
13 |
+
|
14 |
+
$event = $observer->getEvent();
|
15 |
+
$order = $event->getOrder();
|
16 |
+
$store_id = $order->getStoreId();
|
17 |
+
$orderStatuses = Mage::getStoreConfig('stamped/stamped_settings_group/order_status_trigger', $order->getStore());
|
18 |
+
if ($orderStatuses == null) {
|
19 |
+
$orderStatuses = array('complete');
|
20 |
+
} else {
|
21 |
+
$orderStatuses = array_map('strtolower', explode(',', $orderStatuses));
|
22 |
+
}
|
23 |
+
|
24 |
+
if (!Stamped_Core_ApiClient::isConfigured($store_id))
|
25 |
+
{
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
if (!in_array($order->getStatus(), $orderStatuses)) {
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
$data = array();
|
34 |
+
if (!$order->getCustomerIsGuest()) {
|
35 |
+
$data["user_reference"] = $order->getCustomerId();
|
36 |
+
}
|
37 |
+
|
38 |
+
// Get the id of the orders shipping address
|
39 |
+
$shippingId = $order->getShippingAddress()->getId();
|
40 |
+
|
41 |
+
// Get shipping address data using the id
|
42 |
+
$address = Mage::getModel('sales/order_address')->load($shippingId);
|
43 |
+
|
44 |
+
$data = array();
|
45 |
+
if (!$order->getCustomerIsGuest()) {
|
46 |
+
$data["userReference"] = $order->getCustomerEmail();
|
47 |
+
}
|
48 |
+
|
49 |
+
$data["customerId"] = $order->getCustomerId();
|
50 |
+
$data["email"] = $order->getCustomerEmail();
|
51 |
+
$data["firstName"] = $order->getCustomerFirstname();
|
52 |
+
$data["lastName"] = $order->getCustomerLastname();
|
53 |
+
$data["location"] = $address->getCountry();
|
54 |
+
$data['orderNumber'] = $order->getIncrementId();
|
55 |
+
$data['orderId'] = $order->getIncrementId();
|
56 |
+
$data['orderCurrencyISO'] = $order->getOrderCurrency()->getCode();
|
57 |
+
$data["orderTotalPrice"] = $order->getGrandTotal();
|
58 |
+
$data["orderSource"] = 'magento';
|
59 |
+
$data["orderDate"] = $order->getCreatedAtDate()->toString('yyyy-MM-dd HH:mm:ss');
|
60 |
+
$data['itemsList'] = Stamped_Core_ApiClient::getOrderProductsData($order);
|
61 |
+
$data['platform'] = 'magento';
|
62 |
+
|
63 |
+
Stamped_Core_ApiClient::createReviewRequest($data, $store_id);
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
|
67 |
+
} catch(Exception $e) {
|
68 |
+
Mage::log('Failed to send mail after purchase. Error: '.$e);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
app/code/community/Stamped/Core/Model/Resource/Mysql4/setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class stamped_core_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
|
4 |
+
|
5 |
+
}
|
app/code/community/Stamped/Core/controllers/Adminhtml/StampedController.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class stamped_core_Adminhtml_StampedController extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
public function importHistoryOrdersAction() {
|
7 |
+
try {
|
8 |
+
$current_store;
|
9 |
+
$page = 0;
|
10 |
+
$now = time();
|
11 |
+
$last = $now - (60*60*24*180); // 180 days ago
|
12 |
+
$from = date("Y-m-d", $last);
|
13 |
+
|
14 |
+
$store_code = Mage::app()->getRequest()->getParam('store');
|
15 |
+
|
16 |
+
foreach (Mage::app()->getStores() as $store) {
|
17 |
+
if ($store->getCode() == $store_code) {
|
18 |
+
global $current_store;
|
19 |
+
$current_store = $store;
|
20 |
+
break;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
$store_id = $current_store->getId();
|
25 |
+
|
26 |
+
if (Stamped_Core_ApiClient::isConfigured($current_store) == false)
|
27 |
+
{
|
28 |
+
Mage::app()->getResponse()->setBody('Please ensure you have configured the API Public Key and Private Key in Settings.');
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
|
32 |
+
$salesOrder=Mage::getModel("sales/order");
|
33 |
+
$orderStatuses = Mage::getStoreConfig('stamped/stamped_settings_group/order_status_trigger', $current_store);
|
34 |
+
if ($orderStatuses == null) {
|
35 |
+
$orderStatuses = array('complete');
|
36 |
+
} else {
|
37 |
+
$orderStatuses = array_map('strtolower', (explode(',', $orderStatuses)));
|
38 |
+
}
|
39 |
+
|
40 |
+
$salesCollection = $salesOrder->getCollection()
|
41 |
+
->addFieldToFilter('status', $orderStatuses)
|
42 |
+
->addFieldToFilter('store_id', $store_id)
|
43 |
+
->addAttributeToFilter('created_at', array('gteq' =>$from))
|
44 |
+
->addAttributeToSort('created_at', 'DESC')
|
45 |
+
->setPageSize(200);
|
46 |
+
|
47 |
+
$pages = $salesCollection->getLastPageNumber();
|
48 |
+
|
49 |
+
Mage::log(($pages));
|
50 |
+
|
51 |
+
do {
|
52 |
+
try {
|
53 |
+
$page++;
|
54 |
+
$salesCollection->setCurPage($page)->load();
|
55 |
+
|
56 |
+
$orders = array();
|
57 |
+
|
58 |
+
foreach($salesCollection as $order)
|
59 |
+
{
|
60 |
+
$order_data = array();
|
61 |
+
|
62 |
+
//Mage::log(('start loop '. $order->getIncrementId()));
|
63 |
+
// Get the id of the orders shipping address
|
64 |
+
$shippingAddress = $order->getShippingAddress();
|
65 |
+
|
66 |
+
// Get shipping address data using the id
|
67 |
+
if(!empty($shippingAddress)) {
|
68 |
+
$address = Mage::getModel('sales/order_address')->load($shippingAddress->getId());
|
69 |
+
|
70 |
+
if (!empty($address)){
|
71 |
+
$order_data["location"] = $address->getCountry();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
//if (!$order->getCustomerIsGuest()) {
|
76 |
+
// $order_data["userReference"] = $order->getCustomerEmail();
|
77 |
+
//}
|
78 |
+
|
79 |
+
$order_data["customerId"] = $order->getCustomerId();
|
80 |
+
$order_data["email"] = $order->getCustomerEmail();
|
81 |
+
$order_data["firstName"] = $order->getCustomerFirstname();
|
82 |
+
$order_data["lastName"] = $order->getCustomerLastname();
|
83 |
+
$order_data['orderNumber'] = $order->getIncrementId();
|
84 |
+
$order_data['orderId'] = $order->getIncrementId();
|
85 |
+
$order_data['orderCurrencyISO'] = $order->getOrderCurrency()->getCode();
|
86 |
+
$order_data["orderTotalPrice"] = $order->getGrandTotal();
|
87 |
+
$order_data["orderSource"] = 'magento';
|
88 |
+
$order_data["orderDate"] = $order->getCreatedAtDate()->toString('yyyy-MM-dd HH:mm:ss');
|
89 |
+
$order_data['itemsList'] = Stamped_Core_ApiClient::getOrderProductsData($order);
|
90 |
+
$order_data['apiUrl'] = Stamped_Core_ApiClient::getApiUrlAuth($current_store)."/survey/reviews/bulk";
|
91 |
+
|
92 |
+
$orders[] = $order_data;
|
93 |
+
|
94 |
+
//Mage::log(('end loop '. $order->getIncrementId()));
|
95 |
+
}
|
96 |
+
|
97 |
+
//Mage::log(('number of orders '.count($orders)));
|
98 |
+
|
99 |
+
if (count($orders) > 0)
|
100 |
+
{
|
101 |
+
//Mage::log(('importing '.count($orders)));
|
102 |
+
$result = Stamped_Core_ApiClient::createReviewRequestBulk($orders, $current_store);
|
103 |
+
|
104 |
+
//Mage::log(($result));
|
105 |
+
}
|
106 |
+
} catch (Exception $e) {
|
107 |
+
Mage::log('Failed to export past orders. Error: '.$e);
|
108 |
+
Mage::app()->getResponse()->setBody($e->getMessage());
|
109 |
+
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
$salesCollection->clear();
|
114 |
+
|
115 |
+
} while ($page <= (3000 / 200) && $page < $pages);
|
116 |
+
|
117 |
+
} catch(Exception $e) {
|
118 |
+
Mage::log('Failed to import history orders. Error: '.$e);
|
119 |
+
}
|
120 |
+
|
121 |
+
Mage::app()->getResponse()->setBody(1);
|
122 |
+
}
|
123 |
+
}
|
app/code/community/Stamped/Core/etc/adminhtml.xml
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<system>
|
11 |
+
<children>
|
12 |
+
<config>
|
13 |
+
<children>
|
14 |
+
<stamped translate="title">
|
15 |
+
<title>Stamped</title>
|
16 |
+
<sort_order>400</sort_order>
|
17 |
+
</stamped>
|
18 |
+
</children>
|
19 |
+
</config>
|
20 |
+
</children>
|
21 |
+
</system>
|
22 |
+
</children>
|
23 |
+
</admin>
|
24 |
+
</resources>
|
25 |
+
</acl>
|
26 |
+
</config>
|
app/code/community/Stamped/Core/etc/config.xml
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<stamped_core>
|
6 |
+
<version>1.0.0</version>
|
7 |
+
</stamped_core>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<global>
|
11 |
+
<blocks>
|
12 |
+
<stamped>
|
13 |
+
<class>stamped_core_Block</class>
|
14 |
+
</stamped>
|
15 |
+
</blocks>
|
16 |
+
<models>
|
17 |
+
<stamped>
|
18 |
+
<class>stamped_core_Model</class>
|
19 |
+
<resourceModel>stamped_mysql4</resourceModel>
|
20 |
+
</stamped>
|
21 |
+
|
22 |
+
<stamped_mysql4>
|
23 |
+
<class>stamped_core_Model_Mysql4</class>
|
24 |
+
<entities>
|
25 |
+
<richsnippet>
|
26 |
+
<table>stamped_rich_snippets</table>
|
27 |
+
</richsnippet>
|
28 |
+
</entities>
|
29 |
+
</stamped_mysql4>
|
30 |
+
</models>
|
31 |
+
<helpers>
|
32 |
+
order_status_trigger
|
33 |
+
<stamped>
|
34 |
+
<class>stamped_core_Helper</class>
|
35 |
+
</stamped>
|
36 |
+
</helpers>
|
37 |
+
<events>
|
38 |
+
<sales_order_save_after>
|
39 |
+
<observers>
|
40 |
+
<stamped_core_order_observer>
|
41 |
+
<type>singleton</type>
|
42 |
+
<class>Stamped_Core_Model_Order_Observer</class>
|
43 |
+
<method>add_review_request</method>
|
44 |
+
</stamped_core_order_observer>
|
45 |
+
</observers>
|
46 |
+
</sales_order_save_after>
|
47 |
+
</events>
|
48 |
+
<resources>
|
49 |
+
<stamped_setup>
|
50 |
+
<setup>
|
51 |
+
<module>stamped_core</module>
|
52 |
+
<class>stamped_core_Model_Resource_Mysql4_Setup</class>
|
53 |
+
</setup>
|
54 |
+
<connection>
|
55 |
+
<use>core_setup</use>
|
56 |
+
</connection>
|
57 |
+
</stamped_setup>
|
58 |
+
<stamped_write>
|
59 |
+
<connection>
|
60 |
+
<use>core_write</use>
|
61 |
+
</connection>
|
62 |
+
</stamped_write>
|
63 |
+
<stamped_read>
|
64 |
+
<connection>
|
65 |
+
<use>core_read</use>
|
66 |
+
</connection>
|
67 |
+
</stamped_read>
|
68 |
+
</resources>
|
69 |
+
</global>
|
70 |
+
|
71 |
+
<admin>
|
72 |
+
<routers>
|
73 |
+
<adminhtml>
|
74 |
+
<args>
|
75 |
+
<modules>
|
76 |
+
<stamped_core before="Mage_Adminhtml">stamped_core</stamped_core>
|
77 |
+
</modules>
|
78 |
+
</args>
|
79 |
+
</adminhtml>
|
80 |
+
</routers>
|
81 |
+
</admin>
|
82 |
+
|
83 |
+
<frontend>
|
84 |
+
<layout>
|
85 |
+
<updates>
|
86 |
+
<stamped>
|
87 |
+
<file>stamped.xml</file>
|
88 |
+
</stamped>
|
89 |
+
</updates>
|
90 |
+
</layout>
|
91 |
+
</frontend>
|
92 |
+
|
93 |
+
<adminhtml>
|
94 |
+
<acl>
|
95 |
+
<resources>
|
96 |
+
<admin>
|
97 |
+
<children>
|
98 |
+
<system>
|
99 |
+
<children>
|
100 |
+
<config>
|
101 |
+
<children>
|
102 |
+
<stamped>
|
103 |
+
<title>Stamped Module Section</title>
|
104 |
+
</stamped>
|
105 |
+
</children>
|
106 |
+
</config>
|
107 |
+
</children>
|
108 |
+
</system>
|
109 |
+
</children>
|
110 |
+
</admin>
|
111 |
+
</resources>
|
112 |
+
</acl>
|
113 |
+
</adminhtml>
|
114 |
+
|
115 |
+
<default>
|
116 |
+
<stamped>
|
117 |
+
<stamped_settings_group>
|
118 |
+
<order_status_trigger>complete</order_status_trigger>
|
119 |
+
</stamped_settings_group>
|
120 |
+
</stamped>
|
121 |
+
</default>
|
122 |
+
</config>
|
app/code/community/Stamped/Core/etc/system.xml
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<stamped>
|
5 |
+
<label>Stamped.io</label>
|
6 |
+
<sort_order>500</sort_order>
|
7 |
+
</stamped>
|
8 |
+
</tabs>
|
9 |
+
|
10 |
+
<sections>
|
11 |
+
<stamped module="stamped">
|
12 |
+
<label>Stamped.io Reviews</label>
|
13 |
+
<tab>stamped</tab>
|
14 |
+
<frontend_type>text</frontend_type>
|
15 |
+
<sort_order>1</sort_order>
|
16 |
+
<show_in_default>1</show_in_default>
|
17 |
+
<show_in_website>1</show_in_website>
|
18 |
+
<show_in_store>1</show_in_store>
|
19 |
+
<groups>
|
20 |
+
<default_config_group translate="label">
|
21 |
+
<label>Stamped Settings</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
+
<sort_order>1</sort_order>
|
24 |
+
<show_in_store>0</show_in_store>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<comment>
|
28 |
+
<![CDATA[
|
29 |
+
<p>Stamped.io allows you to automatically send emails to your customers requesting for reviews of their recent purchase with you.</p>
|
30 |
+
<p>Edit the Settings by selecting store view from the "<strong>Current Configuration Scope</strong>" dropdown on the top of the left sidebar.</p>
|
31 |
+
]]>
|
32 |
+
</comment>
|
33 |
+
</default_config_group>
|
34 |
+
|
35 |
+
<stamped_settings_group translate="label">
|
36 |
+
<label>Settings</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>2</sort_order>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<show_in_default>0</show_in_default>
|
41 |
+
<show_in_website>0</show_in_website>
|
42 |
+
<comment>
|
43 |
+
<![CDATA[
|
44 |
+
<p>Please enter the following API Public & Private Key, you can grab the keys from your Stamped.io Profile's page here: <a href="http://go.stamped.io/#/app/settings">http://go.stamped.io/#/app/settings</a></p>
|
45 |
+
]]>
|
46 |
+
</comment>
|
47 |
+
|
48 |
+
<fields>
|
49 |
+
<stamped_apikey>
|
50 |
+
<label>API Public Key</label>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>1</sort_order>
|
53 |
+
<comment>
|
54 |
+
</comment>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
<show_in_website>0</show_in_website>
|
57 |
+
<show_in_default>0</show_in_default>
|
58 |
+
</stamped_apikey>
|
59 |
+
<stamped_apisecret>
|
60 |
+
<label>API Private Key</label>
|
61 |
+
<frontend_type>text</frontend_type>
|
62 |
+
<sort_order>2</sort_order>
|
63 |
+
<comment>
|
64 |
+
</comment>
|
65 |
+
<show_in_store>1</show_in_store>
|
66 |
+
<show_in_default>0</show_in_default>
|
67 |
+
<show_in_website>0</show_in_website>
|
68 |
+
</stamped_apisecret>
|
69 |
+
<stamped_storeurl>
|
70 |
+
<label>Store URL</label>
|
71 |
+
<frontend_type>text</frontend_type>
|
72 |
+
<sort_order>3</sort_order>
|
73 |
+
<comment>
|
74 |
+
<![CDATA[
|
75 |
+
This URL should match the one provided in your Stamped.io account
|
76 |
+
]]>
|
77 |
+
</comment>
|
78 |
+
<show_in_store>1</show_in_store>
|
79 |
+
<show_in_default>0</show_in_default>
|
80 |
+
<show_in_website>0</show_in_website>
|
81 |
+
</stamped_storeurl>
|
82 |
+
<enable_widget>
|
83 |
+
<label>Show reviews widget in product page</label>
|
84 |
+
<frontend_type>select</frontend_type>
|
85 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
86 |
+
<enabled>1</enabled>
|
87 |
+
<sort_order>4</sort_order>
|
88 |
+
<comment>
|
89 |
+
<![CDATA[
|
90 |
+
Show reviews widget in product page
|
91 |
+
]]>
|
92 |
+
</comment>
|
93 |
+
<show_in_default>0</show_in_default>
|
94 |
+
<show_in_website>0</show_in_website>
|
95 |
+
<show_in_store>1</show_in_store>
|
96 |
+
</enable_widget>
|
97 |
+
<order_status_trigger translate="label">
|
98 |
+
<label>Order status to trigger Review Requests Emails</label>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>4</sort_order>
|
101 |
+
<comment>
|
102 |
+
<![CDATA[
|
103 |
+
Set the order statuses that will trigger the review requests to be sent, example of commonly used statuses are "Complete", "Shipped," "Pending," or "Received.". Seperate multiple status with comma e.g. "Complete, Shipped"
|
104 |
+
]]>
|
105 |
+
</comment>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
+
<show_in_default>0</show_in_default>
|
108 |
+
<show_in_website>0</show_in_website>
|
109 |
+
</order_status_trigger>
|
110 |
+
</fields>
|
111 |
+
</stamped_settings_group>
|
112 |
+
|
113 |
+
<stamped_import_group translate="label">
|
114 |
+
<label>History Orders Import</label>
|
115 |
+
<frontend_type>text</frontend_type>
|
116 |
+
<sort_order>3</sort_order>
|
117 |
+
<show_in_store>1</show_in_store>
|
118 |
+
<show_in_default>0</show_in_default>
|
119 |
+
<show_in_website>0</show_in_website>
|
120 |
+
<comment>
|
121 |
+
</comment>
|
122 |
+
|
123 |
+
<fields>
|
124 |
+
<import_history_orders translate="label">
|
125 |
+
<label>
|
126 |
+
<![CDATA[
|
127 |
+
Import your existing orders history up to 6 months to Stamped.io. <br /><br /><i>If you need to import orders that is back-dated more than 6 months, please email us at hello@shopry.com</i>
|
128 |
+
]]>
|
129 |
+
</label>
|
130 |
+
<frontend_type>button</frontend_type>
|
131 |
+
<frontend_model>
|
132 |
+
stamped/adminhtml_system_config_form_button
|
133 |
+
</frontend_model>
|
134 |
+
<sort_order>3</sort_order>
|
135 |
+
<show_in_store>1</show_in_store>
|
136 |
+
<show_in_default>0</show_in_default>
|
137 |
+
<show_in_website>0</show_in_website>
|
138 |
+
<comment>
|
139 |
+
</comment>
|
140 |
+
</import_history_orders>
|
141 |
+
</fields>
|
142 |
+
</stamped_import_group>
|
143 |
+
</groups>
|
144 |
+
</stamped>
|
145 |
+
</sections>
|
146 |
+
</config>
|
app/design/adminhtml/default/default/template/stamped/system/config/button.phtml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/javascript">
|
2 |
+
//<![CDATA[
|
3 |
+
function importHistoryOrders() {
|
4 |
+
new Ajax.Request('<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_stamped/importHistoryOrders') ?>', {
|
5 |
+
method: 'get',
|
6 |
+
parameters: {
|
7 |
+
"store" : "<?php echo Mage::app()->getRequest()->getParam('store', 0); ?>"
|
8 |
+
},
|
9 |
+
onComplete: function(transport){
|
10 |
+
if (transport.responseText == 1){
|
11 |
+
var html = '<ul class="messages"><li class="success-msg"><ul><li>' + 'Your orders has been imported to Stamped.io successfully. Please visit https://go.stamped.io/ to check your scheduled reviews requests.' + '</li></ul></li></ul>';
|
12 |
+
$('messages').update(html);
|
13 |
+
}
|
14 |
+
else {
|
15 |
+
var html = '<ul class="messages"><li class="error-msg"><ul><li>' + transport.responseText + '</li></ul></li></ul>';
|
16 |
+
$('messages').update(html);
|
17 |
+
}
|
18 |
+
}
|
19 |
+
});
|
20 |
+
}
|
21 |
+
//]]>
|
22 |
+
</script>
|
23 |
+
|
24 |
+
<?php echo $this->getLayout()->createBlock('adminhtml/widget_button')
|
25 |
+
->setData(array(
|
26 |
+
'id' => 'stamped_button',
|
27 |
+
'label' => $this->helper('adminhtml')->__('Import History Orders'),
|
28 |
+
'onclick' => 'javascript:importHistoryOrders(); return false;'
|
29 |
+
)) -> _toHtml(); ?>
|
app/design/frontend/base/default/layout/stamped.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
|
4 |
+
<catalog_product_view>
|
5 |
+
<reference name="alert.urls">
|
6 |
+
<block type="stamped/stamped" name="stamped.reviews.badge" as="stamped-reviews-badge" template="stamped/badge.phtml"></block>
|
7 |
+
</reference>
|
8 |
+
|
9 |
+
<reference name="content">
|
10 |
+
<block type="stamped/stamped" name="stamped.reviews.widget" as="stamped-reviews-widget" template="stamped/widget.phtml" after="product.info"></block>
|
11 |
+
</reference>
|
12 |
+
|
13 |
+
<reference name="product.info">
|
14 |
+
<block type="stamped/stamped" name="stamped.reviews" as="stamped-reviews" template="stamped/widget2.phtml"/>
|
15 |
+
</reference>
|
16 |
+
</catalog_product_view>
|
17 |
+
|
18 |
+
<default>
|
19 |
+
<reference name="head">
|
20 |
+
<block type="stamped/stamped" as="stamped-js" template="stamped/javascript.phtml" name="stamped.js">
|
21 |
+
</block>
|
22 |
+
</reference>
|
23 |
+
|
24 |
+
<reference name="content">
|
25 |
+
<block type="cms/block" name="stamped" as="stamped">
|
26 |
+
<block type="stamped/stamped" name="stamped.badge" as="stamped-badge" template="stamped/badge.phtml"/>
|
27 |
+
<block type="stamped/stamped" name="stamped.reviews" as="stamped-reviews" template="stamped/reviews.phtml"/>
|
28 |
+
</block>
|
29 |
+
</reference>
|
30 |
+
</default>
|
31 |
+
</layout>
|
app/design/frontend/base/default/template/stamped/badge.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<span class="stamped-product-reviews-badge" data-id="<?php echo $this->getProductId() ?>" data-url="<?php echo $this->getProductUrl() ?>"></span>
|
app/design/frontend/base/default/template/stamped/javascript.phtml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<link href="https://stamped-io.azureedge.net/files/widget.min.css?v=1.1" rel="stylesheet" type="text/css" media="all" />
|
2 |
+
<script type="text/javascript" src="https://stamped-io.azureedge.net/files/widget.min.js?v=1.1"></script>
|
3 |
+
<script>
|
4 |
+
StampedFn.init({
|
5 |
+
apiKey: '<?php echo $this->getApiKey(); ?>',
|
6 |
+
storeUrl: '<?php echo $this->getApiStoreUrl(); ?>'
|
7 |
+
});
|
8 |
+
</script>
|
app/design/frontend/base/default/template/stamped/widget.phtml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (!!Mage::getStoreConfig('stamped/stamped_settings_group/enable_widget',Mage::app()->getStore())):?>
|
2 |
+
<div id="stamped-main-widget" class="stamped stamped-main-widget"
|
3 |
+
data-product-id="<?php echo $this->getProductId() ?>"
|
4 |
+
data-name="<?php echo $this->getProductName() ?>"
|
5 |
+
data-url="<?php echo $this->getProductUrl() ?>"
|
6 |
+
data-image-url="<?php echo $this->getProductImageUrl() ?>"
|
7 |
+
data-description="<?php echo $this->getProductDescription() ?>">
|
8 |
+
</div>
|
9 |
+
<?php endif ?>
|
app/design/frontend/base/default/template/stamped/widget2.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div id="stamped-main-widget" class="stamped stamped-main-widget"
|
2 |
+
data-product-id="<?php echo $this->getProductId() ?>"
|
3 |
+
data-name="<?php echo $this->getProductName() ?>"
|
4 |
+
data-url="<?php echo $this->getProductUrl() ?>"
|
5 |
+
data-image-url="<?php echo $this->getProductImageUrl() ?>"
|
6 |
+
data-description="<?php echo $this->getProductDescription() ?>">
|
7 |
+
</div>
|
app/etc/modules/Stamped_Stamped.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<stamped_core>
|
6 |
+
<active>true</active>
|
7 |
+
<codePool>community</codePool>
|
8 |
+
</stamped_core>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Stamped_Reviews</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.stamped.io/">custom</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Stamped.io allows you to automatically send emails to your customers requesting for reviews for their purchase</summary>
|
10 |
+
<description>Stamped.io allows you to automatically send emails to your customers requesting for reviews for their purchase
|
11 |
+

|
12 |
+
Customers writes their review directly in the email
|
13 |
+
The emails which will be sent to your customers includes a review form, allowing your customers to leave their reviews directly in the email without having to go to a external website, hence, making it convenient for your customers. This convenience increases the chance of getting more reviews. Our users has experienced 300% more conversions in reviews received! And has seen an increase of 30% in Sales conversions</description>
|
14 |
+
<notes>Initial launch 1.0.0, stable</notes>
|
15 |
+
<authors><author><name>shopry</name><user>shopry</user><email>tommy@shopry.com</email></author></authors>
|
16 |
+
<date>2016-08-10</date>
|
17 |
+
<time>10:40:46</time>
|
18 |
+
<contents><target name="magecommunity"><dir name="Stamped"><dir name="Core"><dir name="Block"><dir name="AdminHtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="58571b0ae5c6b4cc340abea1ba16c919"/></dir></dir></dir></dir><file name="Stamped.php" hash="af939ae833fd985e06ce061add9688c3"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="StampedController.php" hash="45b39088bfb88eda630ed5ca43b6cf78"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="89d03dffd4e1824060dd2fef5ad87e52"/><file name="config.xml" hash="fd761fdb44941c08ec2b4058a25e196d"/><file name="system.xml" hash="f5555f45bf8fba12e168eba4bf661cc2"/></dir><dir name="Helper"><file name="Data.php" hash="afb964afe6fd318843a798bbda73e175"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Richsnippet"><file name="Collection.php" hash="ef2899dc158df9cecfa126aa513c26cd"/></dir><file name="Richsnippet.php" hash="f59e2d2fa1f71db4521d6a12f3b80b20"/></dir><dir name="Order"><file name="Observer.php" hash="9216d49e235808cbc4615bbd38d9bddb"/></dir><dir name="Resource"><dir name="Mysql4"><file name="setup.php" hash="096516b57630b4d4d63121c338691f92"/></dir><file name="Richsnippet.php" hash=""/></dir></dir><dir name="sql"><dir name="stamped_setup"><file name="mysql-install-1.0.0.php" hash=""/></dir></dir><file name="ApiClient.php" hash="ed0f13d8859f87793d2a13036beb0570"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="stamped"><dir name="system"><dir name="config"><file name="button.phtml" hash="d843026304cca14fe76fba3e9718bd4c"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="stamped.xml" hash="09c364b2cd4c93085fbe86aad9659e54"/></dir><dir name="template"><dir name="stamped"><file name="badge.phtml" hash="2213f4133be4d77aa9530803b1f0fb48"/><file name="javascript.phtml" hash="d1c970b2f53abd5b8732e985bc456185"/><file name="widget.phtml" hash="867e141f0eef8e6646c2dda563ce4095"/><file name="widget2.phtml" hash="65b4d0618393ffb9e8bacdd2b530b6e5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Stamped_Stamped.xml" hash="d13822e3739720ab0cbd768bc02f4d07"/></dir></target></contents>
|
19 |
+
<compatible/>
|
20 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
21 |
+
</package>
|