Skip to content

Commit 3826de0

Browse files
merge magento/2.4-develop into magento-architects/catalog-image-resizing
2 parents d4317c4 + 606c3e8 commit 3826de0

File tree

175 files changed

+4550
-874
lines changed

Some content is hidden

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

175 files changed

+4550
-874
lines changed

app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
<seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/>
2525
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
2626
</test>
27-
</tests>
27+
</tests>

app/code/Magento/Backend/view/adminhtml/web/js/translate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ define([
3535
* @return {String}
3636
*/
3737
this.translate = function (text) {
38-
return _data[text] ? _data[text] : text;
38+
return typeof _data[text] === 'string' ? _data[text] : text;
3939
};
4040

4141
return this;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ define([
269269
*/
270270
onError: function () {
271271
self.showError($t('Payment ' + self.getTitle() + ' can\'t be initialized'));
272+
self.reInitPayPal();
272273
}
273274
}, self.paypalButtonSelector);
274275
},

app/code/Magento/CardinalCommerce/Test/Mftf/Test/AdminCardinalCommerceSettingsHiddenTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<test name="AdminCardinalCommerceSettingsHiddenTest">
1111
<annotations>
12+
<stories value="Cardinal Commerce Settings"/>
1213
<features value="CardinalCommerce"/>
1314
<title value="CardinalCommerce settings hidden" />
1415
<description value="CardinalCommerce config shouldn't be visible if the 3D secure is disabled for Authorize.Net."/>

app/code/Magento/Catalog/Block/Ui/ProductViewCounter.php

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
namespace Magento\Catalog\Block\Ui;
77

88
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\Catalog\Model\ProductRenderFactory;
10+
use Magento\Catalog\Model\ProductRepository;
911
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorComposite;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\EntityManager\Hydrator;
1015
use Magento\Framework\Registry;
1116
use Magento\Framework\Serialize\SerializerInterface;
1217
use Magento\Framework\Url;
1318
use Magento\Framework\View\Element\Template;
1419
use Magento\Store\Model\Store;
15-
use Magento\Catalog\Model\ProductRenderFactory;
16-
use Magento\Catalog\Model\ProductRepository;
17-
use Magento\Framework\EntityManager\Hydrator;
1820
use Magento\Store\Model\StoreManager;
1921

2022
/**
@@ -25,6 +27,7 @@
2527
*
2628
* @api
2729
* @since 101.1.0
30+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2831
*/
2932
class ProductViewCounter extends Template
3033
{
@@ -68,6 +71,13 @@ class ProductViewCounter extends Template
6871
*/
6972
private $registry;
7073

74+
/**
75+
* Core store config
76+
*
77+
* @var ScopeConfigInterface
78+
*/
79+
private $scopeConfig;
80+
7181
/**
7282
* @param Template\Context $context
7383
* @param ProductRepository $productRepository
@@ -78,6 +88,8 @@ class ProductViewCounter extends Template
7888
* @param SerializerInterface $serialize
7989
* @param Url $url
8090
* @param Registry $registry
91+
* @param ScopeConfigInterface|null $scopeConfig
92+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8193
*/
8294
public function __construct(
8395
Template\Context $context,
@@ -88,7 +100,8 @@ public function __construct(
88100
Hydrator $hydrator,
89101
SerializerInterface $serialize,
90102
Url $url,
91-
Registry $registry
103+
Registry $registry,
104+
?ScopeConfigInterface $scopeConfig = null
92105
) {
93106
parent::__construct($context);
94107
$this->productRepository = $productRepository;
@@ -99,6 +112,7 @@ public function __construct(
99112
$this->serialize = $serialize;
100113
$this->url = $url;
101114
$this->registry = $registry;
115+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
102116
}
103117

104118
/**
@@ -116,14 +130,19 @@ public function getCurrentProductData()
116130
{
117131
/** @var ProductInterface $product */
118132
$product = $this->registry->registry('product');
133+
$productsScope = $this->scopeConfig->getValue(
134+
'catalog/recently_products/scope',
135+
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
136+
);
119137
/** @var Store $store */
120138
$store = $this->storeManager->getStore();
121139

122140
if (!$product || !$product->getId()) {
123141
return $this->serialize->serialize([
124142
'items' => [],
125143
'store' => $store->getId(),
126-
'currency' => $store->getCurrentCurrency()->getCode()
144+
'currency' => $store->getCurrentCurrency()->getCode(),
145+
'productCurrentScope' => $productsScope
127146
]);
128147
}
129148

@@ -140,7 +159,8 @@ public function getCurrentProductData()
140159
$product->getId() => $data
141160
],
142161
'store' => $store->getId(),
143-
'currency' => $store->getCurrentCurrency()->getCode()
162+
'currency' => $store->getCurrentCurrency()->getCode(),
163+
'productCurrentScope' => $productsScope
144164
];
145165

146166
return $this->serialize->serialize($currentProductData);

app/code/Magento/Catalog/CustomerData/CompareProducts.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
namespace Magento\Catalog\CustomerData;
77

88
use Magento\Customer\CustomerData\SectionSourceInterface;
9+
use Magento\Framework\App\Config\ScopeConfigInterface;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\LocalizedException;
912

13+
/**
14+
* Catalog Product Compare Widget
15+
*/
1016
class CompareProducts implements SectionSourceInterface
1117
{
1218
/**
@@ -24,23 +30,33 @@ class CompareProducts implements SectionSourceInterface
2430
*/
2531
private $outputHelper;
2632

33+
/**
34+
* Core store config
35+
*
36+
* @var ScopeConfigInterface
37+
*/
38+
private $scopeConfig;
39+
2740
/**
2841
* @param \Magento\Catalog\Helper\Product\Compare $helper
2942
* @param \Magento\Catalog\Model\Product\Url $productUrl
3043
* @param \Magento\Catalog\Helper\Output $outputHelper
44+
* @param ScopeConfigInterface|null $scopeConfig
3145
*/
3246
public function __construct(
3347
\Magento\Catalog\Helper\Product\Compare $helper,
3448
\Magento\Catalog\Model\Product\Url $productUrl,
35-
\Magento\Catalog\Helper\Output $outputHelper
49+
\Magento\Catalog\Helper\Output $outputHelper,
50+
?ScopeConfigInterface $scopeConfig = null
3651
) {
3752
$this->helper = $helper;
3853
$this->productUrl = $productUrl;
3954
$this->outputHelper = $outputHelper;
55+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
4056
}
4157

4258
/**
43-
* {@inheritdoc}
59+
* @inheritdoc
4460
*/
4561
public function getSectionData()
4662
{
@@ -54,18 +70,26 @@ public function getSectionData()
5470
}
5571

5672
/**
73+
* Get the list of compared product items
74+
*
5775
* @return array
76+
* @throws LocalizedException
5877
*/
5978
protected function getItems()
6079
{
6180
$items = [];
81+
$productsScope = $this->scopeConfig->getValue(
82+
'catalog/recently_products/scope',
83+
\Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE
84+
);
6285
/** @var \Magento\Catalog\Model\Product $item */
6386
foreach ($this->helper->getItemCollection() as $item) {
6487
$items[] = [
6588
'id' => $item->getId(),
6689
'product_url' => $this->productUrl->getUrl($item),
6790
'name' => $this->outputHelper->productAttribute($item, $item->getName(), 'name'),
6891
'remove_url' => $this->helper->getPostDataRemove($item),
92+
'productScope' => $productsScope
6993
];
7094
}
7195
return $items;

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

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

8+
use Magento\Catalog\Api\Data\ProductInterface;
89
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
910

1011
/**
@@ -14,6 +15,32 @@
1415
*/
1516
class Action extends \Magento\Catalog\Model\ResourceModel\AbstractResource
1617
{
18+
/**
19+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
20+
*/
21+
private $dateTime;
22+
23+
/**
24+
* @param \Magento\Eav\Model\Entity\Context $context
25+
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
26+
* @param \Magento\Catalog\Model\Factory $modelFactory
27+
* @param \Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator
28+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
29+
* @param array $data
30+
*/
31+
public function __construct(
32+
\Magento\Eav\Model\Entity\Context $context,
33+
\Magento\Store\Model\StoreManagerInterface $storeManager,
34+
\Magento\Catalog\Model\Factory $modelFactory,
35+
\Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface $uniqueValidator,
36+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
37+
$data = []
38+
) {
39+
parent::__construct($context, $storeManager, $modelFactory, $data, $uniqueValidator);
40+
41+
$this->dateTime = $dateTime;
42+
}
43+
1744
/**
1845
* Initialize connection
1946
*
@@ -43,6 +70,7 @@ public function updateAttributes($entityIds, $attrData, $storeId)
4370
$object = new \Magento\Framework\DataObject();
4471
$object->setStoreId($storeId);
4572

73+
$attrData[ProductInterface::UPDATED_AT] = $this->dateTime->gmtDate();
4674
$this->getConnection()->beginTransaction();
4775
try {
4876
foreach ($attrData as $attrCode => $value) {
@@ -95,7 +123,7 @@ protected function _saveAttributeValue($object, $attribute, $value)
95123
* for default store id
96124
* In this case we clear all not default values
97125
*/
98-
if ($this->_storeManager->hasSingleStore()) {
126+
if ($this->_storeManager->hasSingleStore() && !$attribute->isStatic()) {
99127
$storeId = $this->getDefaultStoreId();
100128
$connection->delete(
101129
$table,
@@ -107,17 +135,24 @@ protected function _saveAttributeValue($object, $attribute, $value)
107135
);
108136
}
109137

110-
$data = new \Magento\Framework\DataObject(
111-
[
112-
'attribute_id' => $attribute->getAttributeId(),
113-
'store_id' => $storeId,
114-
$this->getLinkField() => $entityId,
115-
'value' => $this->_prepareValueForSave($value, $attribute),
116-
]
117-
);
138+
$data = $attribute->isStatic()
139+
? new \Magento\Framework\DataObject(
140+
[
141+
$this->getLinkField() => $entityId,
142+
$attribute->getAttributeCode() => $this->_prepareValueForSave($value, $attribute),
143+
]
144+
)
145+
: new \Magento\Framework\DataObject(
146+
[
147+
'attribute_id' => $attribute->getAttributeId(),
148+
'store_id' => $storeId,
149+
$this->getLinkField() => $entityId,
150+
'value' => $this->_prepareValueForSave($value, $attribute),
151+
]
152+
);
118153
$bind = $this->_prepareDataForTable($data, $table);
119154

120-
if ($attribute->isScopeStore()) {
155+
if ($attribute->isScopeStore() || $attribute->isStatic()) {
121156
/**
122157
* Update attribute value for store
123158
*/
@@ -143,6 +178,8 @@ protected function _saveAttributeValue($object, $attribute, $value)
143178
}
144179

145180
/**
181+
* Resolve entity id
182+
*
146183
* @param int $entityId
147184
* @return int
148185
*/

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
1616
use Magento\Framework\Search\Request\IndexScopeResolverInterface;
1717

18+
/**
19+
* Class LinkedProductSelectBuilderByIndexPrice
20+
*
21+
* Provide Select object for retrieve product id by index price.
22+
*
23+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
24+
*/
1825
class LinkedProductSelectBuilderByIndexPrice implements LinkedProductSelectBuilderInterface
1926
{
2027
/**
@@ -83,13 +90,13 @@ public function __construct(
8390
}
8491

8592
/**
86-
* {@inheritdoc}
93+
* @inheritdoc
8794
*/
88-
public function build($productId)
95+
public function build(int $productId, int $storeId) : array
8996
{
9097
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
9198
$productTable = $this->resource->getTableName('catalog_product_entity');
92-
$websiteId = $this->storeManager->getStore()->getWebsiteId();
99+
$websiteId = $this->storeManager->getStore($storeId)->getWebsiteId();
93100
$customerGroupId = $this->customerSession->getCustomerGroupId();
94101

95102
$priceSelect = $this->resource->getConnection()->select()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function __construct(
7474
/**
7575
* @inheritdoc
7676
*/
77-
public function build($productId)
77+
public function build(int $productId, int $storeId) : array
7878
{
7979
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
8080
$priceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'price');
@@ -104,7 +104,7 @@ public function build($productId)
104104

105105
if (!$this->catalogHelper->isPriceGlobal()) {
106106
$priceSelectStore = clone $priceSelect;
107-
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
107+
$priceSelectStore->where('t.store_id = ?', $storeId);
108108
$selects[] = $priceSelectStore;
109109
}
110110

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
use Magento\Store\Model\Store;
1313

1414
/**
15+
* LinkedProductSelectBuilderBySpecialPrice
16+
*
17+
* Provide Select object for retrieve product id by special price
18+
*
1519
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1620
*/
1721
class LinkedProductSelectBuilderBySpecialPrice implements LinkedProductSelectBuilderInterface
@@ -88,16 +92,16 @@ public function __construct(
8892
}
8993

9094
/**
91-
* {@inheritdoc}
95+
* @inheritdoc
9296
*/
93-
public function build($productId)
97+
public function build(int $productId, int $storeId) : array
9498
{
9599
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
96100
$connection = $this->resource->getConnection();
97101
$specialPriceAttribute = $this->eavConfig->getAttribute(Product::ENTITY, 'special_price');
98102
$specialPriceFromDate = $this->eavConfig->getAttribute(Product::ENTITY, 'special_from_date');
99103
$specialPriceToDate = $this->eavConfig->getAttribute(Product::ENTITY, 'special_to_date');
100-
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
104+
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore($storeId));
101105
$currentDate = $this->dateTime->formatDate($timestamp, false);
102106
$productTable = $this->resource->getTableName('catalog_product_entity');
103107

@@ -145,7 +149,7 @@ public function build($productId)
145149

146150
if (!$this->catalogHelper->isPriceGlobal()) {
147151
$priceSelectStore = clone $specialPrice;
148-
$priceSelectStore->where('t.store_id = ?', $this->storeManager->getStore()->getId());
152+
$priceSelectStore->where('t.store_id = ?', $storeId);
149153
$selects[] = $priceSelectStore;
150154
}
151155

0 commit comments

Comments
 (0)