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.
Merge pull request magento#3827 from magento-tsg/2.2-develop-pr80
[TSG] Backporting for 2.2 (pr80) (2.2-develop)
- Loading branch information
Showing
44 changed files
with
1,078 additions
and
249 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
59 changes: 59 additions & 0 deletions
59
...code/Magento/Catalog/Plugin/Model/Product/Option/UpdateProductCustomOptionsAttributes.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,59 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Plugin\Model\Product\Option; | ||
|
||
/** | ||
* Plugin for updating product 'has_options' and 'required_options' attributes. | ||
*/ | ||
class UpdateProductCustomOptionsAttributes | ||
{ | ||
/** | ||
* @var \Magento\Catalog\Api\ProductRepositoryInterface | ||
*/ | ||
private $productRepository; | ||
|
||
/** | ||
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository | ||
*/ | ||
public function __construct(\Magento\Catalog\Api\ProductRepositoryInterface $productRepository) | ||
{ | ||
$this->productRepository = $productRepository; | ||
} | ||
|
||
/** | ||
* Update product 'has_options' and 'required_options' attributes after option save. | ||
* | ||
* @param \Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $subject | ||
* @param \Magento\Catalog\Api\Data\ProductCustomOptionInterface $option | ||
* | ||
* @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterSave( | ||
\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface $subject, | ||
\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option | ||
) { | ||
$product = $this->productRepository->get($option->getProductSku()); | ||
if (!$product->getHasOptions() | ||
|| ($option->getIsRequire() | ||
&& !$product->getRequiredOptions()) | ||
) { | ||
$product->setCanSaveCustomOptions(true); | ||
$product->setOptionsSaved(true); | ||
$optionId = $option->getOptionId(); | ||
$currentOptions = array_filter($product->getOptions(), function ($optionItem) use ($optionId) { | ||
return $optionId != $optionItem->getOptionId(); | ||
}); | ||
$currentOptions[] = $option; | ||
$product->setOptions($currentOptions); | ||
$product->save(); | ||
} | ||
|
||
return $option; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/code/Magento/Catalog/Test/Mftf/Page/AdminProductAttributeNewPage.xml
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> | ||
<page name="AdminProductAttributeNewPage" url="catalog/product_attribute/new/" area="admin" module="Magento_Catalog"> | ||
<section name="AttributePropertiesSection"/> | ||
<section name="StorefrontPropertiesSection"/> | ||
<section name="AdvancedAttributePropertiesSection"/> | ||
<section name="AdminAttributeOptionsSection"/> | ||
<section name="AttributeManageSwatchSection"/> | ||
</page> | ||
</pages> |
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.