Version Notes
Added: - abandoned carts
Fixed: - stats performance
- thumbnails
Download this release
Release Info
| Developer | eMagicOne |
| Extension | mobile_assistant_connector |
| Version | 1.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.13 to 1.1.0
app/code/community/Emagicone/Mobassistantconnector/controllers/IndexController.php
CHANGED
|
@@ -26,7 +26,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 26 |
public $def_currency;
|
| 27 |
public $currency_code;
|
| 28 |
const GSM_URL = 'https://android.googleapis.com/gcm/send';
|
| 29 |
-
const MB_VERSION = '$Revision:
|
| 30 |
|
| 31 |
public function indexAction() {
|
| 32 |
Mage::app()->cleanCache();
|
|
@@ -47,7 +47,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 47 |
}
|
| 48 |
|
| 49 |
if(!$this->check_auth()) {
|
| 50 |
-
|
| 51 |
}
|
| 52 |
|
| 53 |
$request_params = Mage::app()->getRequest()->getParams();
|
|
@@ -98,7 +98,12 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 98 |
'push_order_statuses' => 'STR',
|
| 99 |
'currency_code' => 'STR',
|
| 100 |
'is_mail' => 'INT',
|
| 101 |
-
'store_group_id' => 'INT'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
));
|
| 103 |
|
| 104 |
foreach($params as $k => $value) {
|
|
@@ -451,6 +456,12 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 451 |
$ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '" . (date('Y-m-d H:i:s', (strtotime($date_to)))) ."'"));
|
| 452 |
}
|
| 453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
/*
|
| 455 |
if(!empty($date_from) && !empty($date_to)) {
|
| 456 |
$ordersCollection->addFieldToFilter('main_table.created_at',
|
|
@@ -462,10 +473,10 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 462 |
|
| 463 |
// var_dump($ordersCollection->getSelect()->__toString());die();
|
| 464 |
|
| 465 |
-
$ordersSum =
|
| 466 |
-
$
|
| 467 |
-
|
| 468 |
-
|
| 469 |
|
| 470 |
$nice_nm = $this->bd_nice_number($ordersSum);
|
| 471 |
|
|
@@ -503,7 +514,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 503 |
if(strlen($this->statuses) > 0) {
|
| 504 |
$salesCollection->getSelect()->where(new Zend_Db_Expr("order.status IN ({$this->statuses})"));
|
| 505 |
}
|
| 506 |
-
$store_stats['count_products'] = $this->bd_nice_number($salesCollection->
|
| 507 |
|
| 508 |
$salesCollection->setOrder('item_id','DESC');
|
| 509 |
|
|
@@ -513,6 +524,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 513 |
$ordersCollection->addAttributeToFilter('entity_id', array('gt' => intval($this->last_order_id)));
|
| 514 |
|
| 515 |
$ordersCollection->setOrder('entity_id','DESC');
|
|
|
|
| 516 |
|
| 517 |
$lastOrder = $ordersCollection->getFirstItem();
|
| 518 |
|
|
@@ -1156,7 +1168,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 1156 |
$thumbnail = $orderItem->getProduct()->getMediaConfig()->getMediaUrl($thumbnail_path);
|
| 1157 |
|
| 1158 |
if(($thumbnail_path == 'no_selection') || (!isset($thumbnail_path))) {
|
| 1159 |
-
$
|
| 1160 |
}
|
| 1161 |
|
| 1162 |
$orderItem = $orderItem->toArray();
|
|
@@ -1748,7 +1760,6 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 1748 |
$row_page['count_ords'] = $ordersCollection->count();
|
| 1749 |
|
| 1750 |
$ordersSum = $this->bd_nice_number($ordersSum);
|
| 1751 |
-
// $row_page['sum_ords'] = $this->_price_format($this->def_currency, 1, $ordersSum, 0, 0);
|
| 1752 |
$row_page['sum_ords'] = $this->_price_format($this->def_currency, 1, $ordersSum, $this->currency_code, 0);
|
| 1753 |
|
| 1754 |
if(!empty($this->page) && !empty($this->show)) {
|
|
@@ -2039,7 +2050,7 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 2039 |
foreach ($salesCollection as $order) {
|
| 2040 |
$thumbnail_path = $order->getProduct()->getThumbnail();
|
| 2041 |
$thumbnail = $order->getProduct()->getMediaConfig()->getMediaUrl($thumbnail_path);
|
| 2042 |
-
|
| 2043 |
if(($thumbnail_path == 'no_selection') || (!isset($thumbnail_path))) {
|
| 2044 |
$thumbnail = '';
|
| 2045 |
}
|
|
@@ -2053,7 +2064,9 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 2053 |
} else {
|
| 2054 |
unset($ord_prodArr['orig_price']);
|
| 2055 |
}
|
|
|
|
| 2056 |
unset($ord_prodArr['product']);
|
|
|
|
| 2057 |
$ord_prodArr['quantity'] = intval($ord_prodArr['quantity']);
|
| 2058 |
$ord_prodArr['order_id'] = $ord_prodArr['main_id'];
|
| 2059 |
$ord_prodArr['type_id'] = ucfirst($ord_prodArr['type_id']);
|
|
@@ -2187,6 +2200,341 @@ class Emagicone_Mobassistantconnector_IndexController extends Mage_Core_Controll
|
|
| 2187 |
return $this->_flatEnabled[$this->getStoreId()];
|
| 2188 |
}
|
| 2189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2190 |
|
| 2191 |
protected function _price_format($iso_code, $curr_format, $price, $convert_to, $force = false, $format = true) {
|
| 2192 |
$currency_symbol = '';
|
| 26 |
public $def_currency;
|
| 27 |
public $currency_code;
|
| 28 |
const GSM_URL = 'https://android.googleapis.com/gcm/send';
|
| 29 |
+
const MB_VERSION = '$Revision: 83 $';
|
| 30 |
|
| 31 |
public function indexAction() {
|
| 32 |
Mage::app()->cleanCache();
|
| 47 |
}
|
| 48 |
|
| 49 |
if(!$this->check_auth()) {
|
| 50 |
+
$this->generate_output('auth_error');
|
| 51 |
}
|
| 52 |
|
| 53 |
$request_params = Mage::app()->getRequest()->getParams();
|
| 98 |
'push_order_statuses' => 'STR',
|
| 99 |
'currency_code' => 'STR',
|
| 100 |
'is_mail' => 'INT',
|
| 101 |
+
'store_group_id' => 'INT',
|
| 102 |
+
'carts_from' => 'STR',
|
| 103 |
+
'carts_to' => 'STR',
|
| 104 |
+
'cart_id' => 'STR',
|
| 105 |
+
'search_carts' => 'STR',
|
| 106 |
+
'show_unregistered_customers' => 'INT',
|
| 107 |
));
|
| 108 |
|
| 109 |
foreach($params as $k => $value) {
|
| 456 |
$ordersCollection->getSelect()->where(new Zend_Db_Expr("(CONVERT_TZ(main_table.created_at, '+00:00', '".$offset."')) <= '" . (date('Y-m-d H:i:s', (strtotime($date_to)))) ."'"));
|
| 457 |
}
|
| 458 |
|
| 459 |
+
$ordersCollection->getSelect()->columns('SUM(base_grand_total) as sum_base_grand_total,COUNT(*) AS count_orders');
|
| 460 |
+
|
| 461 |
+
// $ordersCollection->getSelect()->limit(1);
|
| 462 |
+
|
| 463 |
+
$first = $ordersCollection->getFirstItem();
|
| 464 |
+
|
| 465 |
/*
|
| 466 |
if(!empty($date_from) && !empty($date_to)) {
|
| 467 |
$ordersCollection->addFieldToFilter('main_table.created_at',
|
| 473 |
|
| 474 |
// var_dump($ordersCollection->getSelect()->__toString());die();
|
| 475 |
|
| 476 |
+
$ordersSum = $first['sum_base_grand_total'];
|
| 477 |
+
// $ordersSum = array_sum($ordersCollection->getColumnValues('base_grand_total'));
|
| 478 |
+
// $row['count_orders'] = $ordersCollection->getSize();
|
| 479 |
+
$row['count_orders'] = $first['count_orders'];
|
| 480 |
|
| 481 |
$nice_nm = $this->bd_nice_number($ordersSum);
|
| 482 |
|
| 514 |
if(strlen($this->statuses) > 0) {
|
| 515 |
$salesCollection->getSelect()->where(new Zend_Db_Expr("order.status IN ({$this->statuses})"));
|
| 516 |
}
|
| 517 |
+
$store_stats['count_products'] = $this->bd_nice_number($salesCollection->getSize(), true);
|
| 518 |
|
| 519 |
$salesCollection->setOrder('item_id','DESC');
|
| 520 |
|
| 524 |
$ordersCollection->addAttributeToFilter('entity_id', array('gt' => intval($this->last_order_id)));
|
| 525 |
|
| 526 |
$ordersCollection->setOrder('entity_id','DESC');
|
| 527 |
+
$ordersCollection->getSelect()->limit(1);
|
| 528 |
|
| 529 |
$lastOrder = $ordersCollection->getFirstItem();
|
| 530 |
|
| 1168 |
$thumbnail = $orderItem->getProduct()->getMediaConfig()->getMediaUrl($thumbnail_path);
|
| 1169 |
|
| 1170 |
if(($thumbnail_path == 'no_selection') || (!isset($thumbnail_path))) {
|
| 1171 |
+
$thumbnail = '';
|
| 1172 |
}
|
| 1173 |
|
| 1174 |
$orderItem = $orderItem->toArray();
|
| 1760 |
$row_page['count_ords'] = $ordersCollection->count();
|
| 1761 |
|
| 1762 |
$ordersSum = $this->bd_nice_number($ordersSum);
|
|
|
|
| 1763 |
$row_page['sum_ords'] = $this->_price_format($this->def_currency, 1, $ordersSum, $this->currency_code, 0);
|
| 1764 |
|
| 1765 |
if(!empty($this->page) && !empty($this->show)) {
|
| 2050 |
foreach ($salesCollection as $order) {
|
| 2051 |
$thumbnail_path = $order->getProduct()->getThumbnail();
|
| 2052 |
$thumbnail = $order->getProduct()->getMediaConfig()->getMediaUrl($thumbnail_path);
|
| 2053 |
+
|
| 2054 |
if(($thumbnail_path == 'no_selection') || (!isset($thumbnail_path))) {
|
| 2055 |
$thumbnail = '';
|
| 2056 |
}
|
| 2064 |
} else {
|
| 2065 |
unset($ord_prodArr['orig_price']);
|
| 2066 |
}
|
| 2067 |
+
|
| 2068 |
unset($ord_prodArr['product']);
|
| 2069 |
+
|
| 2070 |
$ord_prodArr['quantity'] = intval($ord_prodArr['quantity']);
|
| 2071 |
$ord_prodArr['order_id'] = $ord_prodArr['main_id'];
|
| 2072 |
$ord_prodArr['type_id'] = ucfirst($ord_prodArr['type_id']);
|
| 2200 |
return $this->_flatEnabled[$this->getStoreId()];
|
| 2201 |
}
|
| 2202 |
|
| 2203 |
+
protected function get_abandoned_carts_list() {
|
| 2204 |
+
$abandoned_carts = array();
|
| 2205 |
+
$offset = $this->_get_timezone_offset();
|
| 2206 |
+
|
| 2207 |
+
|
| 2208 |
+
$storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
|
| 2209 |
+
$customerTableName = Mage::getSingleton('core/resource')->getTableName('customer_entity');
|
| 2210 |
+
|
| 2211 |
+
$quotes = Mage::getResourceModel('sales/quote_collection');
|
| 2212 |
+
|
| 2213 |
+
if (!isset($this->group_id)) {
|
| 2214 |
+
if($this->is_group_exists($this->group_id)) {
|
| 2215 |
+
$quotes->getSelect()
|
| 2216 |
+
->joinLeft(
|
| 2217 |
+
array('cs' => $storeTableName),
|
| 2218 |
+
"cs.store_id = main_table.store_id",
|
| 2219 |
+
array());
|
| 2220 |
+
$quotes->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
|
| 2221 |
+
}
|
| 2222 |
+
}
|
| 2223 |
+
|
| 2224 |
+
if (!empty($this->search_carts)) {
|
| 2225 |
+
$this->search_val = $this->search_carts;
|
| 2226 |
+
}
|
| 2227 |
+
if (!empty($this->search_val) && preg_match('/^\d+(?:,\d+)*$/', $this->search_val)) {
|
| 2228 |
+
$quotes->addAttributeToFilter('main_table.entity_id', array('eq' => intval($this->search_val)));
|
| 2229 |
+
} else if(!empty($this->search_val)) {
|
| 2230 |
+
$quotes->getSelect()->where("main_table.`customer_email` LIKE '%".$this->search_val."%' OR main_table.`customer_firstname` LIKE '%".$this->search_val."%' OR main_table.`customer_lastname` LIKE '%".$this->search_val."%' OR CONCAT(`customer_firstname`, ' ', `customer_lastname`) LIKE '%".$this->search_val."%'");
|
| 2231 |
+
}
|
| 2232 |
+
|
| 2233 |
+
if (!empty($this->carts_from)) {
|
| 2234 |
+
$this->carts_from = Mage::getModel('core/date')->timestamp(strtotime($this->carts_from));
|
| 2235 |
+
$this->carts_from = date('Y-m-d H:i:s', $this->carts_from);
|
| 2236 |
+
$quotes->addFieldToFilter('main_table.updated_at', array('from' => $this->carts_from));
|
| 2237 |
+
}
|
| 2238 |
+
|
| 2239 |
+
if (!empty($this->carts_to)) {
|
| 2240 |
+
$this->carts_to = Mage::getModel('core/date')->timestamp(strtotime($this->carts_to));
|
| 2241 |
+
$this->carts_to = date('Y-m-d H:i:s', $this->carts_to);
|
| 2242 |
+
$quotes->addFieldToFilter('main_table.updated_at', array('to' => $this->carts_to));
|
| 2243 |
+
}
|
| 2244 |
+
|
| 2245 |
+
// if (!empty($this->with_customer_details)) {
|
| 2246 |
+
$quotes->addFieldToFilter('main_table.customer_email', array('notnull' => true));
|
| 2247 |
+
// }
|
| 2248 |
+
|
| 2249 |
+
if (empty($this->show_unregistered_customers)) {
|
| 2250 |
+
$quotes->addFieldToFilter('main_table.customer_id', array('notnull' => true));
|
| 2251 |
+
$quotes->getSelect()
|
| 2252 |
+
->joinInner(
|
| 2253 |
+
array('c' => $customerTableName),
|
| 2254 |
+
"c.entity_id = main_table.customer_id",
|
| 2255 |
+
array());
|
| 2256 |
+
}
|
| 2257 |
+
|
| 2258 |
+
$quotes->addFieldToFilter('main_table.is_active', array('eq' => 1));
|
| 2259 |
+
$quotes->addFieldToFilter('main_table.items_count', array('gt' => 0));
|
| 2260 |
+
|
| 2261 |
+
// $quotes->load();
|
| 2262 |
+
$cart_total_res['total_sum'] = $this->_price_format($this->def_currency, 1, array_sum($quotes->getColumnValues('base_grand_total')), $this->currency_code);
|
| 2263 |
+
$cart_total_res['total_count'] = $quotes->getSize();
|
| 2264 |
+
// $resource = Mage::getSingleton('core/resource');
|
| 2265 |
+
// $readConnection = $resource->getConnection('core_read');
|
| 2266 |
+
// $cart_total_res['total_count'] = $readConnection->fetchOne($quotes->getSelectCountSql());
|
| 2267 |
+
|
| 2268 |
+
// $quotes->clear();
|
| 2269 |
+
|
| 2270 |
+
if(!empty($this->page) && !empty($this->show)) {
|
| 2271 |
+
$quotes->clear();
|
| 2272 |
+
$quotes->getSelect()->limit($this->show, ($this->page-1)*$this->show);
|
| 2273 |
+
}
|
| 2274 |
+
|
| 2275 |
+
switch ($this->sort_by) {
|
| 2276 |
+
case 'id':
|
| 2277 |
+
$quotes->getSelect()->order( array('main_table'.'.entity_id DESC'));
|
| 2278 |
+
break;
|
| 2279 |
+
case 'date':
|
| 2280 |
+
$quotes->getSelect()->order( array('main_table'.'.updated_at DESC'));
|
| 2281 |
+
break;
|
| 2282 |
+
case 'name':
|
| 2283 |
+
$quotes->getSelect()->order( array('main_table'.'.customer_firstname ASC'));
|
| 2284 |
+
break;
|
| 2285 |
+
default:
|
| 2286 |
+
$quotes->getSelect()->order( array('main_table'.'.updated_at DESC'));
|
| 2287 |
+
break;
|
| 2288 |
+
}
|
| 2289 |
+
$carts = array();
|
| 2290 |
+
// $collection->prepareForAbandonedReport();
|
| 2291 |
+
foreach ($quotes as $quote) {
|
| 2292 |
+
if (empty($this->show_unregistered_customers)) {
|
| 2293 |
+
// Show only real customers
|
| 2294 |
+
$customer_id = $quote->getCustomer()->getId();
|
| 2295 |
+
if(empty($customer_id)) {
|
| 2296 |
+
continue;
|
| 2297 |
+
}
|
| 2298 |
+
}
|
| 2299 |
+
|
| 2300 |
+
$cart['id_cart'] = $quote->getEntityId();
|
| 2301 |
+
|
| 2302 |
+
$dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($quote->getUpdatedAt()));
|
| 2303 |
+
$cart['date_add'] = date('Y-m-d H:i:s', $dateTimestamp);
|
| 2304 |
+
|
| 2305 |
+
$cart['id_shop'] = $quote->getStoreId();
|
| 2306 |
+
$cart['id_currency'] = $quote->getBaseCurrenceCode();
|
| 2307 |
+
$cart['id_customer'] = $quote->getCustomerId();
|
| 2308 |
+
|
| 2309 |
+
$cart['email'] = $quote->getCustomerEmail();
|
| 2310 |
+
$cart['customer'] = $quote->getCustomerFirstname() . ' ' .$quote->getCustomerLastname();
|
| 2311 |
+
|
| 2312 |
+
if(!is_null($quote->getCustomer()->getId())){
|
| 2313 |
+
$cart['email'] = $quote->getCustomer()->getEmail();
|
| 2314 |
+
$cart['customer'] = $quote->getCustomer()->getFirstname() . ' ' .$quote->getCustomer()->getLastname();
|
| 2315 |
+
}
|
| 2316 |
+
|
| 2317 |
+
if ($storeName = Mage::getModel('core/store')->load($quote->getStoreId())->getName())
|
| 2318 |
+
$cart['shop_name'] = $storeName;
|
| 2319 |
+
else
|
| 2320 |
+
$cart['shop_name'] = '';
|
| 2321 |
+
|
| 2322 |
+
$cart['carrier_name'] = $quote->getEntityId();
|
| 2323 |
+
// $cart['cart_total'] = $quote->getBaseGrandTotal();
|
| 2324 |
+
$cart['cart_total'] = $quote->getBaseSubtotalWithDiscount();
|
| 2325 |
+
|
| 2326 |
+
$cart['cart_total'] = $this->_price_format($this->def_currency, 3, $cart['cart_total'], $this->currency_code);
|
| 2327 |
+
|
| 2328 |
+
$cart['cart_count_products'] = $quote->getItemsCount();
|
| 2329 |
+
|
| 2330 |
+
$carts[] = $cart;
|
| 2331 |
+
}
|
| 2332 |
+
|
| 2333 |
+
// Sort by name
|
| 2334 |
+
if($this->sort_by == 'name') {
|
| 2335 |
+
foreach($carts as $cart){
|
| 2336 |
+
foreach($cart as $key=>$value){
|
| 2337 |
+
if(!isset($sortArray[$key])){
|
| 2338 |
+
$sortArray[$key] = array();
|
| 2339 |
+
}
|
| 2340 |
+
$sortArray[$key][] = $value;
|
| 2341 |
+
}
|
| 2342 |
+
}
|
| 2343 |
+
|
| 2344 |
+
$orderby = "customer"; //change this to whatever key you want from the array
|
| 2345 |
+
|
| 2346 |
+
array_multisort($sortArray[$orderby],SORT_ASC,$carts);
|
| 2347 |
+
}
|
| 2348 |
+
|
| 2349 |
+
return array('abandoned_carts' => $carts,
|
| 2350 |
+
'abandoned_carts_count' => $cart_total_res['total_count'],
|
| 2351 |
+
'abandoned_carts_total' => $cart_total_res['total_sum'],
|
| 2352 |
+
);
|
| 2353 |
+
|
| 2354 |
+
return $quote;
|
| 2355 |
+
}
|
| 2356 |
+
|
| 2357 |
+
protected function get_abandoned_cart_details(){
|
| 2358 |
+
$cart_info = array();
|
| 2359 |
+
$cart_products = array();
|
| 2360 |
+
|
| 2361 |
+
if ((int)$this->cart_id < 1)
|
| 2362 |
+
return false;
|
| 2363 |
+
|
| 2364 |
+
$offset = $this->_get_timezone_offset();
|
| 2365 |
+
|
| 2366 |
+
$storeTableName = Mage::getSingleton('core/resource')->getTableName('core/store');
|
| 2367 |
+
|
| 2368 |
+
$quotes = Mage::getResourceModel('reports/quote_collection');
|
| 2369 |
+
|
| 2370 |
+
if (!isset($this->group_id)) {
|
| 2371 |
+
if($this->is_group_exists($this->group_id)) {
|
| 2372 |
+
$quotes->getSelect()
|
| 2373 |
+
->joinLeft(
|
| 2374 |
+
array('cs' => $storeTableName),
|
| 2375 |
+
"cs.store_id = main_table.store_id",
|
| 2376 |
+
array());
|
| 2377 |
+
$quotes->getSelect()->where(new Zend_Db_Expr("cs.group_id = " . $this->group_id));
|
| 2378 |
+
}
|
| 2379 |
+
}
|
| 2380 |
+
|
| 2381 |
+
if (!empty($this->cart_id) && preg_match('/^\d+(?:,\d+)*$/', $this->cart_id)) {
|
| 2382 |
+
$quotes->addFieldToFilter('entity_id', array('eq' => intval($this->cart_id)));
|
| 2383 |
+
}
|
| 2384 |
+
|
| 2385 |
+
// $quotes->addFieldToFilter('is_active', array('eq' => 1));
|
| 2386 |
+
// $quotes->addFieldToFilter('items_count', array('qt' => 1));
|
| 2387 |
+
|
| 2388 |
+
if(!empty($this->page) && !empty($this->show)) {
|
| 2389 |
+
$quotes->getSelect()->limit($this->show, ($this->page-1)*$this->show);
|
| 2390 |
+
}
|
| 2391 |
+
|
| 2392 |
+
foreach ($quotes as $quote) {
|
| 2393 |
+
$cart_info['id_currency'] = $quote->getQuoteCurrencyCode();
|
| 2394 |
+
|
| 2395 |
+
$cart_info['id_cart'] = $quote->getEntityId();
|
| 2396 |
+
$cart_info['id_shop'] = $quote->getStoreId();
|
| 2397 |
+
$cart_info['id_currency'] = $quote->getQuoteCurrencyCode();
|
| 2398 |
+
|
| 2399 |
+
$created_at_timestamp = Mage::getModel('core/date')->timestamp(strtotime($quote->getCreatedAt()));
|
| 2400 |
+
$cart_info['date_add'] = date('Y-m-d H:i:s', $created_at_timestamp);
|
| 2401 |
+
|
| 2402 |
+
$updated_at_timestamp = Mage::getModel('core/date')->timestamp(strtotime($quote->getUpdatedAt()));
|
| 2403 |
+
$cart_info['date_up'] = date('Y-m-d H:i:s', $updated_at_timestamp);
|
| 2404 |
+
|
| 2405 |
+
$cart_info['id_customer'] = $quote->getCustomerId();
|
| 2406 |
+
$cart_info['email'] = $quote->getCustomerEmail();
|
| 2407 |
+
$cart_info['customer'] = $quote->getCustomerFirstname() . ' ' .$quote->getCustomerLastname();
|
| 2408 |
+
|
| 2409 |
+
$cart_info['phone'] = '';
|
| 2410 |
+
|
| 2411 |
+
if(!is_null($quote->getCustomer()->getId())){
|
| 2412 |
+
$cart_info['email'] = $quote->getCustomer()->getEmail();
|
| 2413 |
+
$cart_info['customer'] = $quote->getCustomer()->getFirstname() . ' ' .$quote->getCustomer()->getLastname();
|
| 2414 |
+
$cart_info['account_registered'] = $quote->getCustomer()->getCreatedAt();
|
| 2415 |
+
$customer = Mage::getModel('customer/customer')->load($quote->getCustomer()->getId());
|
| 2416 |
+
$customerAddressId = $customer->getDefaultBilling();
|
| 2417 |
+
if($customerAddressId) {
|
| 2418 |
+
$address = Mage::getModel('customer/address')->load($customerAddressId)->toArray();
|
| 2419 |
+
if(count($address) > 1) {
|
| 2420 |
+
$cart_info['phone'] = $address['telephone'];
|
| 2421 |
+
}
|
| 2422 |
+
}
|
| 2423 |
+
} else {
|
| 2424 |
+
$cart_info['account_registered'] = $quote->getCreatedAt();
|
| 2425 |
+
}
|
| 2426 |
+
|
| 2427 |
+
$account_registered_timestamp = Mage::getModel('core/date')->timestamp(strtotime($cart_info['account_registered']));
|
| 2428 |
+
$cart_info['account_registered'] = date('Y-m-d H:i:s', $account_registered_timestamp);
|
| 2429 |
+
|
| 2430 |
+
if ($storeName = Mage::getModel('core/store')->load($quote->getStoreId())->getName())
|
| 2431 |
+
$cart_info['shop_name'] = $storeName;
|
| 2432 |
+
else
|
| 2433 |
+
$cart_info['shop_name'] = '';
|
| 2434 |
+
|
| 2435 |
+
$cart_info['carrier_name'] = $quote->getEntityId();
|
| 2436 |
+
// $cart_info['cart_total'] = $quote->getBaseGrandTotal();
|
| 2437 |
+
$cart_info['cart_total'] = $this->_price_format($this->def_currency, 3, $quote->getBaseSubtotalWithDiscount(), $this->currency_code);
|
| 2438 |
+
$cart_info['cart_count_products'] = $quote->getItemsCount();
|
| 2439 |
+
|
| 2440 |
+
$itemsCollection = $quote->getItemsCollection();
|
| 2441 |
+
foreach ($itemsCollection as $item) {
|
| 2442 |
+
if(!is_null($item->getParentItem())){
|
| 2443 |
+
continue;
|
| 2444 |
+
}
|
| 2445 |
+
$product = array();
|
| 2446 |
+
$product['option_ids'] = array();
|
| 2447 |
+
$product['id_product'] = $item->getProduct()->getEntityId();
|
| 2448 |
+
$product['product_name'] = $item->getName();
|
| 2449 |
+
$product['product_type'] = $item->getProductType();
|
| 2450 |
+
$product['product_quantity'] = $item->getQty();
|
| 2451 |
+
$product['sku'] = $item->getSku();
|
| 2452 |
+
$product['product_price'] = $item->getRowTotal();
|
| 2453 |
+
$product['product_price'] = $this->_price_format($this->def_currency, 3, $product['product_price'], $this->currency_code);
|
| 2454 |
+
|
| 2455 |
+
$thumbnail_path = $item->getProduct()->getThumbnail();
|
| 2456 |
+
$thumbnail = $item->getProduct()->getMediaConfig()->getMediaUrl($thumbnail_path);
|
| 2457 |
+
|
| 2458 |
+
if(($thumbnail_path == 'no_selection') || (!isset($thumbnail_path))) {
|
| 2459 |
+
$thumbnail = '';
|
| 2460 |
+
}
|
| 2461 |
+
$product['product_image'] = $thumbnail;
|
| 2462 |
+
|
| 2463 |
+
$buy_request = $item->getBuyRequest()->getData();
|
| 2464 |
+
|
| 2465 |
+
|
| 2466 |
+
if(isset($buy_request['super_attribute'])){
|
| 2467 |
+
$attribute_ids = $buy_request['super_attribute'];
|
| 2468 |
+
foreach ($attribute_ids as $att_id => $opt_id) {
|
| 2469 |
+
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($att_id);
|
| 2470 |
+
foreach($attribute->getSource()->getAllOptions() as $option) {
|
| 2471 |
+
if($option['value'] == $opt_id){
|
| 2472 |
+
$att[$attribute->getName()] = $option['label'];
|
| 2473 |
+
}
|
| 2474 |
+
}
|
| 2475 |
+
}
|
| 2476 |
+
|
| 2477 |
+
$product['prod_options'] = $att;
|
| 2478 |
+
}
|
| 2479 |
+
|
| 2480 |
+
$options = array();
|
| 2481 |
+
// Get option ids
|
| 2482 |
+
$item_options = $item->getOptions();
|
| 2483 |
+
|
| 2484 |
+
foreach($item_options as $option){
|
| 2485 |
+
$options[$option->getLabel] = $option->getValue();
|
| 2486 |
+
$code = $option->getCode();
|
| 2487 |
+
if($code == 'option_ids'){
|
| 2488 |
+
$dropdown_option_ids = explode(',', $option->getValue());
|
| 2489 |
+
|
| 2490 |
+
foreach ($dropdown_option_ids as $id) {
|
| 2491 |
+
$product['option_ids'][$id] = '';
|
| 2492 |
+
}
|
| 2493 |
+
}
|
| 2494 |
+
}
|
| 2495 |
+
|
| 2496 |
+
// Get option values ids
|
| 2497 |
+
foreach ($item_options as $option) {
|
| 2498 |
+
foreach ($product['option_ids'] as $option_id => $value) {
|
| 2499 |
+
if($option->getCode() == 'option_'.$option_id){
|
| 2500 |
+
$product['option_ids'][$option_id] = $option->getValue();
|
| 2501 |
+
}
|
| 2502 |
+
}
|
| 2503 |
+
|
| 2504 |
+
}
|
| 2505 |
+
|
| 2506 |
+
// Get option and values names
|
| 2507 |
+
unset($product['options']);
|
| 2508 |
+
// $product['prod_options'] = array();
|
| 2509 |
+
$product_options = $item->getProduct()->getOptions();
|
| 2510 |
+
foreach ($product_options as $option) {
|
| 2511 |
+
foreach ($product['option_ids'] as $option_id => $option_value) {
|
| 2512 |
+
if($option->getOptionId() == $option_id){
|
| 2513 |
+
$product['prod_options'][$option->getTitle()] = '';
|
| 2514 |
+
$option_values = $option->getValues();
|
| 2515 |
+
foreach ($option_values as $value) {
|
| 2516 |
+
if($value->getOptionTypeId() == $option_value){
|
| 2517 |
+
$product['prod_options'][$option->getTitle()] = $value->getTitle();
|
| 2518 |
+
// $product['prod_options'][$option->getTitle()]['price'] = $value->getPrice();
|
| 2519 |
+
}
|
| 2520 |
+
}
|
| 2521 |
+
|
| 2522 |
+
}
|
| 2523 |
+
}
|
| 2524 |
+
}
|
| 2525 |
+
unset($product['option_ids']);
|
| 2526 |
+
|
| 2527 |
+
$cart_products[] = $product;
|
| 2528 |
+
}
|
| 2529 |
+
|
| 2530 |
+
}
|
| 2531 |
+
|
| 2532 |
+
return array(
|
| 2533 |
+
'cart_info' => $cart_info,
|
| 2534 |
+
'cart_products' => $cart_products,
|
| 2535 |
+
'cart_products_count' => $cart_info['cart_count_products'],
|
| 2536 |
+
);
|
| 2537 |
+
}
|
| 2538 |
|
| 2539 |
protected function _price_format($iso_code, $curr_format, $price, $convert_to, $force = false, $format = true) {
|
| 2540 |
$currency_symbol = '';
|
package.xml
CHANGED
|
@@ -1,19 +1,20 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>mobile_assistant_connector</name>
|
| 4 |
-
<version>1.0
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GNU</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Mobile Assistant Connector</summary>
|
| 10 |
<description>Mobile Assistant Connector</description>
|
| 11 |
-
<notes>Added: -
|
| 12 |
-
-
|
|
|
|
| 13 |
<authors><author><name>eMagicOne</name><user>mobile</user><email>mobile@emagicone.com</email></author></authors>
|
| 14 |
-
<date>2015-03-
|
| 15 |
-
<time>
|
| 16 |
-
<contents><target name="magecommunity"><dir name="Emagicone"><dir name="Affiliate"><dir name="Model"><file name="Observer.php" hash="34f47695ff6a590f554331fd5ff38ce5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="76cc4c681e62263421f09fdbd94e9b91"/><file name="config.xml" hash="9d4d74e1322ab291275f92ef634ff6fd"/><file name="system.xml" hash="b2baadb73f35fe5a06548e312dcf0b52"/></dir></dir><dir name="Mobassistantconnector"><dir name="Helper"><file name="Data.php" hash="37602f03d9864833f0d306344ddff60f"/></dir><dir name="Model"><file name="Defpassword.php" hash="ab8f696fce0029f113986b83ddeb8232"/><file name="Login.php" hash="6c82713acedcf883203c6bf964a61016"/><file name="Observer.php" hash="bb18972490df3223aeb473d917a2acf4"/><file name="Order.php" hash="f3d5529e0504ea0265cb661e03f41109"/><file name="Password.php" hash="c8fe770cb05b7e45050c6549cb9d39a3"/></dir><dir name="controllers"><file name="IndexController.php" hash="
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min>1.0</min><max>3.0</max></extension><extension><name>json</name><min>1.0</min><max>3.0</max></extension><extension><name>date</name><min>1.0</min><max>3.0</max></extension></required></dependencies>
|
| 19 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>mobile_assistant_connector</name>
|
| 4 |
+
<version>1.1.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/gpl.html">GNU</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Mobile Assistant Connector</summary>
|
| 10 |
<description>Mobile Assistant Connector</description>
|
| 11 |
+
<notes>Added: - abandoned carts
|
| 12 |
+
Fixed: - stats performance
|
| 13 |
+
- thumbnails</notes>
|
| 14 |
<authors><author><name>eMagicOne</name><user>mobile</user><email>mobile@emagicone.com</email></author></authors>
|
| 15 |
+
<date>2015-03-24</date>
|
| 16 |
+
<time>16:20:17</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="Emagicone"><dir name="Affiliate"><dir name="Model"><file name="Observer.php" hash="34f47695ff6a590f554331fd5ff38ce5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="76cc4c681e62263421f09fdbd94e9b91"/><file name="config.xml" hash="9d4d74e1322ab291275f92ef634ff6fd"/><file name="system.xml" hash="b2baadb73f35fe5a06548e312dcf0b52"/></dir></dir><dir name="Mobassistantconnector"><dir name="Helper"><file name="Data.php" hash="37602f03d9864833f0d306344ddff60f"/></dir><dir name="Model"><file name="Defpassword.php" hash="ab8f696fce0029f113986b83ddeb8232"/><file name="Login.php" hash="6c82713acedcf883203c6bf964a61016"/><file name="Observer.php" hash="bb18972490df3223aeb473d917a2acf4"/><file name="Order.php" hash="f3d5529e0504ea0265cb661e03f41109"/><file name="Password.php" hash="c8fe770cb05b7e45050c6549cb9d39a3"/></dir><dir name="controllers"><file name="IndexController.php" hash="e9d990dd2f3b69ed8b67fe814e572294"/><dir name="adminhtml"><file name="IndexController.php" hash="ef5ca028e534cbf81b39a643885c9511"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="bd21488195715421d3beb6a512acd5b5"/><file name="config.xml" hash="a3369251198939eba20d2b0fc020b5c2"/><file name="system.xml" hash="916fe7ee643e4dcb15a5498219605896"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Emagicone_Mobassistantconnector.xml" hash="7bb654478173d96ad294000fc9625820"/></dir></target><target name="magelocale"><dir><dir name="en_GB"><file name="Emagicone_Mobassistantconnector.csv" hash="eaf733f81ff47627c4389d487c93709f"/><file name="__Emagicone_Mobassistantconnector.csv" hash="eaf733f81ff47627c4389d487c93709f"/></dir><dir name="en_US"><file name="Emagicone_Mobassistantconnector.csv" hash="510d79a25c0bfb7a096aab57d8c5b458"/><file name="__Emagicone_Mobassistantconnector.csv" hash="510d79a25c0bfb7a096aab57d8c5b458"/></dir><dir name="es_ES"><file name="Emagicone_Mobassistantconnector.csv" hash="acc37c432dd8b4134844291931b70fbf"/><file name="__Emagicone_Mobassistantconnector.csv" hash="acc37c432dd8b4134844291931b70fbf"/></dir><dir name="fr_FR"><file name="Emagicone_Mobassistantconnector.csv" hash="76c48723a6bbd59534781fd3c7f6d86e"/><file name="__Emagicone_Mobassistantconnector.csv" hash="76c48723a6bbd59534781fd3c7f6d86e"/></dir><dir name="ru_RU"><file name="Emagicone_Mobassistantconnector.csv" hash="2346397cbe029dcc724717b953a3f38c"/><file name="__Emagicone_Mobassistantconnector.csv" hash="2346397cbe029dcc724717b953a3f38c"/></dir><dir name="uk_UA"><file name="Emagicone_Mobassistantconnector.csv" hash="cad0e0c3ec7603e6b886d815357d1766"/><file name="__Emagicone_Mobassistantconnector.csv" hash="cad0e0c3ec7603e6b886d815357d1766"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mobassistantconnector.xml" hash="b5c4d423be8de0c5d73d64783dcb9a3c"/></dir><dir name="template"><dir name="mobassistantconnector"><file name="jsinit.phtml" hash="785c82b5cf6b2a7dc94a1436d1c9115f"/></dir></dir></dir></dir></dir></target></contents>
|
| 18 |
<compatible/>
|
| 19 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><extension><name>curl</name><min>1.0</min><max>3.0</max></extension><extension><name>json</name><min>1.0</min><max>3.0</max></extension><extension><name>date</name><min>1.0</min><max>3.0</max></extension></required></dependencies>
|
| 20 |
</package>
|
