Skip to content

Commit 080a341

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1590 from magento-engcom/2.2-develop-prs
Public Pull Requests #11240 #11493 #11430 #11470 #11445 #11406 #11383 #11351 #11359 #11342 #11261
2 parents 08ec8ce + 821efa9 commit 080a341

File tree

20 files changed

+343
-62
lines changed

20 files changed

+343
-62
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,11 +782,14 @@ public function getAllChildren($asArray = false)
782782
/**
783783
* Retrieve children ids comma separated
784784
*
785+
* @param boolean $recursive
786+
* @param boolean $isActive
787+
* @param boolean $sortByPosition
785788
* @return string
786789
*/
787-
public function getChildren()
790+
public function getChildren($recursive = false, $isActive = true, $sortByPosition = false)
788791
{
789-
return implode(',', $this->getResource()->getChildren($this, false));
792+
return implode(',', $this->getResource()->getChildren($this, $recursive, $isActive, $sortByPosition));
790793
}
791794

792795
/**

app/code/Magento/Catalog/Model/ResourceModel/Category/Flat.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,10 @@ public function isInRootCategoryList($category)
602602
* @param \Magento\Catalog\Model\Category $category
603603
* @param bool $recursive
604604
* @param bool $isActive
605+
* @param bool $sortByPosition
605606
* @return array
606607
*/
607-
public function getChildren($category, $recursive = true, $isActive = true)
608+
public function getChildren($category, $recursive = true, $isActive = true, $sortByPosition = false)
608609
{
609610
$select = $this->getConnection()->select()->from(
610611
$this->getMainStoreTable($category->getStoreId()),
@@ -619,6 +620,9 @@ public function getChildren($category, $recursive = true, $isActive = true)
619620
if ($isActive) {
620621
$select->where('is_active = ?', '1');
621622
}
623+
if ($sortByPosition) {
624+
$select->order('position ASC');
625+
}
622626
$_categories = $this->getConnection()->fetchAll($select);
623627
$categoriesIds = [];
624628
foreach ($_categories as $_category) {
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
8+
9+
use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Price;
10+
use Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Alerts\Stock;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\View\LayoutFactory;
13+
use Magento\Store\Model\ScopeInterface;
14+
use Magento\Ui\Component\Form\Fieldset;
15+
16+
class Alerts extends AbstractModifier
17+
{
18+
const DATA_SCOPE = 'data';
19+
const DATA_SCOPE_STOCK = 'stock';
20+
const DATA_SCOPE_PRICE = 'price';
21+
22+
/**
23+
* @var string
24+
*/
25+
private static $previousGroup = 'related';
26+
27+
/**
28+
* @var int
29+
*/
30+
private static $sortOrder = 110;
31+
32+
/**
33+
* @var ScopeConfigInterface
34+
*/
35+
private $scopeConfig;
36+
37+
/**
38+
* @var LayoutFactory
39+
*/
40+
private $layoutFactory;
41+
42+
/**
43+
* Alerts constructor.
44+
* @param ScopeConfigInterface $scopeConfig
45+
* @param LayoutFactory $layoutFactory
46+
*/
47+
public function __construct(
48+
ScopeConfigInterface $scopeConfig,
49+
LayoutFactory $layoutFactory
50+
) {
51+
$this->scopeConfig = $scopeConfig;
52+
$this->layoutFactory = $layoutFactory;
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
* @since 101.0.0
58+
*/
59+
public function modifyData(array $data)
60+
{
61+
return $data;
62+
}
63+
64+
/**
65+
* {@inheritdoc}
66+
* @since 101.0.0
67+
*/
68+
public function modifyMeta(array $meta)
69+
{
70+
if (!$this->canShowTab()) {
71+
return $meta;
72+
}
73+
74+
$meta = array_replace_recursive(
75+
$meta,
76+
[
77+
'alerts' => [
78+
'arguments' => [
79+
'data' => [
80+
'config' => [
81+
'additionalClasses' => 'admin__fieldset-section',
82+
'label' => __('Product Alerts'),
83+
'collapsible' => true,
84+
'componentType' => Fieldset::NAME,
85+
'dataScope' => static::DATA_SCOPE,
86+
'sortOrder' =>
87+
$this->getNextGroupSortOrder(
88+
$meta,
89+
self::$previousGroup,
90+
self::$sortOrder
91+
),
92+
],
93+
],
94+
],
95+
'children' => [
96+
static::DATA_SCOPE_STOCK => $this->getAlertStockFieldset(),
97+
static::DATA_SCOPE_PRICE => $this->getAlertPriceFieldset()
98+
],
99+
],
100+
]
101+
);
102+
103+
return $meta;
104+
}
105+
106+
/**
107+
* @return bool
108+
*/
109+
private function canShowTab()
110+
{
111+
$alertPriceAllow = $this->scopeConfig->getValue(
112+
'catalog/productalert/allow_price',
113+
ScopeInterface::SCOPE_STORE
114+
);
115+
$alertStockAllow = $this->scopeConfig->getValue(
116+
'catalog/productalert/allow_stock',
117+
ScopeInterface::SCOPE_STORE
118+
);
119+
120+
return ($alertPriceAllow || $alertStockAllow);
121+
}
122+
123+
/**
124+
* Prepares config for the alert stock products fieldset
125+
* @return array
126+
*/
127+
private function getAlertStockFieldset()
128+
{
129+
return [
130+
'arguments' => [
131+
'data' => [
132+
'config' => [
133+
'label' => __('Alert stock'),
134+
'componentType' => 'container',
135+
'component' => 'Magento_Ui/js/form/components/html',
136+
'additionalClasses' => 'admin__fieldset-note',
137+
'content' =>
138+
'<h4>' . __('Alert Stock') . '</h4>' .
139+
$this->layoutFactory->create()->createBlock(
140+
Stock::class
141+
)->toHtml(),
142+
]
143+
]
144+
]
145+
];
146+
}
147+
148+
/**
149+
* Prepares config for the alert price products fieldset
150+
* @return array
151+
*/
152+
private function getAlertPriceFieldset()
153+
{
154+
return [
155+
'arguments' => [
156+
'data' => [
157+
'config' => [
158+
'label' => __('Alert price'),
159+
'componentType' => 'container',
160+
'component' => 'Magento_Ui/js/form/components/html',
161+
'additionalClasses' => 'admin__fieldset-note',
162+
'content' =>
163+
'<h4>' . __('Alert Price') . '</h4>' .
164+
$this->layoutFactory->create()->createBlock(
165+
Price::class
166+
)->toHtml(),
167+
]
168+
]
169+
]
170+
];
171+
}
172+
}

app/code/Magento/Catalog/etc/adminhtml/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Attributes</item>
144144
<item name="sortOrder" xsi:type="number">120</item>
145145
</item>
146+
<item name="alerts" xsi:type="array">
147+
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Alerts</item>
148+
<item name="sortOrder" xsi:type="number">130</item>
149+
</item>
146150
<item name="advanced-pricing-tier-price-type" xsi:type="array">
147151
<item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\TierPrice</item>
148152
<item name="sortOrder" xsi:type="number">150</item>

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,4 @@ Payment,Payment
176176
"Not yet calculated","Not yet calculated"
177177
"We received your order!","We received your order!"
178178
"Thank you for your purchase!","Thank you for your purchase!"
179+
"optional", "optional"

app/code/Magento/Checkout/view/frontend/web/template/cart/shipping-rates.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
checked: $parents[1].selectedShippingMethod,
2525
attr: {
2626
value: carrier_code + '_' + method_code,
27-
id: 's_method_' + method_code
27+
id: 's_method_' + carrier_code + '_' + method_code
2828
}
2929
"/>
30-
<label class="label" data-bind="attr: {for: 's_method_' + method_code}">
30+
<label class="label" data-bind="attr: {for: 's_method_' + carrier_code + '_' + method_code}">
3131
<!-- ko text: $data.method_title --><!-- /ko -->
3232
<each args="element.getRegion('price')" render="" />
3333
</label>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</argument>
4444
</arguments>
4545
</type>
46-
<type name="Magento\Framework\Crontab\CrontabManager">
46+
<type name="Magento\Framework\Crontab\CrontabManagerInterface">
4747
<arguments>
4848
<argument name="shell" xsi:type="object">Magento\Framework\App\Shell</argument>
4949
</arguments>

app/code/Magento/Customer/Block/Widget/Dob.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function getHtmlExtraParams()
228228
*/
229229
public function getDateFormat()
230230
{
231-
return $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
231+
return $this->_localeDate->getDateFormatWithLongYear();
232232
}
233233

234234
/**

app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DobTest extends \PHPUnit\Framework\TestCase
3333
const YEAR = '2014';
3434

3535
// Value of date('Y', strtotime(self::DATE))
36-
const DATE_FORMAT = 'M/d/yy';
36+
const DATE_FORMAT = 'M/d/Y';
3737

3838
/** Constants used by Dob::setDateInput($code, $html) */
3939
const DAY_HTML =
@@ -485,16 +485,16 @@ public function testGetHtmlExtraParamsWithoutRequiredOption()
485485
{
486486
$this->escaper->expects($this->any())
487487
->method('escapeHtml')
488-
->with('{"validate-date":{"dateFormat":"M\/d\/yy"}}')
489-
->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/yy"}}'));
488+
->with('{"validate-date":{"dateFormat":"M\/d\/Y"}}')
489+
->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"}}'));
490490

491491
$this->attribute->expects($this->once())
492492
->method("isRequired")
493493
->willReturn(false);
494494

495495
$this->assertEquals(
496496
$this->_block->getHtmlExtraParams(),
497-
'data-validate="{"validate-date":{"dateFormat":"M\/d\/yy"}}"'
497+
'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"}}"'
498498
);
499499
}
500500

@@ -506,14 +506,14 @@ public function testGetHtmlExtraParamsWithRequiredOption()
506506

507507
$this->escaper->expects($this->any())
508508
->method('escapeHtml')
509-
->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}')
510-
->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}'));
509+
->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}')
510+
->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}'));
511511

512512

513513
$this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper));
514514

515515
$this->assertEquals(
516-
'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/yy"}}"',
516+
'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}"',
517517
$this->_block->getHtmlExtraParams()
518518
);
519519
}

app/code/Magento/Sales/Model/Order/Invoice.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ public function void()
407407
*/
408408
public function cancel()
409409
{
410+
if (!$this->canCancel()) {
411+
return $this;
412+
}
410413
$order = $this->getOrder();
411414
$order->getPayment()->cancelInvoice($this);
412415
foreach ($this->getAllItems() as $item) {

app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ public function create(
101101
$appendComment,
102102
$comment->getIsVisibleOnFront()
103103
);
104+
105+
if ($appendComment) {
106+
$shipment->setCustomerNote($comment->getComment());
107+
$shipment->setCustomerNoteNotify($appendComment);
108+
}
104109
}
105110

106111
return $shipment;

0 commit comments

Comments
 (0)