forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento#21802: [Backport] magento#13612 Fixed-Quantity_and_stock_status when visibility set to storefront throwing exception (by @amol2jcommerce) - magento#21051: Fix broken admin order after emptying order and readding items (by @driskell) - magento#21698: [Backport] 20818 - prevent cache drop for frontend caches on sitemap generation (by @david-fuehr) - magento#21662: [Backport] Fixed: magento#21278, Add sort order on downloadable links (by @mage2pratik) - magento#20412: Remove sku from operators to validate condition (by @igor-imaginemage) - magento#21800: [Backport] Disable dropdown in JavaScript and CSS Settings in developer configur� (by @ananth-iyer) - magento#21793: [Backport] Fixed wrong proxing in the inventory observer (by @VitaliyBoyko) - magento#21759: [Backport] Wishlist review summary (by @amol2jcommerce) - magento#21433: [Backport] Make it possible to generate sales PDF's using the API (by @amol2jcommerce) Fixed GitHub Issues: - magento#13612: 1 exception(s): Exception #0 (Exception): Warning: Illegal offset type in isset or empty in /home/jewelrynest2/public_html/magento/vendor/magento/module-eav/Model/Entity/Attribute/Source/AbstractSource.php on line 76 (reported by @kamal3294) has been fixed in magento#21802 by @amol2jcommerce in 2.2-develop branch Related commits: 1. e7fb7fe 2. dcf808e - magento#21278: Sort order missing on Downloadable Product Links and Sample Columns (reported by @maheshWebkul721) has been fixed in magento#21662 by @mage2pratik in 2.2-develop branch Related commits: 1. f80d382 2. b7ad075 3. a9016e9 - magento#21384: JS minify field is not disabled in developer configuration (reported by @DanielRuf) has been fixed in magento#21800 by @ananth-iyer in 2.2-develop branch Related commits: 1. 095b9f4 - magento#167: Fatal error: Class 'Mage' not found (reported by @clockworkgeek) has been fixed in magento#21793 by @VitaliyBoyko in 2.2-develop branch Related commits: 1. 27d113f - magento#21419: Wishlist is missing review summary (reported by @Den4ik) has been fixed in magento#21759 by @amol2jcommerce in 2.2-develop branch Related commits: 1. 2aed503 2. f0b3b92 3. d9b01e3 4. 9661291 5. 3dea8d0
- Loading branch information
Showing
28 changed files
with
266 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogWidget\Setup; | ||
|
||
use Magento\CatalogWidget\Block\Product\ProductsList; | ||
use Magento\CatalogWidget\Model\Rule\Condition\Product as ConditionProduct; | ||
use Magento\Framework\Serialize\Serializer\Json as Serializer; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\UpgradeDataInterface; | ||
|
||
/** | ||
* Upgrade data for CatalogWidget module. | ||
*/ | ||
class UpgradeData implements UpgradeDataInterface | ||
{ | ||
/** | ||
* @var Serializer | ||
*/ | ||
private $serializer; | ||
|
||
/** | ||
* @param Serializer $serializer | ||
*/ | ||
public function __construct( | ||
Serializer $serializer | ||
) { | ||
$this->serializer = $serializer; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
if (version_compare($context->getVersion(), '2.0.1', '<')) { | ||
$this->replaceIsWithIsOneOf($setup); | ||
} | ||
} | ||
|
||
/** | ||
* Replace 'is' condition with 'is one of' in database. | ||
* | ||
* If 'is' product list condition is used with multiple skus it should be replaced by 'is one of' condition. | ||
* | ||
* @param ModuleDataSetupInterface $setup | ||
*/ | ||
private function replaceIsWithIsOneOf(ModuleDataSetupInterface $setup) | ||
{ | ||
$tableName = $setup->getTable('widget_instance'); | ||
$connection = $setup->getConnection(); | ||
$select = $connection->select() | ||
->from( | ||
$tableName, | ||
[ | ||
'instance_id', | ||
'widget_parameters', | ||
] | ||
)->where('instance_type = ? ', ProductsList::class); | ||
|
||
$result = $setup->getConnection()->fetchAll($select); | ||
|
||
if ($result) { | ||
$updatedData = $this->updateWidgetData($result); | ||
|
||
$connection->insertOnDuplicate( | ||
$tableName, | ||
$updatedData | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Replace 'is' condition with 'is one of' in widget parameters. | ||
* | ||
* @param array $result | ||
* @return array | ||
*/ | ||
private function updateWidgetData(array $result): array | ||
{ | ||
return array_map( | ||
function ($widgetData) { | ||
$widgetParameters = $this->serializer->unserialize($widgetData['widget_parameters']); | ||
foreach ($widgetParameters['conditions'] as &$condition) { | ||
if (ConditionProduct::class === $condition['type'] && | ||
'sku' === $condition['attribute'] && | ||
'==' === $condition['operator']) { | ||
$condition['operator'] = '()'; | ||
} | ||
} | ||
$widgetData['widget_parameters'] = $this->serializer->serialize($widgetParameters); | ||
|
||
return $widgetData; | ||
}, | ||
$result | ||
); | ||
} | ||
} |
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
Oops, something went wrong.