Skip to content

Commit 2ec94a6

Browse files
author
DenysTsymbal
committed
Products to Posts
1 parent e9bd4c8 commit 2ec94a6

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

Block/Adminhtml/System/Config/Form/Featured.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class: 'action-default primary add',
105105
ensureGridIsSet(10000).then(function(){
106106
var grid = window['post_idsJsObject'];
107107
grid.reloadParams = {
108-
'selected_products[]': window.postState
108+
'selected_posts[]': window.postState
109109
};
110110
});
111111
});

Block/Adminhtml/System/Config/Form/Featured/Grid.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getRowInitCallback() : string
6464
{
6565
return 'function (grid, element,checked) {
6666
grid.reloadParams = {
67-
"selected_products[]": window.postState
67+
"selected_posts[]": window.postState
6868
};
6969
7070
}
@@ -139,7 +139,7 @@ function (grid, event) {
139139
}
140140
141141
grid.reloadParams = {
142-
"selected_products[]": window.postState
142+
"selected_posts[]": window.postState
143143
};
144144
145145
grid.setCheckboxChecked(checkbox[0], checked);
@@ -182,7 +182,7 @@ public function getCheckboxCheckCallback() : string
182182
}
183183
184184
grid.reloadParams = {
185-
"selected_products[]": window.postState
185+
"selected_posts[]": window.postState
186186
};
187187
}';
188188
}
@@ -196,14 +196,14 @@ protected function _addColumnFilterToCollection($column) : Grid
196196
{
197197
// Set custom filter for in category flag
198198
if ($column->getId() == 'post_id_checkbox') {
199-
$productIds = $this->_getSelectedPosts();
200-
if (empty($productIds)) {
201-
$productIds = 0;
199+
$postIds = $this->_getSelectedPosts();
200+
if (empty($postIds)) {
201+
$postIds = 0;
202202
}
203203
if ($column->getFilter()->getValue()) {
204-
$this->getCollection()->addFieldToFilter('post_id', ['in' => $productIds]);
205-
} elseif (!empty($productIds)) {
206-
$this->getCollection()->addFieldToFilter('post_id', ['nin' => $productIds]);
204+
$this->getCollection()->addFieldToFilter('post_id', ['in' => $postIds]);
205+
} elseif (!empty($postIds)) {
206+
$this->getCollection()->addFieldToFilter('post_id', ['nin' => $postIds]);
207207
}
208208
} else {
209209
parent::_addColumnFilterToCollection($column);
@@ -267,7 +267,7 @@ public function getGridUrl() : string
267267
*/
268268
protected function _getSelectedPosts() : array
269269
{
270-
$selectedPosts = $this->getRequest()->getParam('selected_products');
270+
$selectedPosts = $this->getRequest()->getParam('selected_posts');
271271

272272
if ($selectedPosts !== null) {
273273
return array_values($selectedPosts);

Block/Adminhtml/Widget/Featured/Grid.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ public function getRowInitCallback() : string
121121
122122
if(!currentState) {
123123
grid.reloadParams = {
124-
"selected_products[]": ""
124+
"selected_posts[]": ""
125125
};
126126
}
127127
else {
128128
grid.reloadParams = {
129-
"selected_products[]": window.postState
129+
"selected_posts[]": window.postState
130130
};
131131
}
132132
@@ -191,7 +191,7 @@ function (grid, event) {
191191
}
192192
193193
grid.reloadParams = {
194-
"selected_products[]": window.postState
194+
"selected_posts[]": window.postState
195195
};
196196
197197
grid.setCheckboxChecked(checkbox[0], checked);
@@ -234,7 +234,7 @@ public function getCheckboxCheckCallback() : string
234234
}
235235
236236
grid.reloadParams = {
237-
"selected_products[]": window.postState
237+
"selected_posts[]": window.postState
238238
};
239239
}';
240240
}
@@ -248,14 +248,14 @@ protected function _addColumnFilterToCollection($column) : Grid
248248
{
249249
// Set custom filter for in category flag
250250
if ($column->getId() == 'post_id_checkbox') {
251-
$productIds = $this->_getSelectedPosts();
252-
if (empty($productIds)) {
253-
$productIds = 0;
251+
$postIds = $this->_getSelectedPosts();
252+
if (empty($postIds)) {
253+
$postIds = 0;
254254
}
255255
if ($column->getFilter()->getValue()) {
256-
$this->getCollection()->addFieldToFilter('post_id', ['in' => $productIds]);
257-
} elseif (!empty($productIds)) {
258-
$this->getCollection()->addFieldToFilter('post_id', ['nin' => $productIds]);
256+
$this->getCollection()->addFieldToFilter('post_id', ['in' => $postIds]);
257+
} elseif (!empty($postIds)) {
258+
$this->getCollection()->addFieldToFilter('post_id', ['nin' => $postIds]);
259259
}
260260
} else {
261261
parent::_addColumnFilterToCollection($column);
@@ -319,7 +319,7 @@ public function getGridUrl() : string
319319
*/
320320
protected function _getSelectedPosts() : array
321321
{
322-
$selectedPosts = $this->getRequest()->getParam('selected_products');
322+
$selectedPosts = $this->getRequest()->getParam('selected_posts');
323323

324324
if ($selectedPosts !== null) {
325325
return array_values($selectedPosts);

0 commit comments

Comments
 (0)