Skip to content

Commit

Permalink
Sync from Bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
fryckbos committed Nov 29, 2016
1 parent ad2fcdd commit bc7cef7
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function generate(Varien_Event_Observer $observer)

// Check if metric need to be reset after collection
if ($metricOrderDelete->resetOnCollect($metric->getKey())) {
$metric->delete();
$metric->setValue(0);
}
}
$logger->debugEnd('Metrics Collection');
Expand Down
45 changes: 31 additions & 14 deletions app/code/community/CoScale/Monitor/Model/Metric/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class CoScale_Monitor_Model_Metric_Order extends CoScale_Monitor_Model_Metric_Ab
const KEY_TIME_PENDING_PICKPACK = 2047;
const KEY_TIME_CURRENT_PICKPACK = 2048;

/**
* Identifier for abandoned carts
*/
const KEY_ABANDONED_CARTS = 2060;
const KEY_ABANDONED_CARTS_VALUE_TOTAL = 2061;

/**
* Public contructor function
*/
Expand Down Expand Up @@ -220,6 +226,18 @@ public function _contruct()
'combine' => true,
);

$this->_metricData[self::KEY_ABANDONED_CARTS] = array(
'name' => 'Abandonned carts',
'description' => 'Abandonned carts',
'unit' => 'orders',
);

$this->_metricData[self::KEY_ABANDONED_CARTS_VALUE_TOTAL] = array(
'name' => 'Total value of abandoned carts',
'description' => 'Total value of abandoned carts',
'unit' => 'Amount',
);

$this->statusPendingPickPack = Mage::getStoreConfig('system/coscale_monitor/status_pickpack_pending');
$this->statusPickPack = Mage::getStoreConfig('system/coscale_monitor/status_pickpack');
$this->statusCompletedPickPack = Mage::getStoreConfig('system/coscale_monitor/status_pickpack_completed');
Expand Down Expand Up @@ -268,6 +286,8 @@ public function initDefaultMetrics($storeId)
self::KEY_AVGTIME_PICKPACK,
self::KEY_TIME_PENDING_PICKPACK,
self::KEY_TIME_CURRENT_PICKPACK,
self::KEY_ABANDONED_CARTS,
self::KEY_ABANDONED_CARTS_VALUE_TOTAL,
);

$amountUnit = Mage::getStoreConfig('currency/options/base', $storeId);
Expand Down Expand Up @@ -785,26 +805,23 @@ public function getAbandonnedCarts()
foreach ($collection as $order) {
$amountUnit = Mage::getStoreConfig('currency/options/base', (int)$order->getStoreId());

$output[] = array(
'name' => 'Abandonned carts',
'unit' => 'orders',
'value' => (float)$order->getCount(),
'store_id' => (int)$order->getStoreId(),
'type' => 'A'
$this->setMetric(
self::ACTION_UPDATE,
self::KEY_ABANDONED_CARTS,
(int)$order->getStoreId(),
(float)$order->getCount()
);
$output[] = array(
'name' => 'Total value of abandoned carts',
'unit' => $amountUnit,
'value' => (float)$order->getSubtotal(),
'store_id' => (int)$order->getStoreId(),
'type' => 'A'

$this->setMetric(
self::ACTION_UPDATE,
self::KEY_ABANDONED_CARTS_VALUE_TOTAL,
(int)$order->getStoreId(),
(float)$order->getSubtotal()
);
}
return $output;
}



public function getEmailQueueSize()
{
$edition = method_exists('Mage', 'getEdition') ? Mage::getEdition():false;
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/CoScale/Monitor/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<CoScale_Monitor>
<version>0.16.0</version>
<version>0.17.0</version>
</CoScale_Monitor>
</modules>
<global>
Expand Down
38 changes: 38 additions & 0 deletions shell/coscale_reset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

require_once 'abstract.php';

/**
* CoScale shell script that will reset the different elements of the module
*
* @package CoScale_Monitor
* @author Mihai Oprea <[email protected]>
* @created 2016-08-11
* @version 1.0
*/
class CoScale_Reset extends Mage_Shell_Abstract
{
/**
* Execute the script
*/
public function run()
{
$helper = Mage::helper('coscale_monitor');

// Reset data
try {
$helper->debugStart('Metrics reset');
Mage::getResourceModel('coscale_monitor/metric')->truncate();

Mage::getSingleton('coscale_monitor/metric_order')->initOrderData();
Mage::getSingleton('coscale_monitor/metric_customer')->updateTotalCount();
Mage::getSingleton('coscale_monitor/metric_product')->updateTotalCount();
$helper->debugEnd('Metrics reset');
} catch (Exception $ex) {
$helper->debugEndError('Reset script', $ex);
}
}
}

$shell = new CoScale_Reset();
$shell->run();

0 comments on commit bc7cef7

Please sign in to comment.