Skip to content

Commit b2bb694

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents d72cc2e + c9338ad commit b2bb694

File tree

66 files changed

+772
-383
lines changed

Some content is hidden

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

66 files changed

+772
-383
lines changed

app/code/Magento/AuthorizenetAcceptjs/view/adminhtml/templates/payment/script.phtml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@
66

77
/** @var Magento\AuthorizenetAcceptjs\Block\Payment $block */
88
?>
9-
<script type="text/x-magento-init">
10-
{
11-
"#payment_form_<?= $block->escapeJs($block->escapeHtml($block->getMethodCode())) ?>": {
12-
"Magento_AuthorizenetAcceptjs/js/payment-form": {
13-
"config": <?= /* @noEscape */ $block->getPaymentConfig() ?>
14-
}
15-
}
16-
}
17-
</script>
9+
<script>
10+
//<![CDATA[
11+
require(
12+
[
13+
'Magento_AuthorizenetAcceptjs/js/authorizenet',
14+
'jquery',
15+
'domReady!'
16+
], function(AuthorizenetAcceptjs, $) {
17+
var config = <?= /* @noEscape */ $block->getPaymentConfig() ?>,
18+
form = $('#payment_form_<?= /* @noEscape */ $block->escapeJs($block->escapeHtml($block->getMethodCode())) ?>');
19+
20+
config.active = form.length > 0 && !form.is(':hidden');
21+
new AuthorizenetAcceptjs(config);
22+
});
23+
//]]>
24+
</script>

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Model\Product\Type;
79

810
use Magento\Catalog\Model\Product;
@@ -91,6 +93,11 @@ class Price
9193
*/
9294
private $tierPriceExtensionFactory;
9395

96+
/**
97+
* @var \Magento\CatalogRule\Model\RuleDateFormatterInterface
98+
*/
99+
private $ruleDateFormatter;
100+
94101
/**
95102
* Constructor
96103
*
@@ -104,6 +111,7 @@ class Price
104111
* @param \Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory
105112
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
106113
* @param ProductTierPriceExtensionFactory|null $tierPriceExtensionFactory
114+
* @param \Magento\CatalogRule\Model\RuleDateFormatterInterface|null $ruleDateFormatter
107115
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
108116
*/
109117
public function __construct(
@@ -116,7 +124,8 @@ public function __construct(
116124
GroupManagementInterface $groupManagement,
117125
\Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory $tierPriceFactory,
118126
\Magento\Framework\App\Config\ScopeConfigInterface $config,
119-
ProductTierPriceExtensionFactory $tierPriceExtensionFactory = null
127+
ProductTierPriceExtensionFactory $tierPriceExtensionFactory = null,
128+
\Magento\CatalogRule\Model\RuleDateFormatterInterface $ruleDateFormatter = null
120129
) {
121130
$this->_ruleFactory = $ruleFactory;
122131
$this->_storeManager = $storeManager;
@@ -129,6 +138,8 @@ public function __construct(
129138
$this->config = $config;
130139
$this->tierPriceExtensionFactory = $tierPriceExtensionFactory ?: ObjectManager::getInstance()
131140
->get(ProductTierPriceExtensionFactory::class);
141+
$this->ruleDateFormatter = $ruleDateFormatter ?: ObjectManager::getInstance()
142+
->get(\Magento\CatalogRule\Model\RuleDateFormatterInterface::class);
132143
}
133144

134145
/**
@@ -502,10 +513,10 @@ public function getFormattedTierPrice($qty, $product)
502513
/**
503514
* Get formatted by currency tier price
504515
*
505-
* @param float $qty
506-
* @param Product $product
516+
* @param float $qty
517+
* @param Product $product
507518
*
508-
* @return array|float
519+
* @return array|float
509520
*
510521
* @deprecated
511522
* @see getFormattedTierPrice()
@@ -529,8 +540,8 @@ public function getFormattedPrice($product)
529540
/**
530541
* Get formatted by currency product price
531542
*
532-
* @param Product $product
533-
* @return array || float
543+
* @param Product $product
544+
* @return array || float
534545
*
535546
* @deprecated
536547
* @see getFormattedPrice()
@@ -611,7 +622,7 @@ public function calculatePrice(
611622
);
612623

613624
if ($rulePrice === false) {
614-
$date = $this->_localeDate->scopeDate($sId);
625+
$date = $this->ruleDateFormatter->getDate($sId);
615626
$rulePrice = $this->_ruleFactory->create()->getRulePrice($date, $wId, $gId, $productId);
616627
}
617628

app/code/Magento/Catalog/Test/Mftf/Test/AdminCloneProductWithDuplicateUrlTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="AdminCloneProductWithDuplicateUrlTest">
1212
<annotations>
1313
<features value="Catalog"/>
14+
<stories value="Product"/>
1415
<title value="Cloning a product with duplicate URL key"/>
1516
<description value="Check product cloning with duplicate URL key"/>
1617
<severity value="AVERAGE"/>

app/code/Magento/Catalog/Test/Mftf/Test/AdminRestrictedUserAddCategoryFromProductPageTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="AdminRestrictedUserAddCategoryFromProductPageTest">
1212
<annotations>
1313
<features value="Catalog"/>
14+
<stories value="Category"/>
1415
<title value="Adding new category from product page by restricted user"/>
1516
<description value="Adding new category from product page by restricted user"/>
1617
<severity value="MAJOR"/>

app/code/Magento/Catalog/Test/Mftf/Test/CheckCurrentCategoryIsHighlightedAndProductsDisplayed.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<test name="CheckCurrentCategoryIsHighlightedAndProductsDisplayed">
1212
<annotations>
1313
<features value="Catalog"/>
14+
<stories value="Category"/>
1415
<title value="Сheck that current category is highlighted and all products displayed for it"/>
1516
<description value="Сheck that current category is highlighted and all products displayed for it"/>
1617
<severity value="MAJOR"/>

app/code/Magento/Catalog/view/frontend/templates/product/image.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
?>
77
<?php /** @var $block \Magento\Catalog\Block\Product\Image */ ?>
88

9-
<img class="photo image"
9+
<img class="photo image <?= $block->escapeHtmlAttr($block->getClass()) ?>"
1010
<?= $block->escapeHtml($block->getCustomAttributes()) ?>
1111
src="<?= $block->escapeUrl($block->getImageUrl()) ?>"
1212
width="<?= $block->escapeHtmlAttr($block->getWidth()) ?>"

app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
230230
{
231231
$connection = $this->getConnection();
232232
$qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0);
233-
$metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
234-
$linkField = $metadata->getLinkField();
235233

236234
$select = $connection->select()->from(
237235
['e' => $this->getTable('catalog_product_entity')],
@@ -245,12 +243,6 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f
245243
['cisi' => $this->getTable('cataloginventory_stock_item')],
246244
'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id',
247245
[]
248-
)->joinInner(
249-
['mcpei' => $this->getTable('catalog_product_entity_int')],
250-
'e.' . $linkField . ' = mcpei.' . $linkField
251-
. ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId()
252-
. ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED,
253-
[]
254246
)->columns(
255247
['qty' => $qtyExpr]
256248
)->where(

app/code/Magento/CatalogRule/Model/ResourceModel/Product/CollectionProcessor.php

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\CatalogRule\Model\ResourceModel\Product;
810

911
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1012
use Magento\CatalogRule\Pricing\Price\CatalogRulePrice;
13+
use Magento\Framework\App\ObjectManager;
1114

1215
/**
1316
* Add catalog rule prices to collection
17+
*
18+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1419
*/
1520
class CollectionProcessor
1621
{
@@ -39,28 +44,39 @@ class CollectionProcessor
3944
*/
4045
private $localeDate;
4146

47+
/**
48+
* @var \Magento\CatalogRule\Model\RuleDateFormatterInterface
49+
*/
50+
private $ruleDateFormatter;
51+
4252
/**
4353
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
4454
* @param \Magento\Framework\App\ResourceConnection $resourceConnection
4555
* @param \Magento\Customer\Model\Session $customerSession
4656
* @param \Magento\Framework\Stdlib\DateTime $dateTime
4757
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
58+
* @param \Magento\CatalogRule\Model\RuleDateFormatterInterface|null $ruleDateFormatter
4859
*/
4960
public function __construct(
5061
\Magento\Store\Model\StoreManagerInterface $storeManager,
5162
\Magento\Framework\App\ResourceConnection $resourceConnection,
5263
\Magento\Customer\Model\Session $customerSession,
5364
\Magento\Framework\Stdlib\DateTime $dateTime,
54-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
65+
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
66+
\Magento\CatalogRule\Model\RuleDateFormatterInterface $ruleDateFormatter = null
5567
) {
5668
$this->storeManager = $storeManager;
5769
$this->resource = $resourceConnection;
5870
$this->customerSession = $customerSession;
5971
$this->dateTime = $dateTime;
6072
$this->localeDate = $localeDate;
73+
$this->ruleDateFormatter = $ruleDateFormatter ?: ObjectManager::getInstance()
74+
->get(\Magento\CatalogRule\Model\RuleDateFormatterInterface::class);
6175
}
6276

6377
/**
78+
* Join prices to collection
79+
*
6480
* @param ProductCollection $productCollection
6581
* @param string $joinColumn
6682
* @return ProductCollection
@@ -73,18 +89,21 @@ public function addPriceData(ProductCollection $productCollection, $joinColumn =
7389
$productCollection->getSelect()
7490
->joinLeft(
7591
['catalog_rule' => $this->resource->getTableName('catalogrule_product_price')],
76-
implode(' AND ', [
77-
'catalog_rule.product_id = ' . $connection->quoteIdentifier($joinColumn),
78-
$connection->quoteInto('catalog_rule.website_id = ?', $store->getWebsiteId()),
79-
$connection->quoteInto(
80-
'catalog_rule.customer_group_id = ?',
81-
$this->customerSession->getCustomerGroupId()
82-
),
83-
$connection->quoteInto(
84-
'catalog_rule.rule_date = ?',
85-
$this->dateTime->formatDate($this->localeDate->scopeDate($store->getId()), false)
86-
),
87-
]),
92+
implode(
93+
' AND ',
94+
[
95+
'catalog_rule.product_id = ' . $connection->quoteIdentifier($joinColumn),
96+
$connection->quoteInto('catalog_rule.website_id = ?', $store->getWebsiteId()),
97+
$connection->quoteInto(
98+
'catalog_rule.customer_group_id = ?',
99+
$this->customerSession->getCustomerGroupId()
100+
),
101+
$connection->quoteInto(
102+
'catalog_rule.rule_date = ?',
103+
$this->dateTime->formatDate($this->ruleDateFormatter->getDate($store->getId()), false)
104+
),
105+
]
106+
),
88107
[CatalogRulePrice::PRICE_CODE => 'rule_price']
89108
);
90109
$productCollection->setFlag('catalog_rule_loaded', true);

app/code/Magento/CatalogRule/Model/ResourceModel/Product/LinkedProductSelectBuilderByCatalogRulePrice.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogRule\Model\ResourceModel\Product;
79

810
use Magento\Catalog\Api\Data\ProductInterface;
@@ -11,6 +13,11 @@
1113
use Magento\Framework\DB\Select;
1214
use Magento\Catalog\Model\ResourceModel\Product\LinkedProductSelectBuilderInterface;
1315

16+
/**
17+
* Provide Select object for retrieve product id with minimal price
18+
*
19+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
20+
*/
1421
class LinkedProductSelectBuilderByCatalogRulePrice implements LinkedProductSelectBuilderInterface
1522
{
1623
/**
@@ -48,6 +55,11 @@ class LinkedProductSelectBuilderByCatalogRulePrice implements LinkedProductSelec
4855
*/
4956
private $baseSelectProcessor;
5057

58+
/**
59+
* @var \Magento\CatalogRule\Model\RuleDateFormatterInterface
60+
*/
61+
private $ruleDateFormatter;
62+
5163
/**
5264
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
5365
* @param \Magento\Framework\App\ResourceConnection $resourceConnection
@@ -56,6 +68,7 @@ class LinkedProductSelectBuilderByCatalogRulePrice implements LinkedProductSelec
5668
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
5769
* @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
5870
* @param BaseSelectProcessorInterface $baseSelectProcessor
71+
* @param \Magento\CatalogRule\Model\RuleDateFormatterInterface|null $ruleDateFormatter
5972
*/
6073
public function __construct(
6174
\Magento\Store\Model\StoreManagerInterface $storeManager,
@@ -64,7 +77,8 @@ public function __construct(
6477
\Magento\Framework\Stdlib\DateTime $dateTime,
6578
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
6679
\Magento\Framework\EntityManager\MetadataPool $metadataPool,
67-
BaseSelectProcessorInterface $baseSelectProcessor = null
80+
BaseSelectProcessorInterface $baseSelectProcessor = null,
81+
\Magento\CatalogRule\Model\RuleDateFormatterInterface $ruleDateFormatter = null
6882
) {
6983
$this->storeManager = $storeManager;
7084
$this->resource = $resourceConnection;
@@ -74,14 +88,16 @@ public function __construct(
7488
$this->metadataPool = $metadataPool;
7589
$this->baseSelectProcessor = (null !== $baseSelectProcessor)
7690
? $baseSelectProcessor : ObjectManager::getInstance()->get(BaseSelectProcessorInterface::class);
91+
$this->ruleDateFormatter = $ruleDateFormatter ?: ObjectManager::getInstance()
92+
->get(\Magento\CatalogRule\Model\RuleDateFormatterInterface::class);
7793
}
7894

7995
/**
80-
* {@inheritdoc}
96+
* @inheritdoc
8197
*/
8298
public function build($productId)
8399
{
84-
$timestamp = $this->localeDate->scopeTimeStamp($this->storeManager->getStore());
100+
$timestamp = $this->ruleDateFormatter->getTimeStamp($this->storeManager->getStore());
85101
$currentDate = $this->dateTime->formatDate($timestamp, false);
86102
$linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
87103
$productTable = $this->resource->getTableName('catalog_product_entity');
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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\CatalogRule\Model;
9+
10+
/**
11+
* Local date for catalog rule
12+
*/
13+
class RuleDateFormatter implements \Magento\CatalogRule\Model\RuleDateFormatterInterface
14+
{
15+
/**
16+
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
17+
*/
18+
private $localeDate;
19+
20+
/**
21+
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
22+
*/
23+
public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate)
24+
{
25+
$this->localeDate = $localeDate;
26+
}
27+
28+
/**
29+
* @inheritdoc
30+
*/
31+
public function getDate($scope = null): \DateTime
32+
{
33+
return $this->localeDate->scopeDate($scope, null, true);
34+
}
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
public function getTimeStamp($scope = null): int
40+
{
41+
return $this->localeDate->scopeTimeStamp($scope);
42+
}
43+
}

0 commit comments

Comments
 (0)