Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
karliuka committed Oct 31, 2021
2 parents 3e6b70a + dfea6d1 commit 186cd30
Show file tree
Hide file tree
Showing 34 changed files with 260 additions and 145 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
/.directory
/.DS_Store
/*.kate-swp
/var
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
- id: check-xml
- id: check-yaml
- id: check-json
- id: pretty-format-json
args: ["--indent=4", "--autofix", "--no-sort-keys"]
- repo: https://github.com/eriocnemis/git.magento_pre_commit_hooks
rev: 1.0.10
hooks:
- id: magento-xml
- id: magento-phpcs
args: ["--autofix"]
- id: magento-phpmd
- id: magento-phpcpd
- id: magento-phpstan
4 changes: 2 additions & 2 deletions Block/Adminhtml/Catalog/Edit/Tab/Conditions.php
Expand Up @@ -59,7 +59,7 @@ class Conditions extends Generic implements TabInterface
* @param RuleConditions $conditions
* @param Fieldset $rendererFieldset
* @param RuleFactory $ruleFactory
* @param array $data
* @param mixed[] $data
*/
public function __construct(
Context $context,
Expand Down Expand Up @@ -233,7 +233,7 @@ protected function addTabToForm($model, $fieldsetId = 'conditions_fieldset', $fo
*/
protected function setConditionFormName(AbstractCondition $conditions, $formName)
{
$conditions->setFormName($formName);
$conditions->setData('form_name', $formName);
$conditions->setJsFormObject($formName);
if ($conditions->getConditions() && is_array($conditions->getConditions())) {
foreach ($conditions->getConditions() as $condition) {
Expand Down
27 changes: 15 additions & 12 deletions Block/Adminhtml/Rule/Chooser/Sku.php
Expand Up @@ -66,7 +66,7 @@ class Sku extends AbstractGrid
* @param SetCollectionFactory $setCollectionFactory
* @param ProductCollectionFactory $productCollectionFactory
* @param ProductType $productType
* @param array $data
* @param mixed[] $data
*/
public function __construct(
Context $context,
Expand Down Expand Up @@ -96,12 +96,12 @@ protected function _construct()
{
parent::_construct();

$id = 'skuChooserGrid_' . $this->getId();
if ($this->getRequest()->getParam('current_grid_id')) {
$this->setId($this->getRequest()->getParam('current_grid_id'));
} else {
$this->setId('skuChooserGrid_' . $this->getId());
$id = $this->getRequest()->getParam('current_grid_id');
}

$this->setId($id);
$form = $this->getJsFormObject();

$this->setRowClickCallback("{$form}.chooserGridRowClick.bind({$form})");
Expand Down Expand Up @@ -129,15 +129,17 @@ protected function _addColumnFilterToCollection($column)
if (empty($selected)) {
$selected = '';
}
if ($column->getFilter()->getValue()) {
$this->getCollection()->addFieldToFilter('sku', ['in' => $selected]);
} else {
$this->getCollection()->addFieldToFilter('sku', ['nin' => $selected]);

if (false !== $column->getFilter()) {
$value = $column->getFilter()->getData('value')
? ['in' => $selected]
: ['nin' => $selected];

$this->getCollection()->addFieldToFilter('sku', $value);
}
} else {
parent::_addColumnFilterToCollection($column);
return $this;
}
return $this;
return parent::_addColumnFilterToCollection($column);
}

/**
Expand All @@ -149,9 +151,10 @@ protected function _prepareCollection()
{
$collection = $this->getProductCollection()
->setStoreId(0)
->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
->addAttributeToSelect(['name', 'type_id', 'attribute_set_id']);

$this->setCollection($collection);

return parent::_prepareCollection();
}

Expand Down
2 changes: 1 addition & 1 deletion COPYING.txt
@@ -1,4 +1,4 @@
Each Magento source file included in this distribution is licensed under OSL 3.0

http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
Please see LICENSE.txt for the full text of the OSL 3.0 license.
Please see LICENSE.txt for the full text of the OSL 3.0 license.
22 changes: 9 additions & 13 deletions Controller/Adminhtml/Rule/Chooser.php
Expand Up @@ -33,17 +33,16 @@ public function execute()
break;
case 'category_ids':
$ids = $request->getParam('selected', []);
if (is_array($ids)) {
foreach ($ids as $key => &$id) {
$id = (int)$id;
if ($id <= 0) {
unset($ids[$key]);
}
$ids = is_array($ids) ? $ids : [];

foreach ($ids as $key => &$id) {
$id = (int)$id;
if ($id <= 0) {
unset($ids[$key]);
}
$ids = array_unique($ids);
} else {
$ids = [];
}

$ids = array_unique($ids);
$block = $this->_view->getLayout()->createBlock(
Tree::class,
'smartcategory_chooser_category_ids',
Expand All @@ -56,9 +55,6 @@ public function execute()
$block = false;
break;
}

if ($block) {
$this->getResponse()->setBody($block->toHtml());
}
return $this->getResponse()->setBody($block ? $block->toHtml() : '');
}
}
7 changes: 3 additions & 4 deletions Controller/Adminhtml/Rule/NewConditionHtml.php
Expand Up @@ -27,6 +27,7 @@ public function execute()
$formName = $request->getParam('form_namespace');
$typeArr = explode('|', str_replace('-', '/', $request->getParam('type')));
$type = $typeArr[0];
$html = '';

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

if ($model instanceof AbstractCondition) {
$model->setJsFormObject($request->getParam('form'));
$model->setFormName($formName);
$model->setData('form_name', $formName);
$html = $model->asHtmlRecursive();
} else {
$html = '';
}
$this->getResponse()->setBody($html);
return $this->getResponse()->setBody($html);
}
}
4 changes: 2 additions & 2 deletions LICENSE.txt
Expand Up @@ -15,7 +15,7 @@ Licensed under the Open Software License version 3.0

4. to perform the Original Work publicly; and

5. to display the Original Work publicly.
5. to display the Original Work publicly.

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.

Expand Down Expand Up @@ -45,4 +45,4 @@ Licensed under the Open Software License version 3.0

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.

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.
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.
5 changes: 2 additions & 3 deletions Model/Indexer/AbstractIndexer.php
Expand Up @@ -91,7 +91,7 @@ public function executeFull()
/**
* Retrieve affected cache tags
*
* @return array
* @return string[]
* @codeCoverageIgnore
*/
public function getIdentities()
Expand Down Expand Up @@ -180,8 +180,7 @@ protected function getCacheContext()
{
if (!($this->cacheContext instanceof CacheContext)) {
return ObjectManager::getInstance()->get(CacheContext::class);
} else {
return $this->cacheContext;
}
return $this->cacheContext;
}
}
19 changes: 11 additions & 8 deletions Model/Indexer/IndexBuilder.php
Expand Up @@ -15,9 +15,12 @@
use Psr\Log\LoggerInterface;
use Faonni\SmartCategory\Model\ResourceModel\Rule\CollectionFactory as RuleCollectionFactory;
use Faonni\SmartCategory\Model\Rule;
use Zend_Db_Expr;

/**
* Index builder
* Rule index builder
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class IndexBuilder
{
Expand Down Expand Up @@ -52,7 +55,7 @@ class IndexBuilder
/**
* Loaded products
*
* @var array
* @var mixed[]
*/
protected $loadedProducts;

Expand Down Expand Up @@ -109,7 +112,7 @@ public function reindexById($id)
/**
* Reindex by ids
*
* @param array $ids
* @param int[] $ids
* @throws LocalizedException
* @return void
* @api
Expand All @@ -129,7 +132,7 @@ public function reindexByIds(array $ids)
/**
* Reindex by ids
*
* @param array $ids
* @param int[] $ids
* @return void
*/
protected function doReindexByIds($ids)
Expand Down Expand Up @@ -200,7 +203,7 @@ protected function doReindexFull()
* Clean by product ids
*
* @param integer $categoryId
* @param array $productIds
* @param mixed[] $productIds
* @return void
*/
protected function cleanByIds($categoryId, $productIds)
Expand All @@ -215,7 +218,7 @@ protected function cleanByIds($categoryId, $productIds)
* Insert products
*
* @param integer $categoryId
* @param array $productIds
* @param mixed[] $productIds
* @return void
*/
protected function insertMultiple($categoryId, $productIds)
Expand Down Expand Up @@ -278,7 +281,7 @@ protected function checkPostedProduct($categoryId, $productId)
{
$select = $this->connection
->select()
->from($this->getTable('catalog_category_product'), [new \Zend_Db_Expr('COUNT(*)')])
->from($this->getTable('catalog_category_product'), [new Zend_Db_Expr('COUNT(*)')])
->where('category_id = ?', $categoryId)
->where('product_id = ?', $productId);

Expand All @@ -289,7 +292,7 @@ protected function checkPostedProduct($categoryId, $productId)
* Retrieve posted products
*
* @param string $categoryId
* @return array
* @return mixed[]
*/
protected function getPostedProductData($categoryId)
{
Expand Down
2 changes: 1 addition & 1 deletion Model/Indexer/Product/ProductRuleIndexer.php
Expand Up @@ -10,7 +10,7 @@
use Faonni\SmartCategory\Model\Indexer\AbstractIndexer;

/**
* Product rule indexer
* Product indexer
*/
class ProductRuleIndexer extends AbstractIndexer
{
Expand Down
4 changes: 3 additions & 1 deletion Model/Indexer/Product/ProductRuleProcessor.php
Expand Up @@ -8,7 +8,7 @@
use Magento\Framework\Indexer\AbstractProcessor;

/**
* Product rule processor
* Indexer processor
*/
class ProductRuleProcessor extends AbstractProcessor
{
Expand All @@ -23,6 +23,7 @@ class ProductRuleProcessor extends AbstractProcessor
* @param int $id
* @param bool $forceReindex
* @return void
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function reindexRow($id, $forceReindex = false)
{
Expand All @@ -39,6 +40,7 @@ public function reindexRow($id, $forceReindex = false)
* @param int[] $ids
* @param bool $forceReindex
* @return void
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function reindexList($ids, $forceReindex = false)
{
Expand Down

0 comments on commit 186cd30

Please sign in to comment.