Version Notes
Multistore with separate imports and separate background order sync
Download this release
Release Info
| Developer | Murry Ivanoff |
| Extension | Metrilo_Analytics |
| Version | 1.1.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.6 to 1.1.7
- app/code/community/Metrilo/Analytics/Block/Adminhtml/System/Config/Form/Button.php +26 -12
- app/code/community/Metrilo/Analytics/Block/Head.php +6 -1
- app/code/community/Metrilo/Analytics/Helper/{AsyncHttpClient.php → Asynchttpclient.php} +0 -0
- app/code/community/Metrilo/Analytics/Helper/Data.php +34 -55
- app/code/community/Metrilo/Analytics/Model/Import.php +28 -9
- app/code/community/Metrilo/Analytics/Model/Observer.php +3 -1
- app/code/community/Metrilo/Analytics/controllers/Adminhtml/AjaxController.php +3 -2
- app/code/community/Metrilo/Analytics/etc/config.xml +1 -1
- app/code/community/Metrilo/Analytics/etc/system.xml +1 -1
- app/design/adminhtml/default/default/template/metrilo/system/config/button.phtml +70 -54
- app/design/frontend/base/default/template/metrilo/head.phtml +3 -1
- package.xml +4 -4
app/code/community/Metrilo/Analytics/Block/Adminhtml/System/Config/Form/Button.php
CHANGED
|
@@ -29,17 +29,30 @@ class Metrilo_Analytics_Block_Adminhtml_System_Config_Form_Button extends Mage_A
|
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*
|
| 34 |
-
* @return
|
| 35 |
*/
|
| 36 |
-
|
| 37 |
{
|
| 38 |
-
$html = parent::_toHtml();
|
| 39 |
$helper = Mage::helper('metrilo_analytics');
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
/**
|
|
@@ -70,12 +83,13 @@ class Metrilo_Analytics_Block_Adminhtml_System_Config_Form_Button extends Mage_A
|
|
| 70 |
*/
|
| 71 |
public function getButtonHtml()
|
| 72 |
{
|
| 73 |
-
$button = $this->getLayout()
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
| 79 |
|
| 80 |
return $button->toHtml();
|
| 81 |
}
|
| 29 |
}
|
| 30 |
|
| 31 |
/**
|
| 32 |
+
* Get import instance
|
| 33 |
+
*
|
| 34 |
+
* @return boolean
|
| 35 |
+
*/
|
| 36 |
+
public function showInStore()
|
| 37 |
+
{
|
| 38 |
+
return Mage::app()->getRequest()->getParam('store');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Get import instance
|
| 44 |
*
|
| 45 |
+
* @return boolean
|
| 46 |
*/
|
| 47 |
+
public function buttonEnabled()
|
| 48 |
{
|
|
|
|
| 49 |
$helper = Mage::helper('metrilo_analytics');
|
| 50 |
|
| 51 |
+
$request = Mage::app()->getRequest();
|
| 52 |
+
$storeId = $helper->getStoreId($request);
|
| 53 |
+
|
| 54 |
+
return $helper->isEnabled($storeId) &&
|
| 55 |
+
$helper->getApiToken($storeId) && $helper->getApiSecret($storeId);
|
| 56 |
}
|
| 57 |
|
| 58 |
/**
|
| 83 |
*/
|
| 84 |
public function getButtonHtml()
|
| 85 |
{
|
| 86 |
+
$button = $this->getLayout()
|
| 87 |
+
->createBlock('adminhtml/widget_button')
|
| 88 |
+
->setData(array(
|
| 89 |
+
'id' => 'metrilo_button',
|
| 90 |
+
'label' => $this->helper('adminhtml')->__('Import orders'),
|
| 91 |
+
'onclick' => 'javascript:import_metrilo(); return false;'
|
| 92 |
+
));
|
| 93 |
|
| 94 |
return $button->toHtml();
|
| 95 |
}
|
app/code/community/Metrilo/Analytics/Block/Head.php
CHANGED
|
@@ -33,7 +33,12 @@ class Metrilo_Analytics_Block_Head extends Mage_Core_Block_Template
|
|
| 33 |
protected function _toHtml()
|
| 34 |
{
|
| 35 |
$html = parent::_toHtml();
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
return $html;
|
| 38 |
}
|
| 39 |
}
|
| 33 |
protected function _toHtml()
|
| 34 |
{
|
| 35 |
$html = parent::_toHtml();
|
| 36 |
+
$helper = Mage::helper('metrilo_analytics');
|
| 37 |
+
|
| 38 |
+
$request = Mage::app()->getRequest();
|
| 39 |
+
$storeId = $helper->getStoreId($request);
|
| 40 |
+
|
| 41 |
+
if($helper->isEnabled($storeId))
|
| 42 |
return $html;
|
| 43 |
}
|
| 44 |
}
|
app/code/community/Metrilo/Analytics/Helper/{AsyncHttpClient.php → Asynchttpclient.php}
RENAMED
|
File without changes
|
app/code/community/Metrilo/Analytics/Helper/Data.php
CHANGED
|
@@ -17,14 +17,33 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 17 |
return Mage::getSingleton('core/session');
|
| 18 |
}
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
/**
|
| 21 |
* Check if metrilo module is enabled
|
| 22 |
*
|
| 23 |
* @return boolean
|
| 24 |
*/
|
| 25 |
-
public function isEnabled()
|
| 26 |
{
|
| 27 |
-
return Mage::getStoreConfig('metrilo_analytics_settings/settings/enable');
|
| 28 |
}
|
| 29 |
|
| 30 |
/**
|
|
@@ -32,9 +51,9 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 32 |
*
|
| 33 |
* @return string
|
| 34 |
*/
|
| 35 |
-
public function getApiToken()
|
| 36 |
{
|
| 37 |
-
return Mage::getStoreConfig('metrilo_analytics_settings/settings/api_key');
|
| 38 |
}
|
| 39 |
|
| 40 |
/**
|
|
@@ -42,9 +61,9 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 42 |
*
|
| 43 |
* @return string
|
| 44 |
*/
|
| 45 |
-
public function getApiSecret()
|
| 46 |
{
|
| 47 |
-
return Mage::getStoreConfig('metrilo_analytics_settings/settings/api_secret');
|
| 48 |
}
|
| 49 |
|
| 50 |
/**
|
|
@@ -138,48 +157,30 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 138 |
return $data;
|
| 139 |
}
|
| 140 |
|
| 141 |
-
/**
|
| 142 |
-
* Create HTTP request to Metrilo API to sync single order
|
| 143 |
-
*
|
| 144 |
-
* @param Mage_Sales_Model_Order $order
|
| 145 |
-
* @return void
|
| 146 |
-
*/
|
| 147 |
-
public function callApi($order, $async = true)
|
| 148 |
-
{
|
| 149 |
-
try {
|
| 150 |
-
$this->callBatchApi(array($order), $async);
|
| 151 |
-
} catch (Exception $e){
|
| 152 |
-
Mage::log($e->getMessage(), null, 'Metrilo_Analytics.log');
|
| 153 |
-
}
|
| 154 |
-
}
|
| 155 |
-
|
| 156 |
/**
|
| 157 |
* Create HTTP request to Metrilo API to sync multiple orders
|
| 158 |
*
|
| 159 |
* @param Array(Mage_Sales_Model_Order) $orders
|
| 160 |
* @return void
|
| 161 |
*/
|
| 162 |
-
public function callBatchApi($
|
| 163 |
{
|
| 164 |
try {
|
| 165 |
$ordersForSubmition = $this->_buildOrdersForSubmition($orders);
|
| 166 |
-
$call = $this->_buildCall($ordersForSubmition);
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
} else {
|
| 170 |
-
$this->_callMetriloApi($call);
|
| 171 |
-
}
|
| 172 |
} catch (Exception $e) {
|
| 173 |
Mage::log($e->getMessage(), null, 'Metrilo_Analytics.log');
|
| 174 |
}
|
| 175 |
}
|
| 176 |
|
| 177 |
// Private functions start here
|
| 178 |
-
|
| 179 |
-
private function _callMetriloApiAsync($call) {
|
| 180 |
ksort($call);
|
|
|
|
| 181 |
$basedCall = base64_encode(Mage::helper('core')->jsonEncode($call));
|
| 182 |
-
$signature = md5($basedCall.$this->getApiSecret());
|
| 183 |
|
| 184 |
$requestBody = array(
|
| 185 |
's' => $signature,
|
|
@@ -190,28 +191,6 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 190 |
$asyncHttpHelper->post('http://p.metrilo.com/bt', $requestBody);
|
| 191 |
}
|
| 192 |
|
| 193 |
-
private function _callMetriloApi($call) {
|
| 194 |
-
// Prepare call for submition
|
| 195 |
-
ksort($call);
|
| 196 |
-
$basedCall = base64_encode(Mage::helper('core')->jsonEncode($call));
|
| 197 |
-
$signature = md5($basedCall.$this->getApiSecret());
|
| 198 |
-
|
| 199 |
-
$requestBody = array(
|
| 200 |
-
's' => $signature,
|
| 201 |
-
'hs' => $basedCall
|
| 202 |
-
);
|
| 203 |
-
|
| 204 |
-
$client = new Varien_Http_Client('http://p.metrilo.com/bt');
|
| 205 |
-
|
| 206 |
-
// This method supports passing named array as well as key, value
|
| 207 |
-
$client->setParameterPost($requestBody);
|
| 208 |
-
$response = $client->request('POST');
|
| 209 |
-
|
| 210 |
-
if ($response->isError()) {
|
| 211 |
-
Mage::log($response->getBody(), null, 'Metrilo_Analytics.log');
|
| 212 |
-
}
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
/**
|
| 216 |
* Create submition ready arrays from Array of Mage_Sales_Model_Order
|
| 217 |
* @param Array(Mage_Sales_Model_Order) $orders
|
|
@@ -300,9 +279,9 @@ class Metrilo_Analytics_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 300 |
);
|
| 301 |
}
|
| 302 |
|
| 303 |
-
private function _buildCall($ordersForSubmition) {
|
| 304 |
return array(
|
| 305 |
-
'token' => $this->getApiToken(),
|
| 306 |
'events' => $ordersForSubmition,
|
| 307 |
// for debugging/support purposes
|
| 308 |
'platform' => 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion(),
|
| 17 |
return Mage::getSingleton('core/session');
|
| 18 |
}
|
| 19 |
|
| 20 |
+
/**
|
| 21 |
+
* Get storeId for the current request context
|
| 22 |
+
*
|
| 23 |
+
* @return string
|
| 24 |
+
*/
|
| 25 |
+
public function getStoreId($request = null) {
|
| 26 |
+
if ($request) {
|
| 27 |
+
# If request is passed retrieve store by storeCode
|
| 28 |
+
$storeCode = $request->getParam('store');
|
| 29 |
+
|
| 30 |
+
if ($storeCode) {
|
| 31 |
+
return Mage::getModel('core/store')->load($storeCode)->getId();
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
# If no request or empty store code
|
| 36 |
+
return Mage::app()->getStore()->getId();
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
/**
|
| 40 |
* Check if metrilo module is enabled
|
| 41 |
*
|
| 42 |
* @return boolean
|
| 43 |
*/
|
| 44 |
+
public function isEnabled($storeId = null)
|
| 45 |
{
|
| 46 |
+
return Mage::getStoreConfig('metrilo_analytics_settings/settings/enable', $storeId);
|
| 47 |
}
|
| 48 |
|
| 49 |
/**
|
| 51 |
*
|
| 52 |
* @return string
|
| 53 |
*/
|
| 54 |
+
public function getApiToken($storeId = null)
|
| 55 |
{
|
| 56 |
+
return Mage::getStoreConfig('metrilo_analytics_settings/settings/api_key', $storeId);
|
| 57 |
}
|
| 58 |
|
| 59 |
/**
|
| 61 |
*
|
| 62 |
* @return string
|
| 63 |
*/
|
| 64 |
+
public function getApiSecret($storeId = null)
|
| 65 |
{
|
| 66 |
+
return Mage::getStoreConfig('metrilo_analytics_settings/settings/api_secret', $storeId);
|
| 67 |
}
|
| 68 |
|
| 69 |
/**
|
| 157 |
return $data;
|
| 158 |
}
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
/**
|
| 161 |
* Create HTTP request to Metrilo API to sync multiple orders
|
| 162 |
*
|
| 163 |
* @param Array(Mage_Sales_Model_Order) $orders
|
| 164 |
* @return void
|
| 165 |
*/
|
| 166 |
+
public function callBatchApi($storeId, $orders)
|
| 167 |
{
|
| 168 |
try {
|
| 169 |
$ordersForSubmition = $this->_buildOrdersForSubmition($orders);
|
| 170 |
+
$call = $this->_buildCall($storeId, $ordersForSubmition);
|
| 171 |
+
|
| 172 |
+
$this->_callMetriloApiAsync($storeId, $call);
|
|
|
|
|
|
|
|
|
|
| 173 |
} catch (Exception $e) {
|
| 174 |
Mage::log($e->getMessage(), null, 'Metrilo_Analytics.log');
|
| 175 |
}
|
| 176 |
}
|
| 177 |
|
| 178 |
// Private functions start here
|
| 179 |
+
private function _callMetriloApiAsync($storeId, $call) {
|
|
|
|
| 180 |
ksort($call);
|
| 181 |
+
|
| 182 |
$basedCall = base64_encode(Mage::helper('core')->jsonEncode($call));
|
| 183 |
+
$signature = md5($basedCall.$this->getApiSecret($storeId));
|
| 184 |
|
| 185 |
$requestBody = array(
|
| 186 |
's' => $signature,
|
| 191 |
$asyncHttpHelper->post('http://p.metrilo.com/bt', $requestBody);
|
| 192 |
}
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
/**
|
| 195 |
* Create submition ready arrays from Array of Mage_Sales_Model_Order
|
| 196 |
* @param Array(Mage_Sales_Model_Order) $orders
|
| 279 |
);
|
| 280 |
}
|
| 281 |
|
| 282 |
+
private function _buildCall($storeId, $ordersForSubmition) {
|
| 283 |
return array(
|
| 284 |
+
'token' => $this->getApiToken($storeId),
|
| 285 |
'events' => $ordersForSubmition,
|
| 286 |
// for debugging/support purposes
|
| 287 |
'platform' => 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion(),
|
app/code/community/Metrilo/Analytics/Model/Import.php
CHANGED
|
@@ -8,7 +8,7 @@ class Metrilo_Analytics_Model_Import extends Mage_Core_Model_Abstract
|
|
| 8 |
{
|
| 9 |
private $_ordersTotal = 0;
|
| 10 |
private $_totalChunks = 0;
|
| 11 |
-
private $_chunkItems
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Prepare all order ids
|
|
@@ -17,9 +17,7 @@ class Metrilo_Analytics_Model_Import extends Mage_Core_Model_Abstract
|
|
| 17 |
*/
|
| 18 |
public function _construct()
|
| 19 |
{
|
| 20 |
-
|
| 21 |
-
$this->_ordersTotal = Mage::getModel('sales/order')->getCollection()->getSize();
|
| 22 |
-
$this->_totalChunks = (int)ceil($this->_ordersTotal / $this->_chunkItems);
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
|
@@ -28,10 +26,9 @@ class Metrilo_Analytics_Model_Import extends Mage_Core_Model_Abstract
|
|
| 28 |
* @param int
|
| 29 |
* @return Varien_Data_Collection
|
| 30 |
*/
|
| 31 |
-
public function getOrders($chunkId)
|
| 32 |
{
|
| 33 |
-
return
|
| 34 |
-
->getCollection()
|
| 35 |
->setPageSize($this->_chunkItems)
|
| 36 |
->setCurPage($chunkId + 1);
|
| 37 |
}
|
|
@@ -41,8 +38,30 @@ class Metrilo_Analytics_Model_Import extends Mage_Core_Model_Abstract
|
|
| 41 |
*
|
| 42 |
* @return array
|
| 43 |
*/
|
| 44 |
-
public function getChunks()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
{
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
}
|
| 8 |
{
|
| 9 |
private $_ordersTotal = 0;
|
| 10 |
private $_totalChunks = 0;
|
| 11 |
+
private $_chunkItems = 15;
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Prepare all order ids
|
| 17 |
*/
|
| 18 |
public function _construct()
|
| 19 |
{
|
| 20 |
+
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 26 |
* @param int
|
| 27 |
* @return Varien_Data_Collection
|
| 28 |
*/
|
| 29 |
+
public function getOrders($storeId, $chunkId)
|
| 30 |
{
|
| 31 |
+
return $this->_getOrderQuery($storeId)
|
|
|
|
| 32 |
->setPageSize($this->_chunkItems)
|
| 33 |
->setCurPage($chunkId + 1);
|
| 34 |
}
|
| 38 |
*
|
| 39 |
* @return array
|
| 40 |
*/
|
| 41 |
+
public function getChunks($storeId)
|
| 42 |
+
{
|
| 43 |
+
$storeTotal = $this->_getOrderQuery($storeId)->getSize();
|
| 44 |
+
|
| 45 |
+
return (int)ceil($storeTotal / $this->_chunkItems);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Get contextual store id
|
| 50 |
+
*
|
| 51 |
+
* @return int
|
| 52 |
+
*/
|
| 53 |
+
public function getStoreId()
|
| 54 |
{
|
| 55 |
+
$helper = Mage::helper('metrilo_analytics');
|
| 56 |
+
$request = Mage::app()->getRequest();
|
| 57 |
+
|
| 58 |
+
return $helper->getStoreId($request);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
private function _getOrderQuery($storeId)
|
| 62 |
+
{
|
| 63 |
+
return Mage::getModel('sales/order')
|
| 64 |
+
->getCollection()
|
| 65 |
+
->addAttributeToFilter('store_id', $storeId);
|
| 66 |
}
|
| 67 |
}
|
app/code/community/Metrilo/Analytics/Model/Observer.php
CHANGED
|
@@ -229,8 +229,10 @@ class Metrilo_Analytics_Model_Observer
|
|
| 229 |
*/
|
| 230 |
public function updateOrder(Varien_Event_Observer $observer)
|
| 231 |
{
|
|
|
|
|
|
|
| 232 |
$helper = Mage::helper('metrilo_analytics');
|
| 233 |
-
$helper->
|
| 234 |
}
|
| 235 |
|
| 236 |
/**
|
| 229 |
*/
|
| 230 |
public function updateOrder(Varien_Event_Observer $observer)
|
| 231 |
{
|
| 232 |
+
$order = $observer->getOrder();
|
| 233 |
+
|
| 234 |
$helper = Mage::helper('metrilo_analytics');
|
| 235 |
+
$helper->callBatchApi($order->getStoreId(), array($order));
|
| 236 |
}
|
| 237 |
|
| 238 |
/**
|
app/code/community/Metrilo/Analytics/controllers/Adminhtml/AjaxController.php
CHANGED
|
@@ -18,11 +18,12 @@ class Metrilo_Analytics_Adminhtml_AjaxController extends Mage_Adminhtml_Controll
|
|
| 18 |
$helper = Mage::helper('metrilo_analytics');
|
| 19 |
try {
|
| 20 |
$import = Mage::getSingleton('metrilo_analytics/import');
|
|
|
|
| 21 |
$chunkId = (int)$this->getRequest()->getParam('chunk_id');
|
| 22 |
// Get orders from the Database
|
| 23 |
-
$orders = $import->getOrders($chunkId);
|
| 24 |
// Send orders via API helper method
|
| 25 |
-
$helper->callBatchApi($orders);
|
| 26 |
$result['success'] = true;
|
| 27 |
} catch (Exception $e) {
|
| 28 |
Mage::logException($e);
|
| 18 |
$helper = Mage::helper('metrilo_analytics');
|
| 19 |
try {
|
| 20 |
$import = Mage::getSingleton('metrilo_analytics/import');
|
| 21 |
+
$storeId = (int)$this->getRequest()->getParam('store_id');
|
| 22 |
$chunkId = (int)$this->getRequest()->getParam('chunk_id');
|
| 23 |
// Get orders from the Database
|
| 24 |
+
$orders = $import->getOrders($storeId, $chunkId);
|
| 25 |
// Send orders via API helper method
|
| 26 |
+
$helper->callBatchApi($storeId, $orders);
|
| 27 |
$result['success'] = true;
|
| 28 |
} catch (Exception $e) {
|
| 29 |
Mage::logException($e);
|
app/code/community/Metrilo/Analytics/etc/config.xml
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
<config>
|
| 9 |
<modules>
|
| 10 |
<Metrilo_Analytics>
|
| 11 |
-
<version>1.1.
|
| 12 |
</Metrilo_Analytics>
|
| 13 |
</modules>
|
| 14 |
<frontend>
|
| 8 |
<config>
|
| 9 |
<modules>
|
| 10 |
<Metrilo_Analytics>
|
| 11 |
+
<version>1.1.7</version>
|
| 12 |
</Metrilo_Analytics>
|
| 13 |
</modules>
|
| 14 |
<frontend>
|
app/code/community/Metrilo/Analytics/etc/system.xml
CHANGED
|
@@ -79,4 +79,4 @@
|
|
| 79 |
</groups>
|
| 80 |
</metrilo_analytics_settings>
|
| 81 |
</sections>
|
| 82 |
-
</config>
|
| 79 |
</groups>
|
| 80 |
</metrilo_analytics_settings>
|
| 81 |
</sections>
|
| 82 |
+
</config>
|
app/design/adminhtml/default/default/template/metrilo/system/config/button.phtml
CHANGED
|
@@ -1,57 +1,73 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
jQuery.noConflict();
|
| 5 |
-
|
| 6 |
-
function import_metrilo() {
|
| 7 |
-
var total_chunks = <?php echo $import->getChunks(); ?>;
|
| 8 |
-
var chunk_percentage = 100;
|
| 9 |
-
if(total_chunks > 0){
|
| 10 |
-
var chunk_percentage = (100 / total_chunks);
|
| 11 |
-
}
|
| 12 |
-
// Update button state and text
|
| 13 |
-
jQuery('#metrilo_button').addClass('disabled').attr('disabled', 'disabled').text('Importing orders');
|
| 14 |
-
|
| 15 |
-
var sync_chunk = function(chunk_id){
|
| 16 |
-
progress_percents = Math.round(chunk_id * chunk_percentage);
|
| 17 |
-
update_importing_message('Please wait... '+progress_percents+'% done', true);
|
| 18 |
-
|
| 19 |
-
// add form_key for magento controller check
|
| 20 |
-
data = {'chunk_id': chunk_id, 'form_key': window.FORM_KEY};
|
| 21 |
-
jQuery.post('<?php echo $this->getAjaxUrl(); ?>', data, function(response) {
|
| 22 |
-
new_chunk_id = chunk_id + 1;
|
| 23 |
-
if(new_chunk_id < total_chunks){
|
| 24 |
-
setTimeout(function() {
|
| 25 |
-
sync_chunk(new_chunk_id);
|
| 26 |
-
}, 100);
|
| 27 |
-
}else{
|
| 28 |
-
update_importing_message("<span style='color: green;'>Done! Please expect up to 30 minutes for your historical data to appear in Metrilo.</span>", false);
|
| 29 |
-
jQuery('#metrilo_button').removeClass('disabled').addClass('success').text('Orders imported');
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
});
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
<
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
<div
|
| 56 |
-
<div
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php if ($this->buttonEnabled()): ?>
|
| 2 |
+
<?php $import = $this->getImport(); ?>
|
| 3 |
+
<?php $storeId = $import->getStoreId(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
|
| 6 |
+
<script type="text/javascript">
|
| 7 |
+
jQuery.noConflict();
|
| 8 |
+
|
| 9 |
+
function import_metrilo() {
|
| 10 |
+
var store_id = <?php echo $storeId; ?>;
|
| 11 |
+
var total_chunks = <?php echo $import->getChunks($storeId); ?>;
|
| 12 |
+
var chunk_percentage = 100;
|
| 13 |
+
if(total_chunks > 0){
|
| 14 |
+
var chunk_percentage = (100 / total_chunks);
|
| 15 |
+
}
|
| 16 |
+
// Update button state and text
|
| 17 |
+
jQuery('#metrilo_button').addClass('disabled').attr('disabled', 'disabled').text('Importing orders');
|
| 18 |
+
|
| 19 |
+
var sync_chunk = function(chunk_id){
|
| 20 |
+
progress_percents = Math.round(chunk_id * chunk_percentage);
|
| 21 |
+
update_importing_message('Please wait... '+progress_percents+'% done', true);
|
| 22 |
|
| 23 |
+
// add form_key for magento controller check
|
| 24 |
+
data = {'store_id': store_id, 'chunk_id': chunk_id, 'form_key': window.FORM_KEY};
|
| 25 |
+
jQuery.post('<?php echo $this->getAjaxUrl(); ?>', data, function(response) {
|
| 26 |
+
new_chunk_id = chunk_id + 1;
|
| 27 |
+
if(new_chunk_id < total_chunks){
|
| 28 |
+
setTimeout(function() {
|
| 29 |
+
sync_chunk(new_chunk_id);
|
| 30 |
+
}, 100);
|
| 31 |
+
}else{
|
| 32 |
+
update_importing_message("<span style='color: green;'>Done! Please expect up to 30 minutes for your historical data to appear in Metrilo.</span>", false);
|
| 33 |
+
jQuery('#metrilo_button').removeClass('disabled').addClass('success').text('Orders imported');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
var update_importing_message = function(message, show_loader){
|
| 41 |
+
if (show_loader)
|
| 42 |
+
message = '<img src="<?php echo $this->getSkinUrl("metrilo/loader.gif"); ?>" />' + message;
|
| 43 |
+
jQuery('#metrilo_import_status').html(message);
|
| 44 |
+
}
|
| 45 |
+
sync_chunk(0);
|
| 46 |
}
|
| 47 |
+
</script>
|
| 48 |
+
|
| 49 |
+
<?php if ($this->showInStore()): ?>
|
| 50 |
+
<div style="float: left;">
|
| 51 |
+
<h3>Importing your orders and customers</h3>
|
| 52 |
+
<p>
|
| 53 |
+
This tool helps you sync all your orders and customers to Metrilo and can take <strong>up to 20 minutes</strong> to complete. <br />
|
| 54 |
+
It will not affect your website's performance at all since it sends your orders to your Metrilo account in small chunks. <br /><br />
|
| 55 |
+
Make sure to <strong>not close this page</strong> while importing. Coffee, maybe?
|
| 56 |
+
</p>
|
| 57 |
+
</div>
|
| 58 |
+
<div style="clear:both"></div>
|
| 59 |
+
<?php echo $this->getButtonHtml() ?>
|
| 60 |
+
<div style="clear:both"></div>
|
| 61 |
+
<div id="metrilo_import_status"></div>
|
| 62 |
+
<div style="clear:both"></div>
|
| 63 |
+
<?php else: ?>
|
| 64 |
+
<div style="float: left;">
|
| 65 |
+
<p>
|
| 66 |
+
In order to import your orders, please pick a store from
|
| 67 |
+
<strong>Current Configuration Scope</strong> on the top left
|
| 68 |
+
to make the import for the selected store.
|
| 69 |
+
</p>
|
| 70 |
+
</div>
|
| 71 |
+
<div style="clear:both"></div>
|
| 72 |
+
<?php endif; ?>
|
| 73 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/metrilo/head.phtml
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
<?php $helper = Mage::helper('metrilo_analytics'); ?>
|
|
|
|
|
|
|
| 2 |
<?php $events = $this->getEvents(); ?>
|
| 3 |
<script type="text/javascript">
|
| 4 |
window.metrilo||(window.metrilo=[]),window.metrilo.queue=[],window.metrilo.methods=["identify","track","event","pageview","purchase","debug","atr"],
|
|
@@ -6,7 +8,7 @@ window.metrilo.skelet=function(e){return function(){a=Array.prototype.slice.call
|
|
| 6 |
for(var i=0;window.metrilo.methods.length>i;i++){var mthd=window.metrilo.methods[i];window.metrilo[mthd]=window.metrilo.skelet(mthd)}
|
| 7 |
window.metrilo.load=function(e){var t=document,n=t.getElementsByTagName("script")[0],r=t.createElement("script");
|
| 8 |
r.type="text/javascript";r.async=true;r.src="//t.metrilo.com/j/"+e+".js";n.parentNode.insertBefore(r,n)};
|
| 9 |
-
metrilo.load("<?php echo $helper->getApiToken(); ?>");
|
| 10 |
|
| 11 |
<?php foreach ($events as $event) : ?>
|
| 12 |
<?php if($event['method'] == 'identify') : ?>
|
| 1 |
<?php $helper = Mage::helper('metrilo_analytics'); ?>
|
| 2 |
+
<?php $request = Mage::app()->getRequest(); ?>
|
| 3 |
+
<?php $storeId = $helper->getStoreId($request); ?>
|
| 4 |
<?php $events = $this->getEvents(); ?>
|
| 5 |
<script type="text/javascript">
|
| 6 |
window.metrilo||(window.metrilo=[]),window.metrilo.queue=[],window.metrilo.methods=["identify","track","event","pageview","purchase","debug","atr"],
|
| 8 |
for(var i=0;window.metrilo.methods.length>i;i++){var mthd=window.metrilo.methods[i];window.metrilo[mthd]=window.metrilo.skelet(mthd)}
|
| 9 |
window.metrilo.load=function(e){var t=document,n=t.getElementsByTagName("script")[0],r=t.createElement("script");
|
| 10 |
r.type="text/javascript";r.async=true;r.src="//t.metrilo.com/j/"+e+".js";n.parentNode.insertBefore(r,n)};
|
| 11 |
+
metrilo.load("<?php echo $helper->getApiToken($storeId); ?>");
|
| 12 |
|
| 13 |
<?php foreach ($events as $event) : ?>
|
| 14 |
<?php if($event['method'] == 'identify') : ?>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Metrilo_Analytics</name>
|
| 4 |
-
<version>1.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Apache Software License (ASL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -18,11 +18,11 @@
|
|
| 18 |
* Powerful intelligence for your sales team&#xD;
|
| 19 |
* With Metrilo, you have an amazing real-time overview of who's doing what on your eCommerce store.&#xD;
|
| 20 |
* Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
|
| 21 |
-
<notes>
|
| 22 |
<authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metirlo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author></authors>
|
| 23 |
<date>2016-06-16</date>
|
| 24 |
-
<time>
|
| 25 |
-
<contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="
|
| 26 |
<compatible/>
|
| 27 |
<dependencies><required><php><min>5.2.1</min><max>5.6.22</max></php></required></dependencies>
|
| 28 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Metrilo_Analytics</name>
|
| 4 |
+
<version>1.1.7</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>Apache Software License (ASL)</license>
|
| 7 |
<channel>community</channel>
|
| 18 |
* Powerful intelligence for your sales team&#xD;
|
| 19 |
* With Metrilo, you have an amazing real-time overview of who's doing what on your eCommerce store.&#xD;
|
| 20 |
* Metrilo automatically collects and analyzes your eCommerce data to use for your email campaigns.</description>
|
| 21 |
+
<notes>Multistore with separate imports and separate background order sync</notes>
|
| 22 |
<authors><author><name>Murry Ivanoff</name><user>Metrilo</user><email>murry@metrilo.com</email></author><author><name>Zhivko Draganov</name><user>zhivko</user><email>zhivko@metirlo.com</email></author><author><name>Miroslav Petrov</name><user>miro</user><email>miro91tn@gmail.com</email></author></authors>
|
| 23 |
<date>2016-06-16</date>
|
| 24 |
+
<time>20:07:42</time>
|
| 25 |
+
<contents><target name="magecommunity"><dir name="Metrilo"><dir name="Analytics"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="d080857c4ae4de4d9bb8bccae029a238"/></dir></dir></dir></dir><file name="Head.php" hash="8a638942f22453f34d4191aff820ffd5"/></dir><dir name="Helper"><file name="Asynchttpclient.php" hash="99d530582ba6407b604f377ad21eddc3"/><file name="Data.php" hash="db0bd2567102b54e17ead6dda9cd8b5b"/></dir><dir name="Model"><file name="Import.php" hash="a85251d30dba509ccf3e8b742fdf4385"/><file name="Observer.php" hash="35b53b63d89a51bc8a58a2def76100aa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AjaxController.php" hash="0a7205a952ffab171828eac9945eb539"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2fdab5ef85143c8c30f4c3bb15628f83"/><file name="config.xml" hash="fcdcc2a84e9860027164e1df5d14f62e"/><file name="system.xml" hash="f9d4a7a38b56e4f167299cdb52a35230"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="metrilo_analytics.xml" hash="0e6911e2e883992f2182969286d929b1"/></dir><dir name="template"><dir name="metrilo"><dir name="system"><dir name="config"><file name="button.phtml" hash="ae861308ebc1460950edcac10bf8024f"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="metrilo_analytics.xml" hash="c7dcf4057bc31d906865e82159ac5eca"/></dir><dir name="template"><dir name="metrilo"><file name="head.phtml" hash="8bc0f1562031c7061110477cba3d662f"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="metrilo"><file name="favicon-metrilo.png" hash="743558f1e49a730be9d515197a36567b"/><file name="loader.gif" hash="e05e6bb35d035cac4f3e0c8af213e9ab"/><file name="logo.png" hash="e9e54afd81384e12f77aca4eaebf5be8"/><file name="styles.css" hash="da0c07513d917e4ad08ff50814b536e1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Metrilo_Analytics.xml" hash="3a4dbecc4e093537f11dd4c8fa2756e7"/></dir></target></contents>
|
| 26 |
<compatible/>
|
| 27 |
<dependencies><required><php><min>5.2.1</min><max>5.6.22</max></php></required></dependencies>
|
| 28 |
</package>
|
