Skip to content

Commit e657c98

Browse files
committed
Merge remote-tracking branch 'adobe-commerce-tier-4/ACP2E-2927' into Tier4-Kings-PR-05-17-2024
2 parents c6bc830 + 09715bb commit e657c98

File tree

5 files changed

+316
-16
lines changed

5 files changed

+316
-16
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
2121
use Magento\Catalog\Model\Product\Link\Resolver as LinkResolver;
2222
use Magento\Catalog\Model\Product\LinkTypeProvider;
23+
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions;
2324
use Magento\Framework\App\ObjectManager;
2425
use Magento\Framework\App\RequestInterface;
2526
use Magento\Framework\Locale\FormatInterface;
@@ -401,6 +402,9 @@ private function overwriteValue($optionId, $option, $overwriteOptions)
401402
$option['is_delete_store_title'] = 1;
402403
}
403404
}
405+
if (CustomOptions::FIELD_TITLE_NAME === $fieldName) {
406+
$option[CustomOptions::FIELD_IS_USE_DEFAULT] = $overwrite;
407+
}
404408
}
405409
}
406410

app/code/Magento/Catalog/Model/ResourceModel/Product/Option.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
/**
1515
* Catalog product custom option resource model
1616
*
17-
* @author Magento Core Team <core@magentocommerce.com>
1817
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1918
*/
2019
class Option extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
@@ -25,15 +24,11 @@ class Option extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
2524
protected $metadataPool;
2625

2726
/**
28-
* Store manager
29-
*
3027
* @var \Magento\Store\Model\StoreManagerInterface
3128
*/
3229
protected $_storeManager;
3330

3431
/**
35-
* Currency factory
36-
*
3732
* @var \Magento\Directory\Model\CurrencyFactory
3833
*/
3934
protected $_currencyFactory;
@@ -259,12 +254,13 @@ protected function _saveValueTitles(AbstractModel $object)
259254
}
260255
} else {
261256
// we should insert record into not default store only of if it does not exist in default store
262-
if (($storeId == Store::DEFAULT_STORE_ID && !$existInDefaultStore) ||
257+
if (((int)$storeId === Store::DEFAULT_STORE_ID && !$existInDefaultStore) ||
263258
(
264-
$storeId != Store::DEFAULT_STORE_ID &&
265-
!$existInCurrentStore &&
266-
!$isDeleteStoreTitle
267-
)
259+
(int)$storeId !== Store::DEFAULT_STORE_ID &&
260+
!$isDeleteStoreTitle &&
261+
($object->getDefaultTitle() !== null && $object->getTitle() !== $object->getDefaultTitle())
262+
) ||
263+
($object->getIsUseDefault() !== null && !(int)$object->getIsUseDefault())
268264
) {
269265
$data = $this->_prepareDataForTable(
270266
new \Magento\Framework\DataObject(

app/code/Magento/Catalog/Model/ResourceModel/Product/Option/Value.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@
2727
class Value extends AbstractDb
2828
{
2929
/**
30-
* Store manager
31-
*
3230
* @var StoreManagerInterface
3331
*/
3432
protected $_storeManager;
3533

3634
/**
37-
* Currency factory
38-
*
3935
* @var CurrencyFactory
4036
*/
4137
protected $_currencyFactory;
@@ -288,8 +284,12 @@ protected function _saveValueTitles(AbstractModel $object)
288284
Store::DEFAULT_STORE_ID
289285
);
290286
// we should insert record into not default store only of if it does not exist in default store
291-
if (($storeId == Store::DEFAULT_STORE_ID && !$existInDefaultStore)
292-
|| ($storeId != Store::DEFAULT_STORE_ID && !$existInCurrentStore)
287+
if (((int)$storeId === Store::DEFAULT_STORE_ID && !$existInDefaultStore) ||
288+
(
289+
(int)$storeId !== Store::DEFAULT_STORE_ID &&
290+
($object->getDefaultTitle() !== null && $object->getTitle() !== $object->getDefaultTitle())
291+
) ||
292+
($object->getIsUseDefault() !== null && !(int)$object->getIsUseDefault())
293293
) {
294294
$bind = [
295295
'option_type_id' => (int)$object->getId(),
@@ -456,6 +456,7 @@ public function duplicate(OptionValue $object, $oldOptionId, $newOptionId)
456456
*
457457
* @return FormatInterface
458458
* @deprecated 101.0.8
459+
* @see Avoid direct use of ObjectManager
459460
*/
460461
private function getLocaleFormatter()
461462
{

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ public static function mergeProductOptionsDataProvider()
660660
'default_key2' => 'val22',
661661
],
662662
],
663+
'is_use_default' => 1,
663664
],
664665
],
665666
],
@@ -702,6 +703,7 @@ public static function mergeProductOptionsDataProvider()
702703
'default_key1' => 'val11',
703704
'default_title' => 'val22',
704705
'is_delete_store_title' => 1,
706+
'is_use_default' => 1,
705707
],
706708
],
707709
],

0 commit comments

Comments
 (0)