Skip to content

Commit 86fa4e2

Browse files
committed
Merge branch 'develop' of github.corp.magento.com:magento2/magento2ce into develop-main
2 parents 8bc1beb + 2087543 commit 86fa4e2

File tree

84 files changed

+1254
-606
lines changed

Some content is hidden

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

84 files changed

+1254
-606
lines changed

app/code/Magento/Braintree/Observer/DataAssignObserver.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Event\Observer;
99
use Magento\Payment\Observer\AbstractDataAssignObserver;
10+
use Magento\Quote\Api\Data\PaymentInterface;
1011

1112
/**
1213
* Class DataAssignObserver
@@ -31,13 +32,19 @@ class DataAssignObserver extends AbstractDataAssignObserver
3132
public function execute(Observer $observer)
3233
{
3334
$data = $this->readDataArgument($observer);
35+
36+
$additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA);
37+
if (!is_array($additionalData)) {
38+
return;
39+
}
40+
3441
$paymentInfo = $this->readPaymentModelArgument($observer);
3542

3643
foreach ($this->additionalInformationList as $additionalInformationKey) {
37-
if ($data->getDataByKey($additionalInformationKey) !== null) {
44+
if (isset($additionalData[$additionalInformationKey])) {
3845
$paymentInfo->setAdditionalInformation(
3946
$additionalInformationKey,
40-
$data->getDataByKey($additionalInformationKey)
47+
$additionalData[$additionalInformationKey]
4148
);
4249
}
4350
}

app/code/Magento/Braintree/Test/Unit/Observer/DataAssignObserverTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Payment\Model\InfoInterface;
1111
use Magento\Payment\Observer\AbstractDataAssignObserver;
1212
use Magento\Braintree\Observer\DataAssignObserver;
13+
use Magento\Quote\Api\Data\PaymentInterface;
1314

1415
/**
1516
* Class DataAssignObserverTest
@@ -30,8 +31,10 @@ public function testExecute()
3031
$paymentInfoModel = $this->getMock(InfoInterface::class);
3132
$dataObject = new DataObject(
3233
[
33-
'payment_method_nonce' => self::PAYMENT_METHOD_NONCE,
34-
'device_data' => self::DEVICE_DATA,
34+
PaymentInterface::KEY_ADDITIONAL_DATA => [
35+
'payment_method_nonce' => self::PAYMENT_METHOD_NONCE,
36+
'device_data' => self::DEVICE_DATA
37+
]
3538
]
3639
);
3740
$observerContainer->expects(static::atLeastOnce())

app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ protected function _prepareCollection()
104104
'sku'
105105
)->addAttributeToSelect(
106106
'price'
107-
)->addStoreFilter(
108-
$this->getRequest()->getParam('store')
109107
)->joinField(
110108
'position',
111109
'catalog_category_product',
@@ -114,6 +112,10 @@ protected function _prepareCollection()
114112
'category_id=' . (int)$this->getRequest()->getParam('id', 0),
115113
'left'
116114
);
115+
$storeId = (int)$this->getRequest()->getParam('store', 0);
116+
if ($storeId > 0) {
117+
$collection->addStoreFilter($storeId);
118+
}
117119
$this->setCollection($collection);
118120

119121
if ($this->getCategory()->getProductsReadonly()) {

app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public function execute()
6767
throw new \Exception(__('Category is not available for requested store.'));
6868
}
6969
$category->move($parentNodeId, $prevNodeId);
70-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
71-
$error = true;
72-
$this->messageManager->addError(__('There was a category move error.'));
7370
} catch (\Magento\Framework\Exception\AlreadyExistsException $e) {
7471
$error = true;
7572
$this->messageManager->addError(__('There was a category move error. %1', $e->getMessage()));
73+
} catch (\Magento\Framework\Exception\LocalizedException $e) {
74+
$error = true;
75+
$this->messageManager->addError($e->getMessage());
7676
} catch (\Exception $e) {
7777
$error = true;
7878
$this->messageManager->addError(__('There was a category move error.'));

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public function copy(\Magento\Catalog\Model\Product $product)
4747
$product->getWebsiteIds();
4848
$product->getCategoryIds();
4949

50+
/** @var \Magento\Catalog\Model\Product $duplicate */
5051
$duplicate = $this->productFactory->create();
5152
$duplicate->setData($product->getData());
53+
$duplicate->setOptions([]);
5254
$duplicate->setIsDuplicate(true);
5355
$duplicate->setOriginalId($product->getEntityId());
5456
$duplicate->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);

app/code/Magento/Catalog/Model/Product/Option/Type/File/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(
3838
\Magento\Framework\File\Size $fileSize
3939
) {
4040
$this->scopeConfig = $scopeConfig;
41-
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
41+
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
4242
$this->fileSize = $fileSize;
4343
}
4444

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Api\ProductRepositoryInterface;
99
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\Exception\LocalizedException;
1011

1112
/**
1213
* @api
@@ -561,6 +562,7 @@ public function getSpecifyOptionMessage()
561562
* @param \Magento\Catalog\Model\Product $product
562563
* @param string $processMode
563564
* @return array
565+
* @throws LocalizedException
564566
*/
565567
protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $product, $processMode)
566568
{
@@ -571,20 +573,29 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
571573
$options = $product->getOptions();
572574
}
573575
if ($options !== null) {
576+
$results = [];
574577
foreach ($options as $option) {
575578
/* @var $option \Magento\Catalog\Model\Product\Option */
576-
$group = $option->groupFactory($option->getType())
577-
->setOption($option)
578-
->setProduct($product)
579-
->setRequest($buyRequest)
580-
->setProcessMode($processMode)
581-
->validateUserValue($buyRequest->getOptions());
579+
try {
580+
$group = $option->groupFactory($option->getType())
581+
->setOption($option)
582+
->setProduct($product)
583+
->setRequest($buyRequest)
584+
->setProcessMode($processMode)
585+
->validateUserValue($buyRequest->getOptions());
586+
} catch (LocalizedException $e) {
587+
$results[] = $e->getMessage();
588+
continue;
589+
}
582590

583591
$preparedValue = $group->prepareForCart();
584592
if ($preparedValue !== null) {
585593
$transport->options[$option->getId()] = $preparedValue;
586594
}
587595
}
596+
if (count($results) > 0) {
597+
throw new LocalizedException(__(implode("\n", $results)));
598+
}
588599
}
589600

590601
$eventName = sprintf('catalog_product_type_prepare_%s_options', $processMode);

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,17 +522,14 @@ public function duplicate($oldId, $newId)
522522
)->where(
523523
$this->getLinkField() . ' = ?',
524524
$oldId
525-
)->where(
526-
'store_id >= ?',
527-
0
528525
);
529526

530527
$connection->query(
531528
$connection->insertFromSelect(
532529
$select,
533530
$tableName,
534531
['attribute_id', 'store_id', $this->getLinkField(), 'value'],
535-
\Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE
532+
\Magento\Framework\DB\Adapter\AdapterInterface::INSERT_IGNORE
536533
)
537534
);
538535
}
@@ -541,7 +538,6 @@ public function duplicate($oldId, $newId)
541538
$statusAttribute = $this->getAttribute('status');
542539
$statusAttributeId = $statusAttribute->getAttributeId();
543540
$statusAttributeTable = $statusAttribute->getBackend()->getTable();
544-
$updateCond[] = 'store_id >= 0';
545541
$updateCond[] = $connection->quoteInto($this->getLinkField() . ' = ?', $newId);
546542
$updateCond[] = $connection->quoteInto('attribute_id = ?', $statusAttributeId);
547543
$connection->update(

app/code/Magento/Catalog/Model/Webapi/Product/Option/Type/File/Processor.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
use Magento\Framework\App\Filesystem\DirectoryList;
99
use Magento\Framework\Api\Data\ImageContentInterface;
10-
use Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory;
1110
use Magento\Framework\Api\ImageProcessor;
1211
use Magento\Framework\Filesystem;
1312

@@ -20,7 +19,7 @@ class Processor
2019
protected $imageProcessor;
2120

2221
/** @var string */
23-
protected $destinationFolder = '/custom_options/quote';
22+
protected $destinationFolder = 'custom_options/quote';
2423

2524
/**
2625
* @param Filesystem $filesystem
@@ -40,9 +39,8 @@ public function __construct(
4039
*/
4140
protected function saveFile(ImageContentInterface $imageContent)
4241
{
43-
$uri = $this->filesystem->getUri(DirectoryList::MEDIA);
4442
$filePath = $this->imageProcessor->processImageContent($this->destinationFolder, $imageContent);
45-
return $uri . $this->destinationFolder . $filePath;
43+
return $this->destinationFolder . $filePath;
4644
}
4745

4846
/**
@@ -54,8 +52,8 @@ public function processFileContent(ImageContentInterface $imageContent)
5452
{
5553
$filePath = $this->saveFile($imageContent);
5654

57-
$fileAbsolutePath = $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath($filePath);
58-
$fileHash = md5($this->filesystem->getDirectoryRead(DirectoryList::ROOT)->readFile($filePath));
55+
$fileAbsolutePath = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath($filePath);
56+
$fileHash = md5($this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->readFile($filePath));
5957
$imageSize = getimagesize($fileAbsolutePath);
6058
$result = [
6159
'type' => $imageContent->getType(),

app/code/Magento/Catalog/Model/Webapi/Product/Option/Type/File/Validator.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)