-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7755 from magento-l3/PR_29_JUN_2022_odubovyk
L3 Bugfix delivery
- Loading branch information
Showing
20 changed files
with
504 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/code/Magento/CatalogRule/Test/Fixture/Data/ActionsSerializer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogRule\Test\Fixture\Data; | ||
|
||
use Magento\CatalogRule\Model\Rule\Action\Collection; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
|
||
class ActionsSerializer | ||
{ | ||
/** | ||
* @var Json | ||
*/ | ||
private Json $json; | ||
|
||
/** | ||
* @param Json $json | ||
*/ | ||
public function __construct( | ||
Json $json | ||
) { | ||
$this->json = $json; | ||
} | ||
|
||
/** | ||
* Normalizes and serializes actions data | ||
* | ||
* @param array $data | ||
* @return string | ||
*/ | ||
public function serialize(array $data): string | ||
{ | ||
return $this->json->serialize($this->normalize($data)); | ||
} | ||
|
||
/** | ||
* Normalizes actions data | ||
* | ||
* @param array $data | ||
* @return array | ||
*/ | ||
private function normalize(array $data) : array | ||
{ | ||
$actions = $data; | ||
$actions += [ | ||
'type' => Collection::class, | ||
'attribute' => null, | ||
'value' => null, | ||
'operator' => '=', | ||
]; | ||
return $actions; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
app/code/Magento/CatalogRule/Test/Fixture/Data/ConditionsSerializer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogRule\Test\Fixture\Data; | ||
|
||
use Magento\CatalogRule\Model\Rule\Condition\Combine; | ||
use Magento\CatalogRule\Model\Rule\Condition\Product; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
|
||
class ConditionsSerializer | ||
{ | ||
/** | ||
* @var Json | ||
*/ | ||
private Json $json; | ||
|
||
/** | ||
* @param Json $json | ||
*/ | ||
public function __construct( | ||
Json $json | ||
) { | ||
$this->json = $json; | ||
} | ||
|
||
/** | ||
* Normalizes and serializes conditions data | ||
* | ||
* @param array $data | ||
* @return string | ||
*/ | ||
public function serialize(array $data): string | ||
{ | ||
return $this->json->serialize($this->normalize($data)); | ||
} | ||
|
||
/** | ||
* Normalizes conditions data | ||
* | ||
* @param array $data | ||
* @return array | ||
*/ | ||
private function normalize(array $data) : array | ||
{ | ||
$conditions = $data; | ||
if (array_is_list($conditions)) { | ||
$conditions = [ | ||
'conditions' => $conditions, | ||
]; | ||
} | ||
$conditions += [ | ||
'type' => Combine::class, | ||
'attribute' => null, | ||
'value' => true, | ||
'operator' => null, | ||
'aggregator' => 'all', | ||
'is_value_processed' => null, | ||
'conditions' => [ | ||
|
||
], | ||
]; | ||
$subConditions = $conditions['conditions']; | ||
$conditions['conditions'] = []; | ||
|
||
foreach ($subConditions as $condition) { | ||
if (isset($condition['conditions']) && array_is_list($condition)) { | ||
$condition = $this->normalize($condition); | ||
} else { | ||
$condition += [ | ||
'type' => Product::class, | ||
'attribute' => null, | ||
'value' => null, | ||
'operator' => '==', | ||
'is_value_processed' => false, | ||
]; | ||
} | ||
|
||
$conditions['conditions'][] = $condition; | ||
} | ||
return $conditions; | ||
} | ||
} |
Oops, something went wrong.