Skip to content

Commit ec058d7

Browse files
committed
MAGETWO-54200: Wrong "gift_message_available" parameter exported
1 parent 3b5260e commit ec058d7

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

app/code/Magento/GiftMessage/Model/GiftMessageConfigProvider.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
use Magento\Framework\UrlInterface;
1313
use Magento\Framework\Locale\FormatInterface as LocaleFormat;
1414
use Magento\Framework\Data\Form\FormKey;
15-
use Magento\Catalog\Model\Product\Attribute\Source\Boolean;
16-
use Magento\Store\Model\ScopeInterface;
1715

1816
/**
1917
* Configuration provider for GiftMessage rendering on "Checkout cart" page.
@@ -96,11 +94,11 @@ public function getConfig()
9694
$configuration['giftMessage'] = [];
9795
$orderLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
9896
GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ORDER,
99-
ScopeInterface::SCOPE_STORE
97+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
10098
);
10199
$itemLevelGiftMessageConfiguration = (bool)$this->scopeConfiguration->getValue(
102100
GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS,
103-
ScopeInterface::SCOPE_STORE
101+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
104102
);
105103
if ($orderLevelGiftMessageConfiguration) {
106104
$orderMessages = $this->getOrderLevelGiftMessages();
@@ -180,13 +178,8 @@ protected function getItemLevelGiftMessages()
180178
$itemId = $item->getId();
181179
$itemLevelConfig[$itemId] = [];
182180
$isMessageAvailable = $item->getProduct()->getGiftMessageAvailable();
183-
184-
if ($isMessageAvailable == Boolean::VALUE_USE_CONFIG) {
185-
$itemLevelConfig[$itemId]['is_available'] = (bool)$this->scopeConfiguration->getValue(
186-
GiftMessageHelper::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS,
187-
ScopeInterface::SCOPE_STORE
188-
);
189-
} else {
181+
// use gift message product setting if it is available
182+
if ($isMessageAvailable !== null) {
190183
$itemLevelConfig[$itemId]['is_available'] = (bool)$isMessageAvailable;
191184
}
192185
$message = $this->itemRepository->get($quote->getId(), $itemId);

app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\Store\Model\ScopeInterface;
1414
use Magento\Ui\Component\Form\Element\Checkbox;
1515
use Magento\Ui\Component\Form\Field;
16-
use Magento\Catalog\Model\Product\Attribute\Source\Boolean;
1716

1817
/**
1918
* Class GiftMessageDataProvider
@@ -58,14 +57,15 @@ public function __construct(
5857
public function modifyData(array $data)
5958
{
6059
$modelId = $this->locator->getProduct()->getId();
61-
$value = Boolean::VALUE_USE_CONFIG;
60+
$value = '';
6261

6362
if (isset($data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE])) {
6463
$value = $data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE];
6564
}
6665

67-
if ($value == Boolean::VALUE_USE_CONFIG) {
68-
$data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE] = $this->getValueFromConfig();
66+
if ('' === $value) {
67+
$data[$modelId][static::DATA_SOURCE_DEFAULT][static::FIELD_MESSAGE_AVAILABLE] =
68+
$this->getValueFromConfig();
6969
$data[$modelId][static::DATA_SOURCE_DEFAULT]['use_config_' . static::FIELD_MESSAGE_AVAILABLE] = '1';
7070
}
7171

@@ -129,8 +129,14 @@ protected function customizeAllowGiftMessageField(array $meta)
129129
'data' => [
130130
'config' => [
131131
'dataScope' => static::FIELD_MESSAGE_AVAILABLE,
132-
'component' => 'Magento_Ui/js/form/element/single-checkbox-use-config',
132+
'imports' => [
133+
'disabled' =>
134+
'${$.parentName}.use_config_'
135+
. static::FIELD_MESSAGE_AVAILABLE
136+
. ':checked',
137+
],
133138
'additionalClasses' => 'admin__field-x-small',
139+
'formElement' => Checkbox::NAME,
134140
'componentType' => Field::NAME,
135141
'prefer' => 'toggle',
136142
'valueMap' => [
@@ -154,12 +160,6 @@ protected function customizeAllowGiftMessageField(array $meta)
154160
'false' => '0',
155161
'true' => '1',
156162
],
157-
'exports' => [
158-
'checked' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseConfig',
159-
],
160-
'imports' => [
161-
'disabled' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseDefault',
162-
],
163163
],
164164
],
165165
],

0 commit comments

Comments
 (0)