Skip to content

Commit 94841e9

Browse files
dev
1 parent e75bc33 commit 94841e9

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

src/controllers/StoreProductController.php

+40
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,20 @@ public function actions()
483483
"services" => [
484484
'class' => ViewBackendAction::class,
485485
'priority' => 90,
486+
'name' => 'Создание товаров',
487+
'icon' => 'fas fa-info-circle',
488+
'accessCallback' => function () {
489+
if (\Yii::$app->user->can(CmsManager::PERMISSION_ROLE_ADMIN_ACCESS)) {
490+
return true;
491+
}
492+
493+
return false;
494+
},
495+
],
496+
497+
"other" => [
498+
'class' => ViewBackendAction::class,
499+
'priority' => 100,
486500
'name' => 'Инструменты',
487501
'icon' => 'fas fa-info-circle',
488502
'accessCallback' => function () {
@@ -606,6 +620,32 @@ public function actions()
606620
}
607621

608622

623+
public function actionQuantityZero()
624+
{
625+
Skeeks::unlimited();
626+
627+
$rr = new RequestResponse();
628+
if ($rr->isRequestAjaxPost()) {
629+
$rr->success = true;
630+
631+
if (!\Yii::$app->shop->backendShopStore) {
632+
$rr->message = "Ошибка";
633+
$rr->success = false;
634+
return $rr;
635+
}
636+
637+
$result = ShopStoreProduct::updateAll([
638+
'quantity' => 0
639+
], [
640+
'shop_store_id' => \Yii::$app->shop->backendShopStore->id
641+
]);
642+
643+
$rr->message = "Обнулено: {$result} товаров.";
644+
}
645+
646+
return $rr;
647+
}
648+
609649
public function actionAutoCreate()
610650
{
611651
Skeeks::unlimited();

src/views/store-product/other.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @link https://cms.skeeks.com/
4+
* @copyright Copyright (c) 2010 SkeekS
5+
* @license https://cms.skeeks.com/license/
6+
* @author Semenov Alexander <semenov@skeeks.com>
7+
*/
8+
/**
9+
* @var $this yii\web\View
10+
* @var $context \skeeks\cms\backend\BackendAction
11+
*/
12+
$context = $this->context;
13+
14+
$backendUrl = \yii\helpers\Url::to(['quantity-zero']);
15+
16+
$this->registerJs(<<<JS
17+
18+
$(".btn-quantity-zero").on("click", function() {
19+
var ajaxQuery = sx.ajax.preparePostQuery("{$backendUrl}");
20+
21+
new sx.classes.AjaxHandlerStandartRespose(ajaxQuery, {
22+
'blockerSelector' : 'body',
23+
'enableBlocker' : true,
24+
}).on("success", function(e, response) {
25+
26+
});
27+
28+
ajaxQuery.execute();
29+
});
30+
31+
JS
32+
);
33+
34+
?>
35+
<div class="sx-bg-secondary" style="padding: 10px; max-width: 500px;">
36+
<button class="btn btn-primary btn-quantity-zero">Обнулить количество</button>
37+
</div>
38+

0 commit comments

Comments
 (0)