Skip to content

Commit 4cd6b55

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MC-36683
2 parents 772d178 + 1c3837c commit 4cd6b55

File tree

86 files changed

+2981
-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.

86 files changed

+2981
-142
lines changed

app/code/Magento/Bundle/Pricing/Price/BundleSelectionFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ public function create(
5252
$quantity,
5353
array $arguments = []
5454
) {
55+
$quantity = $quantity ? (float)$quantity : 1.;
56+
$selection->setQty($quantity);
57+
5558
$arguments['bundleProduct'] = $bundleProduct;
5659
$arguments['saleableItem'] = $selection;
57-
$arguments['quantity'] = $quantity ? (float)$quantity : 1.;
60+
$arguments['quantity'] = $quantity;
5861

5962
return $this->objectManager->create(self::SELECTION_CLASS_DEFAULT, $arguments);
6063
}

app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ $scriptString .= <<<script
7777
dataUrl: '{$block->escapeJs($block->escapeUrl($block->getLoadTreeUrl()))}'
7878
});
7979
80+
categoryLoader.processResponse = function (response, parent, callback) {
81+
var config = JSON.parse(response.responseText);
82+
83+
this.buildCategoryTree(parent, config);
84+
85+
if (typeof callback == "function") {
86+
callback(this, parent);
87+
}
88+
};
89+
8090
categoryLoader.buildCategoryTree = function(parent, config)
8191
{
8292
if (!config) return null;
@@ -164,8 +174,10 @@ $scriptString .= <<<script
164174
};
165175
166176
categoryLoader.on("beforeload", function(treeLoader, node) {
167-
$('{$block->escapeJs($_divId)}').fire('category:beforeLoad', {treeLoader:treeLoader});
168177
treeLoader.baseParams.id = node.attributes.id;
178+
treeLoader.baseParams.store = node.attributes.store;
179+
treeLoader.baseParams.form_key = FORM_KEY;
180+
$('{$block->escapeJs($_divId)}').fire('category:beforeLoad', {treeLoader:treeLoader});
169181
});
170182
171183
tree{$block->escapeJs($block->getId())} = new Ext.tree.TreePanel.Enhanced('{$block->escapeJs($_divId)}', {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public function isValid($value)
114114
]
115115
);
116116
$valid = false;
117+
break;
117118
}
118-
break;
119119
}
120120
}
121121
return $valid;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CatalogRuleGraphQl\Plugin\Pricing\Price;
9+
10+
use Magento\CatalogRule\Model\ResourceModel\Rule;
11+
use Magento\CatalogRule\Pricing\Price\CatalogRulePrice;
12+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
13+
14+
/**
15+
* Class UpdateCatalogRulePrice
16+
*
17+
* Plugin to update catalog rule price based on customer group id
18+
*/
19+
class UpdateCatalogRulePrice
20+
{
21+
/**
22+
* @var TimezoneInterface
23+
*/
24+
private $dateTime;
25+
26+
/**
27+
* @var Rule
28+
*/
29+
private $ruleResource;
30+
31+
/**
32+
* @param TimezoneInterface $dateTime
33+
* @param Rule $ruleResource
34+
*/
35+
public function __construct(
36+
TimezoneInterface $dateTime,
37+
Rule $ruleResource
38+
) {
39+
$this->dateTime = $dateTime;
40+
$this->ruleResource = $ruleResource;
41+
}
42+
43+
/**
44+
* Returns catalog rule value for logged in customer group
45+
*
46+
* @param CatalogRulePrice $catalogRulePrice
47+
* @param float|boolean $value
48+
* @return float|boolean
49+
*/
50+
public function afterGetValue(
51+
CatalogRulePrice $catalogRulePrice,
52+
$value
53+
) {
54+
$product = $catalogRulePrice->getProduct();
55+
if ($product && $product->getCustomerGroupId()) {
56+
$store = $product->getStore();
57+
$value = $this->ruleResource->getRulePrice(
58+
$this->dateTime->scopeDate($store->getId()),
59+
$store->getWebsiteId(),
60+
$product->getCustomerGroupId(),
61+
$product->getId()
62+
);
63+
$value = $value ? (float) $value : false;
64+
}
65+
66+
return $value;
67+
}
68+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
9+
<type name="Magento\CatalogRule\Pricing\Price\CatalogRulePrice">
10+
<plugin name="update_catalog_rule_price_for_logged_in_customer_group" type="Magento\CatalogRuleGraphQl\Plugin\Pricing\Price\UpdateCatalogRulePrice"/>
11+
</type>
12+
</config>

app/code/Magento/CatalogUrlRewrite/etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
</argument>
6060
</arguments>
6161
</type>
62+
<type name="Magento\UrlRewrite\Model\UrlRewrite">
63+
<arguments>
64+
<argument name="entityToCacheTagMap" xsi:type="array">
65+
<item name="product" xsi:type="const">Magento\Catalog\Model\Product::CACHE_TAG</item>
66+
<item name="category" xsi:type="const">Magento\Catalog\Model\Category::CACHE_TAG</item>
67+
</argument>
68+
</arguments>
69+
</type>
6270
<type name="Magento\Eav\Model\Config">
6371
<arguments>
6472
<argument name="attributesForPreload" xsi:type="array">

app/code/Magento/CmsUrlRewrite/etc/di.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
<type name="Magento\Cms\Model\ResourceModel\Page">
1010
<plugin name="cms_url_rewrite_plugin" type="Magento\CmsUrlRewrite\Plugin\Cms\Model\ResourceModel\Page"/>
1111
</type>
12+
<type name="Magento\UrlRewrite\Model\UrlRewrite">
13+
<arguments>
14+
<argument name="entityToCacheTagMap" xsi:type="array">
15+
<item name="cms-page" xsi:type="const">Magento\Cms\Model\Page::CACHE_TAG</item>
16+
</argument>
17+
</arguments>
18+
</type>
1219
</config>
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Customer\Controller\Adminhtml\Address;
9+
10+
use Magento\Customer\Api\AddressMetadataInterface;
11+
use Magento\Framework\Exception\NotFoundException;
12+
use Magento\Framework\App\Filesystem\DirectoryList;
13+
use Magento\Framework\Controller\Result\RawFactory;
14+
use Magento\Framework\Url\DecoderInterface;
15+
use Magento\Framework\Controller\ResultInterface;
16+
use Magento\Framework\Filesystem;
17+
use Magento\Framework\Controller\Result\Raw;
18+
use Magento\MediaStorage\Helper\File\Storage;
19+
use Magento\Framework\App\Response\Http\FileFactory;
20+
use Magento\Framework\Filesystem\Io\File as IoFile;
21+
use Magento\Backend\App\Action\Context;
22+
use Magento\Framework\App\Action\HttpGetActionInterface;
23+
use Magento\Backend\App\Action;
24+
25+
/**
26+
* Class Viewfile serves to show file or image by file/image name provided in request parameters.
27+
*/
28+
class Viewfile extends Action implements HttpGetActionInterface
29+
{
30+
/**
31+
* Authorization level of a basic admin session
32+
*/
33+
const ADMIN_RESOURCE = 'Magento_Customer::manage';
34+
35+
/**
36+
* @var RawFactory
37+
*/
38+
private $resultRawFactory;
39+
40+
/**
41+
* @var DecoderInterface
42+
*/
43+
private $urlDecoder;
44+
45+
/**
46+
* @var Filesystem
47+
*/
48+
private $filesystem;
49+
50+
/**
51+
* @var Storage
52+
*/
53+
private $storage;
54+
55+
/**
56+
* @var FileFactory
57+
*/
58+
private $fileFactory;
59+
60+
/**
61+
* @var IoFile
62+
*/
63+
private $ioFile;
64+
65+
/**
66+
* @param Context $context
67+
* @param FileFactory $fileFactory
68+
* @param RawFactory $resultRawFactory
69+
* @param DecoderInterface $urlDecoder
70+
* @param Filesystem $filesystem
71+
* @param Storage $storage
72+
* @param IoFile $ioFile
73+
*/
74+
public function __construct(
75+
Context $context,
76+
FileFactory $fileFactory,
77+
RawFactory $resultRawFactory,
78+
DecoderInterface $urlDecoder,
79+
Filesystem $filesystem,
80+
Storage $storage,
81+
IoFile $ioFile
82+
) {
83+
parent::__construct($context);
84+
$this->resultRawFactory = $resultRawFactory;
85+
$this->urlDecoder = $urlDecoder;
86+
$this->filesystem = $filesystem;
87+
$this->storage = $storage;
88+
$this->fileFactory = $fileFactory;
89+
$this->ioFile = $ioFile;
90+
}
91+
92+
/**
93+
* Customer address view file action
94+
*
95+
* @return ResultInterface|void
96+
* @throws NotFoundException
97+
*/
98+
public function execute()
99+
{
100+
list($file, $plain) = $this->getFileParams();
101+
102+
$directory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
103+
$fileName = AddressMetadataInterface::ENTITY_TYPE_ADDRESS . DIRECTORY_SEPARATOR .
104+
ltrim($file, DIRECTORY_SEPARATOR);
105+
$path = $directory->getAbsolutePath($fileName);
106+
if (mb_strpos($path, '..') !== false
107+
|| (!$directory->isFile($fileName) && !$this->storage->processStorageFile($path))
108+
) {
109+
throw new NotFoundException(__('Page not found.'));
110+
}
111+
112+
$pathInfo = $this->ioFile->getPathInfo($path);
113+
if ($plain) {
114+
$extension = $pathInfo['extension'];
115+
switch (strtolower($extension)) {
116+
case 'gif':
117+
$contentType = 'image/gif';
118+
break;
119+
case 'jpg':
120+
$contentType = 'image/jpeg';
121+
break;
122+
case 'png':
123+
$contentType = 'image/png';
124+
break;
125+
default:
126+
$contentType = 'application/octet-stream';
127+
break;
128+
}
129+
$stat = $directory->stat($fileName);
130+
$contentLength = $stat['size'];
131+
$contentModify = $stat['mtime'];
132+
133+
/** @var Raw $resultRaw */
134+
$resultRaw = $this->resultRawFactory->create();
135+
$resultRaw->setHttpResponseCode(200)
136+
->setHeader('Pragma', 'public', true)
137+
->setHeader('Content-type', $contentType, true)
138+
->setHeader('Content-Length', $contentLength)
139+
->setHeader('Last-Modified', date('r', $contentModify));
140+
$resultRaw->setContents($directory->readFile($fileName));
141+
142+
return $resultRaw;
143+
} else {
144+
$name = $pathInfo['basename'];
145+
$this->fileFactory->create(
146+
$name,
147+
['type' => 'filename', 'value' => $fileName],
148+
DirectoryList::MEDIA
149+
);
150+
}
151+
}
152+
153+
/**
154+
* Get parameters from request.
155+
*
156+
* @return array
157+
* @throws NotFoundException
158+
*/
159+
private function getFileParams() : array
160+
{
161+
$file = null;
162+
$plain = false;
163+
if ($this->getRequest()->getParam('file')) {
164+
// download file
165+
$file = $this->urlDecoder->decode(
166+
$this->getRequest()->getParam('file')
167+
);
168+
} elseif ($this->getRequest()->getParam('image')) {
169+
// show plain image
170+
$file = $this->urlDecoder->decode(
171+
$this->getRequest()->getParam('image')
172+
);
173+
$plain = true;
174+
} else {
175+
throw new NotFoundException(__('Page not found.'));
176+
}
177+
178+
return [$file, $plain];
179+
}
180+
}

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,11 @@ protected function _implodeArrayValues($value)
331331
return '';
332332
}
333333

334-
$isScalar = false;
334+
$isScalar = true;
335335
foreach ($value as $val) {
336-
if (is_scalar($val)) {
337-
$isScalar = true;
336+
if (!is_scalar($val)) {
337+
$isScalar = false;
338+
break;
338339
}
339340
}
340341
if ($isScalar) {

app/code/Magento/Customer/Model/FileProcessor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ public function getViewUrl($filePath, $type)
158158
$viewUrl = '';
159159

160160
if ($this->entityTypeCode == AddressMetadataInterface::ENTITY_TYPE_ADDRESS) {
161-
$filePath = $this->entityTypeCode . '/' . ltrim($filePath, '/');
162-
$viewUrl = $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA])
163-
. $this->mediaDirectory->getRelativePath($filePath);
161+
$viewUrl = $this->urlBuilder->getUrl(
162+
'customer/address/viewfile',
163+
[$type => $this->urlEncoder->encode(ltrim($filePath, '/'))]
164+
);
164165
}
165166

166167
if ($this->entityTypeCode == CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER) {

0 commit comments

Comments
 (0)