Skip to content

Commit 53a0578

Browse files
committed
Merge branch '2.4.x' into 2.3.x
2 parents 9174fdc + 20389e6 commit 53a0578

33 files changed

+184
-224
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.directory
2+
/.DS_Store
3+
/*.kate-swp
4+
/var

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.0.1
4+
hooks:
5+
- id: end-of-file-fixer
6+
- id: mixed-line-ending
7+
args: ['--fix=lf']
8+
- id: trailing-whitespace
9+
- id: check-xml
10+
- id: check-yaml
11+
- id: check-json
12+
- id: pretty-format-json
13+
args: ["--indent=4", "--autofix", "--no-sort-keys"]
14+
- repo: https://github.com/eriocnemis/git.MagentoPreCommitHooks
15+
rev: 1.0.7
16+
hooks:
17+
- id: magento-phpcs
18+
# - id: magento-phpmd
19+
- id: magento-phpcpd
20+
- id: magento-phpstan

Block/Adminhtml/Catalog/Edit/Tab/Conditions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Conditions extends Generic implements TabInterface
5959
* @param RuleConditions $conditions
6060
* @param Fieldset $rendererFieldset
6161
* @param RuleFactory $ruleFactory
62-
* @param array $data
62+
* @param mixed[] $data
6363
*/
6464
public function __construct(
6565
Context $context,
@@ -233,7 +233,7 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
233233
*/
234234
protected function setConditionFormName(AbstractCondition $conditions, $formName)
235235
{
236-
$conditions->setFormName($formName);
236+
$conditions->setData('form_name', $formName);
237237
$conditions->setJsFormObject($formName);
238238
if ($conditions->getConditions() && is_array($conditions->getConditions())) {
239239
foreach ($conditions->getConditions() as $condition) {

Block/Adminhtml/Rule/Chooser/Sku.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Sku extends AbstractGrid
6666
* @param SetCollectionFactory $setCollectionFactory
6767
* @param ProductCollectionFactory $productCollectionFactory
6868
* @param ProductType $productType
69-
* @param array $data
69+
* @param mixed[] $data
7070
*/
7171
public function __construct(
7272
Context $context,
@@ -96,12 +96,12 @@ protected function _construct()
9696
{
9797
parent::_construct();
9898

99+
$id = 'skuChooserGrid_' . $this->getId();
99100
if ($this->getRequest()->getParam('current_grid_id')) {
100-
$this->setId($this->getRequest()->getParam('current_grid_id'));
101-
} else {
102-
$this->setId('skuChooserGrid_' . $this->getId());
101+
$id = $this->getRequest()->getParam('current_grid_id');
103102
}
104103

104+
$this->setId($id);
105105
$form = $this->getJsFormObject();
106106

107107
$this->setRowClickCallback("{$form}.chooserGridRowClick.bind({$form})");
@@ -129,15 +129,17 @@ protected function _addColumnFilterToCollection($column)
129129
if (empty($selected)) {
130130
$selected = '';
131131
}
132-
if ($column->getFilter()->getValue()) {
133-
$this->getCollection()->addFieldToFilter('sku', ['in' => $selected]);
134-
} else {
135-
$this->getCollection()->addFieldToFilter('sku', ['nin' => $selected]);
132+
133+
if (false !== $column->getFilter()) {
134+
$value = $column->getFilter()->getData('value')
135+
? ['in' => $selected]
136+
: ['nin' => $selected];
137+
138+
$this->getCollection()->addFieldToFilter('sku', $value);
136139
}
137-
} else {
138-
parent::_addColumnFilterToCollection($column);
140+
return $this;
139141
}
140-
return $this;
142+
return parent::_addColumnFilterToCollection($column);
141143
}
142144

143145
/**
@@ -149,9 +151,10 @@ protected function _prepareCollection()
149151
{
150152
$collection = $this->getProductCollection()
151153
->setStoreId(0)
152-
->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
154+
->addAttributeToSelect(['name', 'type_id', 'attribute_set_id']);
153155

154156
$this->setCollection($collection);
157+
155158
return parent::_prepareCollection();
156159
}
157160

COPYING.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Each Magento source file included in this distribution is licensed under OSL 3.0
22

33
http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
4-
Please see LICENSE.txt for the full text of the OSL 3.0 license.
4+
Please see LICENSE.txt for the full text of the OSL 3.0 license.

Controller/Adminhtml/Rule/Chooser.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ public function execute()
3333
break;
3434
case 'category_ids':
3535
$ids = $request->getParam('selected', []);
36-
if (is_array($ids)) {
37-
foreach ($ids as $key => &$id) {
38-
$id = (int)$id;
39-
if ($id <= 0) {
40-
unset($ids[$key]);
41-
}
36+
$ids = is_array($ids) ? $ids : [];
37+
38+
foreach ($ids as $key => &$id) {
39+
$id = (int)$id;
40+
if ($id <= 0) {
41+
unset($ids[$key]);
4242
}
43-
$ids = array_unique($ids);
44-
} else {
45-
$ids = [];
4643
}
44+
45+
$ids = array_unique($ids);
4746
$block = $this->_view->getLayout()->createBlock(
4847
Tree::class,
4948
'smartcategory_chooser_category_ids',
@@ -56,9 +55,6 @@ public function execute()
5655
$block = false;
5756
break;
5857
}
59-
60-
if ($block) {
61-
$this->getResponse()->setBody($block->toHtml());
62-
}
58+
return $this->getResponse()->setBody($block ? $block->toHtml() : '');
6359
}
6460
}

Controller/Adminhtml/Rule/NewConditionHtml.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function execute()
2727
$formName = $request->getParam('form_namespace');
2828
$typeArr = explode('|', str_replace('-', '/', $request->getParam('type')));
2929
$type = $typeArr[0];
30+
$html = '';
3031

3132
$model = $this->_objectManager->create($type)
3233
->setId($id)
@@ -40,11 +41,9 @@ public function execute()
4041

4142
if ($model instanceof AbstractCondition) {
4243
$model->setJsFormObject($request->getParam('form'));
43-
$model->setFormName($formName);
44+
$model->setData('form_name', $formName);
4445
$html = $model->asHtmlRecursive();
45-
} else {
46-
$html = '';
4746
}
48-
$this->getResponse()->setBody($html);
47+
return $this->getResponse()->setBody($html);
4948
}
5049
}

LICENSE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Licensed under the Open Software License version 3.0
1515

1616
4. to perform the Original Work publicly; and
1717

18-
5. to display the Original Work publicly.
18+
5. to display the Original Work publicly.
1919

2020
2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
2121

@@ -45,4 +45,4 @@ Licensed under the Open Software License version 3.0
4545

4646
15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
4747

48-
16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
48+
16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.

Model/Indexer/AbstractIndexer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function executeFull()
9191
/**
9292
* Retrieve affected cache tags
9393
*
94-
* @return array
94+
* @return string[]
9595
* @codeCoverageIgnore
9696
*/
9797
public function getIdentities()
@@ -180,8 +180,7 @@ protected function getCacheContext()
180180
{
181181
if (!($this->cacheContext instanceof CacheContext)) {
182182
return ObjectManager::getInstance()->get(CacheContext::class);
183-
} else {
184-
return $this->cacheContext;
185183
}
184+
return $this->cacheContext;
186185
}
187186
}

Model/Indexer/IndexBuilder.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
use Psr\Log\LoggerInterface;
1616
use Faonni\SmartCategory\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory;
1717
use Faonni\SmartCategory\Model\Rule;
18+
use Zend_Db_Expr;
1819

1920
/**
20-
* Index builder
21+
* Rule index builder
2122
*/
2223
class IndexBuilder
2324
{
@@ -52,7 +53,7 @@ class IndexBuilder
5253
/**
5354
* Loaded products
5455
*
55-
* @var array
56+
* @var mixed[]
5657
*/
5758
protected $loadedProducts;
5859

@@ -109,7 +110,7 @@ public function reindexById($id)
109110
/**
110111
* Reindex by ids
111112
*
112-
* @param array $ids
113+
* @param int[] $ids
113114
* @throws LocalizedException
114115
* @return void
115116
* @api
@@ -129,7 +130,7 @@ public function reindexByIds(array $ids)
129130
/**
130131
* Reindex by ids
131132
*
132-
* @param array $ids
133+
* @param int[] $ids
133134
* @return void
134135
*/
135136
protected function doReindexByIds($ids)
@@ -200,7 +201,7 @@ protected function doReindexFull()
200201
* Clean by product ids
201202
*
202203
* @param integer $categoryId
203-
* @param array $productIds
204+
* @param mixed[] $productIds
204205
* @return void
205206
*/
206207
protected function cleanByIds($categoryId, $productIds)
@@ -215,7 +216,7 @@ protected function cleanByIds($categoryId, $productIds)
215216
* Insert products
216217
*
217218
* @param integer $categoryId
218-
* @param array $productIds
219+
* @param mixed[] $productIds
219220
* @return void
220221
*/
221222
protected function insertMultiple($categoryId, $productIds)
@@ -278,7 +279,7 @@ protected function checkPostedProduct($categoryId, $productId)
278279
{
279280
$select = $this->connection
280281
->select()
281-
->from($this->getTable('catalog_category_product'), [new \Zend_Db_Expr('COUNT(*)')])
282+
->from($this->getTable('catalog_category_product'), [new Zend_Db_Expr('COUNT(*)')])
282283
->where('category_id = ?', $categoryId)
283284
->where('product_id = ?', $productId);
284285

@@ -289,7 +290,7 @@ protected function checkPostedProduct($categoryId, $productId)
289290
* Retrieve posted products
290291
*
291292
* @param string $categoryId
292-
* @return array
293+
* @return mixed[]
293294
*/
294295
protected function getPostedProductData($categoryId)
295296
{

0 commit comments

Comments
 (0)