Skip to content

Commit 6a3aa8c

Browse files
author
Volodymyr Kublytskyi
committed
Merge remote-tracking branch 'mainline/2.1-develop' into MAGETWO-83478-magento-magento2-12050
2 parents 75881f6 + 90074e7 commit 6a3aa8c

File tree

148 files changed

+4447
-1515
lines changed

Some content is hidden

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

148 files changed

+4447
-1515
lines changed

app/autoload.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,3 @@
3535
}
3636

3737
AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($composerAutoloader));
38-
39-
// Sets default autoload mappings, may be overridden in Bootstrap::create
40-
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);

app/bootstrap.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
}
2929

3030
require_once __DIR__ . '/autoload.php';
31+
// Sets default autoload mappings, may be overridden in Bootstrap::create
32+
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
33+
3134
require_once BP . '/app/functions.php';
3235

3336
/* Custom umask value may be provided in optional mage_umask file in root */

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ define(
3636
braintreeDeviceData: null,
3737
paymentMethodNonce: null,
3838
lastBillingAddress: null,
39+
ccCode: null,
40+
ccMessageContainer: null,
3941
validatorManager: validatorManager,
4042
code: 'braintree',
4143

@@ -138,9 +140,39 @@ define(
138140
return;
139141
}
140142

143+
this.restoreMessageContainer();
144+
this.restoreCode();
145+
146+
/**
147+
* Define onReady callback
148+
*/
149+
braintree.onReady = function () {};
141150
this.initBraintree();
142151
},
143152

153+
/**
154+
* Restore original message container for cc-form component
155+
*/
156+
restoreMessageContainer: function () {
157+
this.messageContainer = this.ccMessageContainer;
158+
},
159+
160+
/**
161+
* Restore original code for cc-form component
162+
*/
163+
restoreCode: function () {
164+
this.code = this.ccCode;
165+
},
166+
167+
/** @inheritdoc */
168+
initChildren: function () {
169+
this._super();
170+
this.ccMessageContainer = this.messageContainer;
171+
this.ccCode = this.code;
172+
173+
return this;
174+
},
175+
144176
/**
145177
* Init config
146178
*/

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ define([
5252
var self = this;
5353

5454
/**
55-
* Define already callback
55+
* Define onReady callback
5656
*/
5757
Braintree.onReady = function () {
5858
self.getPaymentMethodNonce();
@@ -78,6 +78,7 @@ define([
7878
formComponent.setPaymentMethodNonce(response.paymentMethodNonce);
7979
formComponent.additionalData['public_hash'] = self.publicHash;
8080
formComponent.code = self.code;
81+
formComponent.messageContainer = self.messageContainer;
8182
formComponent.placeOrder();
8283
});
8384
})

app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Attributes/Extend.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ public function getExtendedElement($switchAttributeCode)
143143
[
144144
'name' => "product[{$switchAttributeCode}]",
145145
'values' => $this->getOptions(),
146-
'value' => $switchAttributeCode,
147146
'class' => 'required-entry next-toinput',
148147
'no_span' => true,
149148
'disabled' => $this->isDisabledField(),

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function __construct(\Magento\Catalog\Block\Product\Context $context, arr
124124
*/
125125
public function getAddToCartUrl($product, $additional = [])
126126
{
127-
if ($product->getTypeInstance()->hasRequiredOptions($product)) {
127+
if (!$product->getTypeInstance()->isPossibleBuyFromList($product)) {
128128
if (!isset($additional['_escape'])) {
129129
$additional['_escape'] = true;
130130
}

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,21 @@ public function prepareSortableFieldsByCategory($category)
318318
public function getIdentities()
319319
{
320320
$identities = [];
321-
foreach ($this->_getProductCollection() as $item) {
322-
$identities = array_merge($identities, $item->getIdentities());
323-
}
321+
324322
$category = $this->getLayer()->getCurrentCategory();
325323
if ($category) {
326324
$identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $category->getId();
327325
}
326+
327+
//Check if category page shows only static block (No products)
328+
if ($category->getData('display_mode') == Category::DM_PAGE) {
329+
return $identities;
330+
}
331+
332+
foreach ($this->_getProductCollection() as $item) {
333+
$identities = array_merge($identities, $item->getIdentities());
334+
}
335+
328336
return $identities;
329337
}
330338

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public function getAdditionalData(array $excludeAttr = [])
8181
$attributes = $product->getAttributes();
8282
foreach ($attributes as $attribute) {
8383
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
84-
$value = $attribute->getFrontend()->getValue($product);
85-
84+
if (is_array($value = $attribute->getFrontend()->getValue($product))) {
85+
continue;
86+
}
8687
if (!$product->hasData($attribute->getAttributeCode())) {
8788
$value = __('N/A');
8889
} elseif ((string)$value == '') {

app/code/Magento/Catalog/Block/Product/View/Options/Type/Date.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function getCalendarDateHtml()
8282
$yearStart = $this->_catalogProductOptionTypeDate->getYearStart();
8383
$yearEnd = $this->_catalogProductOptionTypeDate->getYearEnd();
8484

85+
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
86+
/** Escape invisible characters which are present in some locales and may corrupt formatting */
87+
$escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat);
8588
$calendar = $this->getLayout()->createBlock(
8689
'Magento\Framework\View\Element\Html\Date'
8790
)->setId(
@@ -93,7 +96,7 @@ public function getCalendarDateHtml()
9396
)->setImage(
9497
$this->getViewFileUrl('Magento_Theme::calendar.png')
9598
)->setDateFormat(
96-
$this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)
99+
$escapedDateFormat
97100
)->setValue(
98101
$value
99102
)->setYearsRange(

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

Lines changed: 58 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory as CustomOptionFactory;
99
use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory as ProductLinkFactory;
1010
use Magento\Catalog\Api\ProductRepositoryInterface\Proxy as ProductRepository;
11+
use Magento\Catalog\Model\Product;
1112
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks;
1213
use Magento\Catalog\Model\Product\Link\Resolver as LinkResolver;
1314
use Magento\Framework\App\ObjectManager;
@@ -112,14 +113,14 @@ public function __construct(
112113
/**
113114
* Initialize product from data
114115
*
115-
* @param \Magento\Catalog\Model\Product $product
116+
* @param Product $product
116117
* @param array $productData
117-
* @return \Magento\Catalog\Model\Product
118+
* @return Product
118119
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
119120
* @SuppressWarnings(PHPMD.NPathComplexity)
120121
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
121122
*/
122-
public function initializeFromData(\Magento\Catalog\Model\Product $product, array $productData)
123+
public function initializeFromData(Product $product, array $productData)
123124
{
124125
unset($productData['custom_attributes']);
125126
unset($productData['extension_attributes']);
@@ -195,36 +196,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
195196
}
196197

197198
$product = $this->setProductLinks($product);
198-
199-
/**
200-
* Initialize product options
201-
*/
202-
if ($productOptions && !$product->getOptionsReadonly()) {
203-
// mark custom options that should to fall back to default value
204-
$options = $this->mergeProductOptions(
205-
$productOptions,
206-
$this->request->getPost('options_use_default')
207-
);
208-
$customOptions = [];
209-
foreach ($options as $customOptionData) {
210-
if (empty($customOptionData['is_delete'])) {
211-
if (empty($customOptionData['option_id'])) {
212-
$customOptionData['option_id'] = null;
213-
}
214-
215-
if (isset($customOptionData['values'])) {
216-
$customOptionData['values'] = array_filter($customOptionData['values'], function ($valueData) {
217-
return empty($valueData['is_delete']);
218-
});
219-
}
220-
221-
$customOption = $this->getCustomOptionFactory()->create(['data' => $customOptionData]);
222-
$customOption->setProductSku($product->getSku());
223-
$customOptions[] = $customOption;
224-
}
225-
}
226-
$product->setOptions($customOptions);
227-
}
199+
$product = $this->fillProductOptions($product, $productOptions);
228200

229201
$product->setCanSaveCustomOptions(
230202
!empty($productData['affect_product_custom_options']) && !$product->getOptionsReadonly()
@@ -236,10 +208,10 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
236208
/**
237209
* Initialize product before saving
238210
*
239-
* @param \Magento\Catalog\Model\Product $product
240-
* @return \Magento\Catalog\Model\Product
211+
* @param Product $product
212+
* @return Product
241213
*/
242-
public function initialize(\Magento\Catalog\Model\Product $product)
214+
public function initialize(Product $product)
243215
{
244216
$productData = $this->request->getPost('product', []);
245217
return $this->initializeFromData($product, $productData);
@@ -248,11 +220,11 @@ public function initialize(\Magento\Catalog\Model\Product $product)
248220
/**
249221
* Setting product links
250222
*
251-
* @param \Magento\Catalog\Model\Product $product
252-
* @return \Magento\Catalog\Model\Product
223+
* @param Product $product
224+
* @return Product
253225
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
254226
*/
255-
protected function setProductLinks(\Magento\Catalog\Model\Product $product)
227+
protected function setProductLinks(Product $product)
256228
{
257229
$links = $this->getLinkResolver()->getLinks();
258230

@@ -454,4 +426,51 @@ private function getDateTimeFilter()
454426

455427
return $this->dateTimeFilter;
456428
}
429+
430+
/**
431+
* Fills $product with options from $productOptions array
432+
*
433+
* @param Product $product
434+
* @param array $productOptions
435+
* @return Product
436+
*/
437+
private function fillProductOptions(Product $product, array $productOptions)
438+
{
439+
if ($product->getOptionsReadonly()) {
440+
return $product;
441+
}
442+
if (empty($productOptions)) {
443+
return $product->setOptions([]);
444+
}
445+
// mark custom options that should to fall back to default value
446+
$options = $this->mergeProductOptions(
447+
$productOptions,
448+
$this->request->getPost('options_use_default')
449+
);
450+
$customOptions = [];
451+
foreach ($options as $customOptionData) {
452+
if (!empty($customOptionData['is_delete'])) {
453+
continue;
454+
}
455+
456+
if (empty($customOptionData['option_id'])) {
457+
$customOptionData['option_id'] = null;
458+
}
459+
if (isset($customOptionData['values'])) {
460+
$customOptionData['values'] = array_filter(
461+
$customOptionData['values'],
462+
function ($valueData) {
463+
return empty($valueData['is_delete']);
464+
}
465+
);
466+
}
467+
$customOption = $this->getCustomOptionFactory()->create(
468+
['data' => $customOptionData]
469+
);
470+
$customOption->setProductSku($product->getSku());
471+
$customOptions[] = $customOption;
472+
}
473+
474+
return $product->setOptions($customOptions);
475+
}
457476
}

0 commit comments

Comments
 (0)