Skip to content

Commit 99dbb54

Browse files
Merge pull request #1 from magento/2.2-develop
Update 2.2 develop branch
2 parents 32a7c4b + 899e950 commit 99dbb54

File tree

59 files changed

+910
-142
lines changed

Some content is hidden

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

59 files changed

+910
-142
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ atlassian*
3333
/.php_cs
3434
/.php_cs.cache
3535
/grunt-config.json
36-
/dev/tools/grunt/configs/local-themes.js
3736

3837
/pub/media/*.*
3938
!/pub/media/.htaccess

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

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
define([
88
'jquery',
99
'underscore',
10-
'mage/utils/wrapper',
1110
'Magento_Checkout/js/view/payment/default',
1211
'Magento_Braintree/js/view/payment/adapter',
1312
'Magento_Checkout/js/model/quote',
@@ -19,7 +18,6 @@ define([
1918
], function (
2019
$,
2120
_,
22-
wrapper,
2321
Component,
2422
Braintree,
2523
quote,
@@ -105,6 +103,12 @@ define([
105103
}
106104
});
107105

106+
quote.shippingAddress.subscribe(function () {
107+
if (self.isActive()) {
108+
self.reInitPayPal();
109+
}
110+
});
111+
108112
// for each component initialization need update property
109113
this.isReviewRequired(false);
110114
this.initClientConfig();
@@ -222,9 +226,8 @@ define([
222226

223227
/**
224228
* Re-init PayPal Auth Flow
225-
* @param {Function} callback - Optional callback
226229
*/
227-
reInitPayPal: function (callback) {
230+
reInitPayPal: function () {
228231
if (Braintree.checkout) {
229232
Braintree.checkout.teardown(function () {
230233
Braintree.checkout = null;
@@ -235,17 +238,6 @@ define([
235238
this.clientConfig.paypal.amount = this.grandTotalAmount;
236239
this.clientConfig.paypal.shippingAddressOverride = this.getShippingAddress();
237240

238-
if (callback) {
239-
this.clientConfig.onReady = wrapper.wrap(
240-
this.clientConfig.onReady,
241-
function (original, checkout) {
242-
this.clientConfig.onReady = original;
243-
original(checkout);
244-
callback();
245-
}.bind(this)
246-
);
247-
}
248-
249241
Braintree.setConfig(this.clientConfig);
250242
Braintree.setup();
251243
},
@@ -429,19 +421,17 @@ define([
429421
* Triggers when customer click "Continue to PayPal" button
430422
*/
431423
payWithPayPal: function () {
432-
this.reInitPayPal(function () {
433-
if (!additionalValidators.validate()) {
434-
return;
435-
}
424+
if (!additionalValidators.validate()) {
425+
return;
426+
}
436427

437-
try {
438-
Braintree.checkout.paypal.initAuthFlow();
439-
} catch (e) {
440-
this.messageContainer.addErrorMessage({
441-
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
442-
});
443-
}
444-
}.bind(this));
428+
try {
429+
Braintree.checkout.paypal.initAuthFlow();
430+
} catch (e) {
431+
this.messageContainer.addErrorMessage({
432+
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
433+
});
434+
}
445435
},
446436

447437
/**

app/code/Magento/Catalog/Block/Product/ProductList/Crosssell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct
2525
*/
2626
protected function _prepareData()
2727
{
28-
$product = $this->_coreRegistry->registry('product');
28+
$product = $this->getProduct();
2929
/* @var $product \Magento\Catalog\Model\Product */
3030

3131
$this->_itemCollection = $product->getCrossSellProductCollection()->addAttributeToSelect(

app/code/Magento/Catalog/Block/Product/ProductList/Related.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __construct(
8282
*/
8383
protected function _prepareData()
8484
{
85-
$product = $this->_coreRegistry->registry('product');
85+
$product = $this->getProduct();
8686
/* @var $product \Magento\Catalog\Model\Product */
8787

8888
$this->_itemCollection = $product->getRelatedProductCollection()->addAttributeToSelect(

app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __construct(
9797
*/
9898
protected function _prepareData()
9999
{
100-
$product = $this->_coreRegistry->registry('product');
100+
$product = $this->getProduct();
101101
/* @var $product \Magento\Catalog\Model\Product */
102102
$this->_itemCollection = $product->getUpSellProductCollection()->setPositionOrder()->addStoreFilter();
103103
if ($this->moduleManager->isEnabled('Magento_Checkout')) {

app/code/Magento/Catalog/Controller/Product/Compare.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,12 @@ public function setCustomerId($customerId)
139139
$this->_customerId = $customerId;
140140
return $this;
141141
}
142+
143+
/**
144+
* @inheritdoc
145+
*/
146+
public function execute()
147+
{
148+
return $this->resultRedirectFactory->create()->setPath('catalog/product_compare');
149+
}
142150
}

app/code/Magento/Catalog/Model/Product/Gallery/Processor.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
namespace Magento\Catalog\Model\Product\Gallery;
77

8+
use Magento\Framework\Api\Data\ImageContentInterface;
89
use Magento\Framework\App\Filesystem\DirectoryList;
910
use Magento\Framework\Exception\LocalizedException;
10-
use Magento\Framework\Filesystem\DriverInterface;
11+
use Magento\Framework\App\ObjectManager;
1112

1213
/**
1314
* Catalog product Media Gallery attribute processor.
@@ -55,28 +56,39 @@ class Processor
5556
*/
5657
protected $resourceModel;
5758

59+
/**
60+
* @var \Magento\Framework\File\Mime
61+
*/
62+
private $mime;
63+
5864
/**
5965
* @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository
6066
* @param \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb
6167
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
6268
* @param \Magento\Framework\Filesystem $filesystem
6369
* @param \Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel
70+
* @param \Magento\Framework\File\Mime|null $mime
71+
* @throws \Magento\Framework\Exception\FileSystemException
6472
*/
6573
public function __construct(
6674
\Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository,
6775
\Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb,
6876
\Magento\Catalog\Model\Product\Media\Config $mediaConfig,
6977
\Magento\Framework\Filesystem $filesystem,
70-
\Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel
78+
\Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel,
79+
\Magento\Framework\File\Mime $mime = null
7180
) {
7281
$this->attributeRepository = $attributeRepository;
7382
$this->fileStorageDb = $fileStorageDb;
7483
$this->mediaConfig = $mediaConfig;
7584
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
7685
$this->resourceModel = $resourceModel;
86+
$this->mime = $mime ?: ObjectManager::getInstance()->get(\Magento\Framework\File\Mime::class);
7787
}
7888

7989
/**
90+
* Return media_gallery attribute
91+
*
8092
* @return \Magento\Catalog\Api\Data\ProductAttributeInterface
8193
* @since 101.0.0
8294
*/
@@ -178,6 +190,13 @@ public function addImage(
178190
$attrCode = $this->getAttribute()->getAttributeCode();
179191
$mediaGalleryData = $product->getData($attrCode);
180192
$position = 0;
193+
194+
$absoluteFilePath = $this->mediaDirectory->getAbsolutePath($file);
195+
$imageMimeType = $this->mime->getMimeType($absoluteFilePath);
196+
$imageContent = $this->mediaDirectory->readFile($absoluteFilePath);
197+
$imageBase64 = base64_encode($imageContent);
198+
$imageName = $pathinfo['filename'];
199+
181200
if (!is_array($mediaGalleryData)) {
182201
$mediaGalleryData = ['images' => []];
183202
}
@@ -192,9 +211,17 @@ public function addImage(
192211
$mediaGalleryData['images'][] = [
193212
'file' => $fileName,
194213
'position' => $position,
195-
'media_type' => 'image',
196214
'label' => '',
197215
'disabled' => (int)$exclude,
216+
'media_type' => 'image',
217+
'types' => $mediaAttribute,
218+
'content' => [
219+
'data' => [
220+
ImageContentInterface::NAME => $imageName,
221+
ImageContentInterface::BASE64_ENCODED_DATA => $imageBase64,
222+
ImageContentInterface::TYPE => $imageMimeType,
223+
]
224+
]
198225
];
199226

200227
$product->setData($attrCode, $mediaGalleryData);
@@ -353,7 +380,8 @@ public function setMediaAttribute(\Magento\Catalog\Model\Product $product, $medi
353380
}
354381

355382
/**
356-
* get media attribute codes
383+
* Get media attribute codes
384+
*
357385
* @return array
358386
* @since 101.0.0
359387
*/
@@ -363,6 +391,8 @@ public function getMediaAttributeCodes()
363391
}
364392

365393
/**
394+
* Trim .tmp ending from filename
395+
*
366396
* @param string $file
367397
* @return string
368398
* @since 101.0.0
@@ -484,7 +514,6 @@ public function getAffectedFields($object)
484514
/**
485515
* Attribute value is not to be saved in a conventional way, separate table is used to store the complex value
486516
*
487-
* {@inheritdoc}
488517
* @since 101.0.0
489518
*/
490519
public function isScalar()

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeSetSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
</section>
1919
<section name="AdminModifyAttributesSection">
2020
<!-- Parameter is the attribute name -->
21-
<element name="dropDownAttributeByName" type="select" selector="//*[text()='{{attributeName}}']/../..//select" parameterized="true"/>
21+
<element name="dropDownAttributeByName" type="select" selector="//*[text()='{{attributeName}}']/../../..//select" parameterized="true"/>
2222
</section>
2323
</sections>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductCustomizableOptionsSection.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<element name="useDefaultOptionTitle" type="text" selector="[data-index='options'] tr.data-row [data-index='title'] [name^='options_use_default']"/>
1515
<element name="useDefaultOptionValueTitleByIndex" type="text" selector="[data-index='options'] [data-index='values'] tr[data-repeat-index='{{var1}}'] [name^='options_use_default']" parameterized="true"/>
1616
<element name="addOptionBtn" type="button" selector="button[data-index='button_add']"/>
17-
<element name="fillOptionTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//label[text()='Option Title']/parent::span/parent::div//input[@class='admin__control-text']" parameterized="true"/>
18-
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//label[text()='Option Type']/parent::span/parent::div//div[@data-role='selected-option']" parameterized="true"/>
19-
<element name="checkDropDown" type="select" selector="//span[text()='{{var1}}']/ancestor::div[@class='fieldset-wrapper-title']/following-sibling::div[@data-role='collapsible-content']//div[@data-index='type']//div[contains(@class, 'action-menu')]//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='Drop-down']" parameterized="true"/>
17+
<element name="fillOptionTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Title']/parent::label/parent::div/parent::div//input[@class='admin__control-text']" parameterized="true"/>
18+
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Type']/parent::label/parent::div/parent::div//div[@data-role='selected-option']" parameterized="true"/>
19+
<element name="checkDropDown" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//parent::label/parent::div/parent::div//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='Drop-down']" parameterized="true"/>
2020
<element name="clickAddValue" type="button" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tfoot//button" parameterized="true"/>
21-
<element name="fillOptionValueTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//label[text()='Title']/parent::span/parent::div//div[@class='admin__field-control']/input" parameterized="true"/>
21+
<element name="fillOptionValueTitle" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//span[text()='Title']/parent::label/parent::div/parent::div//div[@class='admin__field-control']/input" parameterized="true"/>
2222
<element name="fillOptionValuePrice" type="input" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody/tr[@data-repeat-index='{{var2}}']//span[text()='Price']/parent::label/parent::div//div[@class='admin__control-addon']/input" parameterized="true"/>
23-
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//label[text()='Price Type']/parent::span/parent::div//select" parameterized="true"/>
23+
<element name="clickSelectPriceType" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//tbody//tr[@data-repeat-index='{{var2}}']//span[text()='Price Type']/parent::label/parent::div/parent::div//select" parameterized="true"/>
2424
<!-- Elements that make it easier to select the most recently added element -->
2525
<element name="lastOptionTitle" type="input" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, '_required')]//input" />
2626
<element name="lastOptionTypeParent" type="block" selector="//*[@data-index='custom_options']//*[@data-index='options']/tbody/tr[last()]//*[contains(@class, 'admin__action-multiselect-text')]" />

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
1616
<element name="productNameUseDefault" type="checkbox" selector="input[name='use_default[name]']"/>
1717
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
18-
<element name="enableProductAttributeLabel" type="text" selector="[data-index='status'] .admin__field-label label"/>
19-
<element name="enableProductAttributeLabelWrapper" type="text" selector="[data-index='status'] .admin__field-label"/>
18+
<element name="enableProductAttributeLabel" type="text" selector="//span[text()='Enable Product']/parent::label"/>
19+
<element name="enableProductAttributeLabelWrapper" type="text" selector="//span[text()='Enable Product']/parent::label/parent::div"/>
2020
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
2121
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
2222
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
@@ -33,7 +33,7 @@
3333
<element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/>
3434
<element name="divByDataIndex" type="input" selector="div[data-index='{{var}}']" parameterized="true"/>
3535
<element name="attributeSetSearchCount" type="text" selector="div[data-index='attribute_set_id'] .admin__action-multiselect-search-count"/>
36-
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//label[text()='{{attributeLabel}}']" parameterized="true"/>
36+
<element name="attributeLabelByText" type="text" selector="//*[@class='admin__field']//span[text()='{{attributeLabel}}']" parameterized="true"/>
3737
<element name="addAttributeBtn" type="button" selector="#addAttribute"/>
3838
<element name="attributeSetFilterResultByName" type="text" selector="//label/span[text() = '{{var}}']" timeout="30" parameterized="true"/>
3939
<element name="attributeSetDropDown" type="select" selector="div[data-index='attribute_set_id'] .action-select.admin__action-multiselect"/>

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ define([
7878
pricesCode = [],
7979
priceValue, origin, finalPrice;
8080

81-
this.cache.additionalPriceObject = this.cache.additionalPriceObject || {};
81+
if (typeof newPrices !== 'undefined' && newPrices.hasOwnProperty('prices')) {
82+
this.cache.additionalPriceObject = {};
83+
} else {
84+
this.cache.additionalPriceObject = this.cache.additionalPriceObject || {};
85+
}
8286

8387
if (newPrices) {
8488
$.extend(this.cache.additionalPriceObject, newPrices);

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
129129
*/
130130
const COL_NAME = 'name';
131131

132+
/**
133+
* Column new_from_date.
134+
*/
135+
const COL_NEW_FROM_DATE = 'new_from_date';
136+
137+
/**
138+
* Column new_to_date.
139+
*/
140+
const COL_NEW_TO_DATE = 'new_to_date';
141+
132142
/**
133143
* Column product website.
134144
*/
@@ -292,7 +302,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
292302
ValidatorInterface::ERROR_MEDIA_PATH_NOT_ACCESSIBLE => 'Imported resource (image) does not exist in the local media storage',
293303
ValidatorInterface::ERROR_MEDIA_URL_NOT_ACCESSIBLE => 'Imported resource (image) could not be downloaded from external resource due to timeout or access permissions',
294304
ValidatorInterface::ERROR_INVALID_WEIGHT => 'Product weight is invalid',
295-
ValidatorInterface::ERROR_DUPLICATE_URL_KEY => 'Url key: \'%s\' was already generated for an item with the SKU: \'%s\'. You need to specify the unique URL key manually'
305+
ValidatorInterface::ERROR_DUPLICATE_URL_KEY => 'Url key: \'%s\' was already generated for an item with the SKU: \'%s\'. You need to specify the unique URL key manually',
306+
ValidatorInterface::ERROR_NEW_TO_DATE => 'Make sure new_to_date is later than or the same as new_from_date',
296307
];
297308

298309
/**
@@ -313,8 +324,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
313324
Product::COL_TYPE => 'product_type',
314325
Product::COL_PRODUCT_WEBSITES => 'product_websites',
315326
'status' => 'product_online',
316-
'news_from_date' => 'new_from_date',
317-
'news_to_date' => 'new_to_date',
327+
'news_from_date' => self::COL_NEW_FROM_DATE,
328+
'news_to_date' => self::COL_NEW_TO_DATE,
318329
'options_container' => 'display_product_options_in',
319330
'minimal_price' => 'map_price',
320331
'msrp' => 'msrp_price',
@@ -2477,6 +2488,20 @@ public function validateRow(array $rowData, $rowNum)
24772488
}
24782489
}
24792490
}
2491+
2492+
if (!empty($rowData[self::COL_NEW_FROM_DATE]) && !empty($rowData[self::COL_NEW_TO_DATE])
2493+
) {
2494+
$newFromTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_FROM_DATE], false));
2495+
$newToTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_TO_DATE], false));
2496+
if ($newFromTimestamp > $newToTimestamp) {
2497+
$this->addRowError(
2498+
ValidatorInterface::ERROR_NEW_TO_DATE,
2499+
$rowNum,
2500+
$rowData[self::COL_NEW_TO_DATE]
2501+
);
2502+
}
2503+
}
2504+
24802505
return !$this->getErrorAggregator()->isRowInvalid($rowNum);
24812506
}
24822507

app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ interface RowValidatorInterface extends \Magento\Framework\Validator\ValidatorIn
8585

8686
const ERROR_DUPLICATE_URL_KEY = 'duplicatedUrlKey';
8787

88+
const ERROR_NEW_TO_DATE = 'invalidNewToDateValue';
89+
8890
/**
8991
* Value that means all entities (e.g. websites, groups etc.)
9092
*/

0 commit comments

Comments
 (0)