Skip to content

Commit b246165

Browse files
Merge branch 2.2-develop into ENGCOM-4041-magento-magento2-20743
2 parents 2d0d6d1 + 6480499 commit b246165

File tree

43 files changed

+412
-132
lines changed

Some content is hidden

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

43 files changed

+412
-132
lines changed

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717

1818
/**
19+
* Attributes attributes block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -56,6 +58,8 @@ public function __construct(
5658
}
5759

5860
/**
61+
* Returns a Product.
62+
*
5963
* @return Product
6064
*/
6165
public function getProduct()
@@ -67,6 +71,8 @@ public function getProduct()
6771
}
6872

6973
/**
74+
* Additional data.
75+
*
7076
* $excludeAttr is optional array of attribute codes to
7177
* exclude them from additional data array
7278
*
@@ -89,7 +95,7 @@ public function getAdditionalData(array $excludeAttr = [])
8995
$value = $this->priceCurrency->convertAndFormat($value);
9096
}
9197

92-
if (is_string($value) && strlen($value)) {
98+
if (is_string($value) && strlen(trim($value))) {
9399
$data[$attribute->getAttributeCode()] = [
94100
'label' => __($attribute->getStoreLabel()),
95101
'value' => $value,

app/code/Magento/Catalog/Block/Product/View/Options.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/**
8-
* Product options block
9-
*
10-
* @author Magento Core Team <[email protected]>
11-
*/
127
namespace Magento\Catalog\Block\Product\View;
138

149
use Magento\Catalog\Model\Product;
10+
use Magento\Catalog\Model\Product\Option\Value;
1511

1612
/**
13+
* Product options block
14+
*
15+
* @author Magento Core Team <[email protected]>
1716
* @api
1817
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1918
* @since 100.0.2
@@ -121,6 +120,8 @@ public function setProduct(Product $product = null)
121120
}
122121

123122
/**
123+
* Get group of option.
124+
*
124125
* @param string $type
125126
* @return string
126127
*/
@@ -142,6 +143,8 @@ public function getOptions()
142143
}
143144

144145
/**
146+
* Check if block has options.
147+
*
145148
* @return bool
146149
*/
147150
public function hasOptions()
@@ -160,7 +163,10 @@ public function hasOptions()
160163
*/
161164
protected function _getPriceConfiguration($option)
162165
{
163-
$optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false);
166+
$optionPrice = $option->getPrice(true);
167+
if ($option->getPriceType() !== Value::TYPE_PERCENT) {
168+
$optionPrice = $this->pricingHelper->currency($optionPrice, false, false);
169+
}
164170
$data = [
165171
'prices' => [
166172
'oldPrice' => [
@@ -195,7 +201,7 @@ protected function _getPriceConfiguration($option)
195201
],
196202
],
197203
'type' => $option->getPriceType(),
198-
'name' => $option->getTitle()
204+
'name' => $option->getTitle(),
199205
];
200206
return $data;
201207
}
@@ -231,7 +237,7 @@ public function getJsonConfig()
231237
//pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee
232238
$this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]);
233239

234-
$config=$configObj->getConfig();
240+
$config = $configObj->getConfig();
235241

236242
return $this->_jsonEncoder->encode($config);
237243
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private function isUniqueAdminValues(array $optionsValues, array $deletedOptions
158158
{
159159
$adminValues = [];
160160
foreach ($optionsValues as $optionKey => $values) {
161-
if (!(isset($deletedOptions[$optionKey]) and $deletedOptions[$optionKey] === '1')) {
161+
if (!(isset($deletedOptions[$optionKey]) && $deletedOptions[$optionKey] === '1')) {
162162
$adminValues[] = reset($values);
163163
}
164164
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
2020

2121
/**
22+
* Product helper
23+
*
2224
* @api
2325
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2426
* @since 100.0.2
@@ -104,7 +106,7 @@ class Helper
104106
* @param \Magento\Backend\Helper\Js $jsHelper
105107
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
106108
* @param CustomOptionFactory|null $customOptionFactory
107-
* @param ProductLinkFactory |null $productLinkFactory
109+
* @param ProductLinkFactory|null $productLinkFactory
108110
* @param ProductRepositoryInterface|null $productRepository
109111
* @param LinkTypeProvider|null $linkTypeProvider
110112
* @param AttributeFilter|null $attributeFilter
@@ -365,6 +367,8 @@ private function overwriteValue($optionId, $option, $overwriteOptions)
365367
}
366368

367369
/**
370+
* Get link resolver instance
371+
*
368372
* @return LinkResolver
369373
* @deprecated 101.0.0
370374
*/
@@ -377,6 +381,8 @@ private function getLinkResolver()
377381
}
378382

379383
/**
384+
* Get DateTimeFilter instance
385+
*
380386
* @return \Magento\Framework\Stdlib\DateTime\Filter\DateTime
381387
* @deprecated 101.0.0
382388
*/
@@ -391,6 +397,7 @@ private function getDateTimeFilter()
391397

392398
/**
393399
* Remove ids of non selected websites from $websiteIds array and return filtered data
400+
*
394401
* $websiteIds parameter expects array with website ids as keys and 1 (selected) or 0 (non selected) as values
395402
* Only one id (default website ID) will be set to $websiteIds array when the single store mode is turned on
396403
*
@@ -463,6 +470,7 @@ private function fillProductOptions(Product $product, array $productOptions)
463470
private function convertSpecialFromDateStringToObject($productData)
464471
{
465472
if (isset($productData['special_from_date']) && $productData['special_from_date'] != '') {
473+
$productData['special_from_date'] = $this->getDateTimeFilter()->filter($productData['special_from_date']);
466474
$productData['special_from_date'] = new \DateTime($productData['special_from_date']);
467475
}
468476

app/code/Magento/Catalog/Test/Unit/Block/Product/View/AttributesTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,28 @@ protected function setUp()
125125
}
126126

127127
/**
128+
* Get attribute with no value phrase
129+
*
130+
* @param string $phrase
128131
* @return void
132+
* @dataProvider noValueProvider
129133
*/
130-
public function testGetAttributeNoValue()
134+
public function testGetAttributeNoValue(string $phrase)
131135
{
132-
$this->phrase = '';
133-
$this->frontendAttribute
134-
->expects($this->any())
135-
->method('getValue')
136-
->willReturn($this->phrase);
136+
$this->frontendAttribute->method('getValue')
137+
->willReturn($phrase);
137138
$attributes = $this->attributesBlock->getAdditionalData();
138-
$this->assertTrue(empty($attributes['phrase']));
139+
$this->assertArrayNotHasKey('phrase', $attributes);
140+
}
141+
142+
/**
143+
* No value data provider
144+
*
145+
* @return array
146+
*/
147+
public function noValueProvider(): array
148+
{
149+
return [[' '], ['']];
139150
}
140151

141152
/**

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ class HelperTest extends \PHPUnit\Framework\TestCase
9595
*/
9696
protected $attributeFilterMock;
9797

98+
/**
99+
* @var \PHPUnit_Framework_MockObject_MockObject
100+
*/
101+
private $dateTimeFilterMock;
102+
103+
/**
104+
* @inheritdoc
105+
*/
98106
protected function setUp()
99107
{
100108
$this->objectManager = new ObjectManager($this);
@@ -167,6 +175,11 @@ protected function setUp()
167175
$resolverProperty = $helperReflection->getProperty('linkResolver');
168176
$resolverProperty->setAccessible(true);
169177
$resolverProperty->setValue($this->helper, $this->linkResolverMock);
178+
179+
$this->dateTimeFilterMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\Filter\DateTime::class);
180+
$dateTimeFilterProperty = $helperReflection->getProperty('dateTimeFilter');
181+
$dateTimeFilterProperty->setAccessible(true);
182+
$dateTimeFilterProperty->setValue($this->helper, $this->dateTimeFilterMock);
170183
}
171184

172185
/**
@@ -208,6 +221,12 @@ public function testInitialize(
208221
if (!empty($tierPrice)) {
209222
$productData = array_merge($productData, ['tier_price' => $tierPrice]);
210223
}
224+
225+
$this->dateTimeFilterMock->expects($this->once())
226+
->method('filter')
227+
->with($specialFromDate)
228+
->willReturn($specialFromDate);
229+
211230
$attributeNonDate = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
212231
->disableOriginalConstructor()
213232
->getMock();

app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@
1313
$block->escapeUrl($block->getContinueShoppingUrl())) ?></p>
1414
<?= $block->getChildHtml('shopping.cart.table.after') ?>
1515
</div>
16+
<script type="text/x-magento-init">
17+
{
18+
"*": {
19+
"Magento_Checkout/js/empty-cart": {}
20+
}
21+
}
22+
</script>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Customer/js/customer-data'
8+
], function (customerData) {
9+
'use strict';
10+
11+
customerData.reload(['cart'], false);
12+
});

app/code/Magento/ConfigurableProduct/view/adminhtml/templates/catalog/product/composite/fieldset/configurable.phtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<legend class="legend admin__legend">
1818
<span><?= /* @escapeNotVerified */ __('Associated Products') ?></span>
1919
</legend>
20-
<div class="product-options">
21-
<div class="field admin__field _required required">
22-
<?php foreach ($_attributes as $_attribute): ?>
20+
<div class="product-options fieldset admin__fieldset">
21+
<?php foreach ($_attributes as $_attribute): ?>
22+
<div class="field admin__field _required required">
2323
<label class="label admin__field-label"><?php
2424
/* @escapeNotVerified */ echo $_attribute->getProductAttribute()
2525
->getStoreLabel($_product->getStoreId());
@@ -34,8 +34,8 @@
3434
<option><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>
3535
</select>
3636
</div>
37-
<?php endforeach; ?>
38-
</div>
37+
</div>
38+
<?php endforeach; ?>
3939
</div>
4040
</fieldset>
4141
<script>

app/code/Magento/Cron/Model/Schedule.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\Exception\CronException;
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
12+
use Magento\Framework\Intl\DateTimeFactory;
1213

1314
/**
1415
* Crontab schedule model
@@ -50,24 +51,32 @@ class Schedule extends \Magento\Framework\Model\AbstractModel
5051
*/
5152
private $timezoneConverter;
5253

54+
/**
55+
* @var DateTimeFactory
56+
*/
57+
private $dateTimeFactory;
58+
5359
/**
5460
* @param \Magento\Framework\Model\Context $context
5561
* @param \Magento\Framework\Registry $registry
5662
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
5763
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
5864
* @param array $data
59-
* @param TimezoneInterface $timezoneConverter
65+
* @param TimezoneInterface|null $timezoneConverter
66+
* @param DateTimeFactory|null $dateTimeFactory
6067
*/
6168
public function __construct(
6269
\Magento\Framework\Model\Context $context,
6370
\Magento\Framework\Registry $registry,
6471
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
6572
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
6673
array $data = [],
67-
TimezoneInterface $timezoneConverter = null
74+
TimezoneInterface $timezoneConverter = null,
75+
DateTimeFactory $dateTimeFactory = null
6876
) {
6977
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
7078
$this->timezoneConverter = $timezoneConverter ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
79+
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
7180
}
7281

7382
/**
@@ -109,17 +118,20 @@ public function trySchedule()
109118
if (!$e || !$time) {
110119
return false;
111120
}
121+
$configTimeZone = $this->timezoneConverter->getConfigTimezone();
122+
$storeDateTime = $this->dateTimeFactory->create(null, new \DateTimeZone($configTimeZone));
112123
if (!is_numeric($time)) {
113124
//convert time from UTC to admin store timezone
114125
//we assume that all schedules in configuration (crontab.xml and DB tables) are in admin store timezone
115-
$time = $this->timezoneConverter->date($time)->format('Y-m-d H:i');
116-
$time = strtotime($time);
126+
$dateTimeUtc = $this->dateTimeFactory->create($time);
127+
$time = $dateTimeUtc->getTimestamp();
117128
}
118-
$match = $this->matchCronExpression($e[0], strftime('%M', $time))
119-
&& $this->matchCronExpression($e[1], strftime('%H', $time))
120-
&& $this->matchCronExpression($e[2], strftime('%d', $time))
121-
&& $this->matchCronExpression($e[3], strftime('%m', $time))
122-
&& $this->matchCronExpression($e[4], strftime('%w', $time));
129+
$time = $storeDateTime->setTimestamp($time);
130+
$match = $this->matchCronExpression($e[0], $time->format('i'))
131+
&& $this->matchCronExpression($e[1], $time->format('H'))
132+
&& $this->matchCronExpression($e[2], $time->format('d'))
133+
&& $this->matchCronExpression($e[3], $time->format('m'))
134+
&& $this->matchCronExpression($e[4], $time->format('w'));
123135

124136
return $match;
125137
}

0 commit comments

Comments
 (0)