|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Ecommerce admin controller |
|
5
|
|
|
* |
|
6
|
|
|
* @author Alexey Krupskiy <[email protected]> |
|
7
|
|
|
* @link http://inji.ru/ |
|
8
|
|
|
* @copyright 2015 Alexey Krupskiy |
|
9
|
|
|
* @license https://github.com/injitools/cms-Inji/blob/master/LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
class EcommerceController extends adminController { |
|
12
|
|
|
|
|
13
|
|
|
public function dashboardAction() { |
|
14
|
|
|
$this->view->setTitle('Онлайн магазин'); |
|
15
|
|
|
$this->view->page(); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function configureAction() { |
|
19
|
|
|
if (!empty($_POST['config'])) { |
|
20
|
|
|
$config = App::$cur->ecommerce->config; |
|
21
|
|
|
$config['view_empty_warehouse'] = empty($_POST['config']['view_empty_warehouse']) ? false : true; |
|
22
|
|
|
$config['view_empty_image'] = empty($_POST['config']['view_empty_image']) ? false : true; |
|
23
|
|
|
$config['sell_empty_warehouse'] = empty($_POST['config']['sell_empty_warehouse']) ? false : true; |
|
24
|
|
|
$config['sell_over_warehouse'] = empty($_POST['config']['sell_over_warehouse']) ? false : true; |
|
25
|
|
|
$config['notify_mail'] = $_POST['config']['notify_mail']; |
|
26
|
|
|
$config['defaultCategoryView'] = $_POST['config']['defaultCategoryView']; |
|
27
|
|
|
$config['defaultCurrency'] = $_POST['config']['defaultCurrency']; |
|
28
|
|
|
$config['orderPrefix'] = $_POST['config']['orderPrefix']; |
|
29
|
|
|
$config['show_zero_price'] = empty($_POST['config']['show_zero_price']) ? false : true; |
|
30
|
|
|
$config['show_without_price'] = empty($_POST['config']['show_without_price']) ? false : true; |
|
31
|
|
|
$config['filtersInLast'] = empty($_POST['config']['filtersInLast']) ? false : true; |
|
32
|
|
|
$config['defaultNeedDelivery'] = empty($_POST['config']['defaultNeedDelivery']) ? false : true; |
|
33
|
|
|
Config::save('module', $config, 'Ecommerce'); |
|
34
|
|
|
Tools::redirect('/admin/ecommerce/configure', 'Настройки были изменены', 'success'); |
|
35
|
|
|
} |
|
36
|
|
|
$managers = [ |
|
37
|
|
|
'Ecommerce\Delivery', |
|
38
|
|
|
'Ecommerce\PayType', |
|
39
|
|
|
'Ecommerce\Warehouse', |
|
40
|
|
|
'Ecommerce\Unit', |
|
41
|
|
|
'Ecommerce\Card', |
|
42
|
|
|
'Ecommerce\Discount', |
|
43
|
|
|
'Ecommerce\Cart\Stage', |
|
44
|
|
|
'Ecommerce\Item\Type', |
|
45
|
|
|
'Ecommerce\Item\Option', |
|
46
|
|
|
'Ecommerce\Item\Offer\Option', |
|
47
|
|
|
'Ecommerce\Item\Offer\Price\Type', |
|
48
|
|
|
'Ecommerce\UserAdds\Field', |
|
49
|
|
|
'Ecommerce\Cart\Status', |
|
50
|
|
|
'Ecommerce\Delivery\Field', |
|
51
|
|
|
'Ecommerce\Delivery\Provider', |
|
52
|
|
|
]; |
|
53
|
|
|
$this->view->setTitle('Настройки магазина'); |
|
54
|
|
|
$this->view->page(['data' => compact('managers')]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function reBlockIndexAction() { |
|
58
|
|
|
set_time_limit(0); |
|
59
|
|
|
$carts = Cart::getList(); |
|
60
|
|
|
foreach ($carts as $cart) { |
|
61
|
|
|
$cart->save(); |
|
62
|
|
|
} |
|
63
|
|
|
Tools::redirect('/admin/ecommerce/configure', 'Данные о блокировках обновлены'); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function reSearchIndexAction($i = 0) { |
|
67
|
|
|
set_time_limit(0); |
|
68
|
|
|
$count = 100; |
|
69
|
|
|
$items = Ecommerce\Item::getList(['start' => $i * $count, 'limit' => $count]); |
|
70
|
|
|
if (!$items) { |
|
71
|
|
|
Tools::redirect('/admin/ecommerce/configure', 'Поисковый индекс обновлен'); |
|
72
|
|
|
} else { |
|
73
|
|
|
$i++; |
|
74
|
|
|
foreach ($items as $key => $item) { |
|
75
|
|
|
$item->save(); |
|
76
|
|
|
unset($items[$key]); |
|
77
|
|
|
unset($item); |
|
78
|
|
|
} |
|
79
|
|
|
echo 'Происходит процесс индексации: проиндексировано ' . $i * $count; |
|
80
|
|
|
Tools::redirect('/admin/ecommerce/reSearchIndex/' . $i); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function newOrdersSubscribeAction() { |
|
85
|
|
|
$this->Notifications->subscribe('Ecommerce-orders'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function closeCartAction($cartId = 0) { |
|
89
|
|
|
$cart = Ecommerce\Cart::get((int) $cartId); |
|
90
|
|
|
$result = new Server\Result(); |
|
91
|
|
|
if ($cart && $cart->cart_status_id != 5) { |
|
92
|
|
|
$cart->cart_status_id = 5; |
|
93
|
|
|
$cart->save(); |
|
94
|
|
|
$result->successMsg = 'Заказ был завершен'; |
|
95
|
|
|
$result->send(); |
|
96
|
|
|
} |
|
97
|
|
|
$result->success = false; |
|
98
|
|
|
$result->content = 'Такая корзина не найдена'; |
|
99
|
|
|
$result->send(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
} |