Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 5dce3bd

Browse files
author
Valeriy Nayda
committed
Merge remote-tracking branch 'origin/2.3-develop' into recheck-129-retrive-customer-token
2 parents 277fe08 + ca42048 commit 5dce3bd

File tree

170 files changed

+4565
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+4565
-1150
lines changed

app/code/Magento/Backend/etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Backend" >
9+
<module name="Magento_Backend">
1010
<sequence>
1111
<module name="Magento_Directory"/>
1212
</sequence>

app/code/Magento/Braintree/Model/Ui/PayPal/ConfigProvider.php

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public function __construct(Config $config, ResolverInterface $resolver)
4747
*/
4848
public function getConfig()
4949
{
50+
$requireBillingAddressAll = \Magento\Paypal\Model\Config::REQUIRE_BILLING_ADDRESS_ALL;
51+
5052
return [
5153
'payment' => [
5254
self::PAYPAL_CODE => [
@@ -60,6 +62,8 @@ public function getConfig()
6062
'vaultCode' => self::PAYPAL_VAULT_CODE,
6163
'skipOrderReview' => $this->config->isSkipOrderReview(),
6264
'paymentIcon' => $this->config->getPayPalIcon(),
65+
'isRequiredBillingAddress' =>
66+
(int)$this->config->isRequiredBillingAddress() === $requireBillingAddressAll
6367
]
6468
]
6569
];

app/code/Magento/Braintree/Test/Unit/Model/Ui/PayPal/ConfigProviderTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function testGetConfig($expected)
7777
'width' => 30, 'height' => 26, 'url' => 'https://icon.test.url'
7878
]);
7979

80+
$this->config->method('isRequiredBillingAddress')
81+
->willReturn(1);
82+
8083
self::assertEquals($expected, $this->configProvider->getConfig());
8184
}
8285

@@ -101,7 +104,8 @@ public function getConfigDataProvider()
101104
'skipOrderReview' => false,
102105
'paymentIcon' => [
103106
'width' => 30, 'height' => 26, 'url' => 'https://icon.test.url'
104-
]
107+
],
108+
'isRequiredBillingAddress' => true
105109
]
106110
]
107111
]

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ define([
206206
beforePlaceOrder: function (data) {
207207
this.setPaymentMethodNonce(data.nonce);
208208

209-
if (quote.billingAddress() === null && typeof data.details.billingAddress !== 'undefined') {
209+
if ((this.isRequiredBillingAddress() || quote.billingAddress() === null) &&
210+
typeof data.details.billingAddress !== 'undefined'
211+
) {
210212
this.setBillingAddress(data.details, data.details.billingAddress);
211213
}
212214

@@ -264,6 +266,14 @@ define([
264266
return window.checkoutConfig.payment[this.getCode()].isAllowShippingAddressOverride;
265267
},
266268

269+
/**
270+
* Is billing address required from PayPal side
271+
* @returns {Boolean}
272+
*/
273+
isRequiredBillingAddress: function () {
274+
return window.checkoutConfig.payment[this.getCode()].isRequiredBillingAddress;
275+
},
276+
267277
/**
268278
* Get configuration for PayPal
269279
* @returns {Object}

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView
5656
*/
5757
private $catalogRuleProcessor;
5858

59+
/**
60+
* @var array
61+
*/
62+
private $optionsPosition = [];
63+
5964
/**
6065
* @param \Magento\Catalog\Block\Product\Context $context
6166
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -86,6 +91,8 @@ public function __construct(
8691
}
8792

8893
/**
94+
* Return catalog rule processor or creates processor if it does not exist
95+
*
8996
* @deprecated 100.2.0
9097
* @return \Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor
9198
*/
@@ -101,6 +108,7 @@ private function getCatalogRuleProcessor()
101108

102109
/**
103110
* Returns the bundle product options
111+
*
104112
* Will return cached options data if the product options are already initialized
105113
* In a case when $stripSelection parameter is true will reload stored bundle selections collection from DB
106114
*
@@ -135,6 +143,8 @@ public function getOptions($stripSelection = false)
135143
}
136144

137145
/**
146+
* Return true if product has options
147+
*
138148
* @return bool
139149
*/
140150
public function hasOptions()
@@ -150,7 +160,6 @@ public function hasOptions()
150160
* Returns JSON encoded config to be used in JS scripts
151161
*
152162
* @return string
153-
*
154163
*/
155164
public function getJsonConfig()
156165
{
@@ -172,6 +181,7 @@ public function getJsonConfig()
172181
}
173182
$optionId = $optionItem->getId();
174183
$options[$optionId] = $this->getOptionItemData($optionItem, $currentProduct, $position);
184+
$this->optionsPosition[$position] = $optionId;
175185

176186
// Add attribute default value (if set)
177187
if ($preConfiguredFlag) {
@@ -370,6 +380,7 @@ private function getConfigData(Product $product, array $options)
370380
$config = [
371381
'options' => $options,
372382
'selected' => $this->selectedOptions,
383+
'positions' => $this->optionsPosition,
373384
'bundleId' => $product->getId(),
374385
'priceFormat' => $this->localeFormat->getPriceFormat(),
375386
'prices' => [

app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ public function testGetJsonConfigFixedPriceBundle()
280280
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
281281
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
282282
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
283+
$this->assertEquals([1], $jsonConfig['positions']);
283284
}
284285

285286
/**

app/code/Magento/Bundle/view/frontend/web/js/product-summary.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ define([
5656

5757
// Clear Summary box
5858
this.element.html('');
59-
60-
$.each(this.cache.currentElement.selected, $.proxy(this._renderOption, this));
59+
this.cache.currentElement.positions.forEach(function (optionId) {
60+
this._renderOption(optionId, this.cache.currentElement.selected[optionId]);
61+
}, this);
6162
this.element
6263
.parents(this.options.bundleSummaryContainer)
6364
.toggleClass('empty', !this.cache.currentElementCount); // Zero elements equal '.empty' container

app/code/Magento/Catalog/Block/Product/View/Gallery.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
use Magento\Framework\Stdlib\ArrayUtils;
2424

2525
/**
26+
* Product gallery block
27+
*
2628
* @api
2729
* @since 100.0.2
2830
*/
@@ -139,7 +141,7 @@ public function getGalleryImagesJson()
139141
'thumb' => $image->getData('small_image_url'),
140142
'img' => $image->getData('medium_image_url'),
141143
'full' => $image->getData('large_image_url'),
142-
'caption' => $image->getData('label'),
144+
'caption' => ($image->getLabel() ?: $this->getProduct()->getName()),
143145
'position' => $image->getData('position'),
144146
'isMain' => $this->isMainImage($image),
145147
'type' => str_replace('external-', '', $image->getMediaType()),
@@ -196,6 +198,8 @@ public function isMainImage($image)
196198
}
197199

198200
/**
201+
* Returns image attribute
202+
*
199203
* @param string $imageId
200204
* @param string $attributeName
201205
* @param string $default
@@ -222,6 +226,8 @@ private function getConfigView()
222226
}
223227

224228
/**
229+
* Returns image gallery config object
230+
*
225231
* @return Collection
226232
*/
227233
private function getGalleryImagesConfig()

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

+27-12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product
5454
*/
5555
private $storeManager;
5656

57+
/**
58+
* @var \Magento\Framework\Escaper|null
59+
*/
60+
private $escaper;
61+
62+
/**
63+
* @var null|\Psr\Log\LoggerInterface
64+
*/
65+
private $logger;
66+
5767
/**
5868
* Save constructor.
5969
*
@@ -63,20 +73,26 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product
6373
* @param \Magento\Catalog\Model\Product\Copier $productCopier
6474
* @param \Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager
6575
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
76+
* @param \Magento\Framework\Escaper|null $escaper
77+
* @param \Psr\Log\LoggerInterface|null $logger
6678
*/
6779
public function __construct(
6880
\Magento\Backend\App\Action\Context $context,
6981
Product\Builder $productBuilder,
7082
Initialization\Helper $initializationHelper,
7183
\Magento\Catalog\Model\Product\Copier $productCopier,
7284
\Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager,
73-
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
85+
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
86+
\Magento\Framework\Escaper $escaper = null,
87+
\Psr\Log\LoggerInterface $logger = null
7488
) {
7589
$this->initializationHelper = $initializationHelper;
7690
$this->productCopier = $productCopier;
7791
$this->productTypeManager = $productTypeManager;
7892
$this->productRepository = $productRepository;
7993
parent::__construct($context, $productBuilder);
94+
$this->escaper = $escaper ?? $this->_objectManager->get(\Magento\Framework\Escaper::class);
95+
$this->logger = $logger ?? $this->_objectManager->get(\Psr\Log\LoggerInterface::class);
8096
}
8197

8298
/**
@@ -103,14 +119,14 @@ public function execute()
103119
$this->productBuilder->build($this->getRequest())
104120
);
105121
$this->productTypeManager->processProduct($product);
106-
107122
if (isset($data['product'][$product->getIdFieldName()])) {
108123
throw new \Magento\Framework\Exception\LocalizedException(
109124
__('The product was unable to be saved. Please try again.')
110125
);
111126
}
112127

113128
$originalSku = $product->getSku();
129+
$canSaveCustomOptions = $product->getCanSaveCustomOptions();
114130
$product->save();
115131
$this->handleImageRemoveError($data, $product->getId());
116132
$this->getCategoryLinkManagement()->assignProductToCategories(
@@ -120,20 +136,17 @@ public function execute()
120136
$productId = $product->getEntityId();
121137
$productAttributeSetId = $product->getAttributeSetId();
122138
$productTypeId = $product->getTypeId();
123-
124-
$this->copyToStores($data, $productId);
139+
$extendedData = $data;
140+
$extendedData['can_save_custom_options'] = $canSaveCustomOptions;
141+
$this->copyToStores($extendedData, $productId);
125142
$this->messageManager->addSuccessMessage(__('You saved the product.'));
126143
$this->getDataPersistor()->clear('catalog_product');
127144
if ($product->getSku() != $originalSku) {
128145
$this->messageManager->addNoticeMessage(
129146
__(
130147
'SKU for product %1 has been changed to %2.',
131-
$this->_objectManager->get(
132-
\Magento\Framework\Escaper::class
133-
)->escapeHtml($product->getName()),
134-
$this->_objectManager->get(
135-
\Magento\Framework\Escaper::class
136-
)->escapeHtml($product->getSku())
148+
$this->escaper->escapeHtml($product->getName()),
149+
$this->escaper->escapeHtml($product->getSku())
137150
)
138151
);
139152
}
@@ -143,17 +156,18 @@ public function execute()
143156
);
144157

145158
if ($redirectBack === 'duplicate') {
159+
$product->unsetData('quantity_and_stock_status');
146160
$newProduct = $this->productCopier->copy($product);
147161
$this->messageManager->addSuccessMessage(__('You duplicated the product.'));
148162
}
149163
} catch (\Magento\Framework\Exception\LocalizedException $e) {
150-
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
164+
$this->logger->critical($e);
151165
$this->messageManager->addExceptionMessage($e);
152166
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
153167
$this->getDataPersistor()->set('catalog_product', $data);
154168
$redirectBack = $productId ? true : 'new';
155169
} catch (\Exception $e) {
156-
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
170+
$this->logger->critical($e);
157171
$this->messageManager->addErrorMessage($e->getMessage());
158172
$data = isset($product) ? $this->persistMediaData($product, $data) : $data;
159173
$this->getDataPersistor()->set('catalog_product', $data);
@@ -242,6 +256,7 @@ protected function copyToStores($data, $productId)
242256
->setStoreId($copyFrom)
243257
->load($productId)
244258
->setStoreId($copyTo)
259+
->setCanSaveCustomOptions($data['can_save_custom_options'])
245260
->setCopyFromView(true)
246261
->save();
247262
}

0 commit comments

Comments
 (0)