forked from myjavawork/bb
/
ListingController.php
97 lines (75 loc) · 2.8 KB
/
ListingController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/*
* @copyright Copyright (c) 2013 by ESS-UA.
*/
class Ess_M2ePro_Adminhtml_ListingController
extends Ess_M2ePro_Controller_Adminhtml_BaseController
{
//#############################################
public function checkLockListingAction()
{
$listingId = (int)$this->getRequest()->getParam('id');
$component = $this->getRequest()->getParam('component');
$lockItemParams = array(
'id' => $listingId,
'component' => $component
);
$lockItem = Mage::getModel('M2ePro/Listing_LockItem',$lockItemParams);
if ($lockItem->isExist()) {
return $this->getResponse()->setBody('locked');
}
return $this->getResponse()->setBody('unlocked');
}
public function lockListingNowAction()
{
$listingId = (int)$this->getRequest()->getParam('id');
$component = $this->getRequest()->getParam('component');
$lockItemParams = array(
'id' => $listingId,
'component' => $component
);
$lockItem = Mage::getModel('M2ePro/Listing_LockItem',$lockItemParams);
if (!$lockItem->isExist()) {
$lockItem->create();
}
}
public function unlockListingNowAction()
{
$listingId = (int)$this->getRequest()->getParam('id');
$component = $this->getRequest()->getParam('component');
$lockItemParams = array(
'id' => $listingId,
'component' => $component
);
$lockItem = Mage::getModel('M2ePro/Listing_LockItem',$lockItemParams);
if ($lockItem->isExist()) {
$lockItem->remove();
}
}
//#############################################
public function clearLogAction()
{
$ids = $this->getRequestIds();
if (count($ids) == 0) {
$this->_getSession()->addError(Mage::helper('M2ePro')->__('Please select item(s) to clear.'));
$this->_redirect('*/*/index');
return;
}
foreach ($ids as $id) {
Mage::getModel('M2ePro/Listing_Log')->clearMessages($id);
}
$this->_getSession()->addSuccess(Mage::helper('M2ePro')->__('The listing(s) log was successfully cleaned.'));
$this->_redirectUrl(Mage::helper('M2ePro')->getBackUrl('list'));
}
public function getErrorsSummaryAction()
{
$blockParams = array(
'action_ids' => $this->getRequest()->getParam('action_ids'),
'table_name' => Mage::getResourceModel('M2ePro/Listing_Log')->getMainTable(),
'type_log' => 'listing'
);
$block = $this->getLayout()->createBlock('M2ePro/adminhtml_log_errorsSummary','',$blockParams);
return $this->getResponse()->setBody($block->toHtml());
}
//#############################################
}