Skip to content

Commit f8942b5

Browse files
rganinraith-hamzah
authored andcommitted
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-72521
2 parents 8b8a2c9 + e7c5bb5 commit f8942b5

File tree

20 files changed

+358
-103
lines changed

20 files changed

+358
-103
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private function cacheProduct($cacheKey, \Magento\Catalog\Api\Data\ProductInterf
312312
if ($this->cacheLimit && count($this->instances) > $this->cacheLimit) {
313313
$offset = round($this->cacheLimit / -2);
314314
$this->instancesById = array_slice($this->instancesById, $offset, null, true);
315-
$this->instances = array_slice($this->instances, $offset);
315+
$this->instances = array_slice($this->instances, $offset, null, true);
316316
}
317317
}
318318

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/Block/Checkout/AttributeMerger.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,19 @@ protected function getFieldConfig(
168168

169169
$element = [
170170
'component' => isset($additionalConfig['component']) ? $additionalConfig['component'] : $uiComponent,
171-
'config' => [
172-
// customScope is used to group elements within a single form (e.g. they can be validated separately)
173-
'customScope' => $dataScopePrefix,
174-
'customEntry' => isset($additionalConfig['config']['customEntry'])
175-
? $additionalConfig['config']['customEntry']
176-
: null,
177-
'template' => 'ui/form/field',
178-
'elementTmpl' => isset($additionalConfig['config']['elementTmpl'])
179-
? $additionalConfig['config']['elementTmpl']
180-
: $elementTemplate,
181-
'tooltip' => isset($additionalConfig['config']['tooltip'])
182-
? $additionalConfig['config']['tooltip']
183-
: null
184-
],
171+
'config' => $this->mergeConfigurationNode(
172+
'config',
173+
$additionalConfig,
174+
[
175+
'config' => [
176+
// customScope is used to group elements within a single
177+
// form (e.g. they can be validated separately)
178+
'customScope' => $dataScopePrefix,
179+
'template' => 'ui/form/field',
180+
'elementTmpl' => $elementTemplate,
181+
],
182+
]
183+
),
185184
'dataScope' => $dataScopePrefix . '.' . $attributeCode,
186185
'label' => $attributeConfig['label'],
187186
'provider' => $providerName,

app/code/Magento/Checkout/view/frontend/web/template/billing-address/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
-->
77
<div class="field field-select-billing">
8-
<label class="label"><span data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
8+
<label class="label"><span data-bind="i18n: 'Billing Address'"></span></label>
99
<div class="control" data-bind="if: (addressOptions.length > 1)">
1010
<select class="select" name="billing_address_id" data-bind="
1111
options: addressOptions,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<schedule_ahead_for>20</schedule_ahead_for>
1212
<schedule_lifetime>15</schedule_lifetime>
1313
<history_cleanup_every>10</history_cleanup_every>
14-
<history_success_lifetime>60</history_success_lifetime>
15-
<history_failure_lifetime>600</history_failure_lifetime>
14+
<history_success_lifetime>10080</history_success_lifetime>
15+
<history_failure_lifetime>10080</history_failure_lifetime>
1616
<use_separate_process>0</use_separate_process>
1717
</group>
1818
</config>

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/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public function __construct(
7070
public function getLinks()
7171
{
7272
$this->_purchased = $this->_purchasedFactory->create()->load(
73-
$this->getItem()->getId(),
73+
$this->getItem()->getOrderItemId(),
7474
'order_item_id'
7575
);
7676
$purchasedLinks = $this->_itemsFactory->create()->addFieldToFilter(
7777
'order_item_id',
78-
$this->getItem()->getId()
78+
$this->getItem()->getOrderItemId()
7979
);
8080
$this->_purchased->setPurchasedItems($purchasedLinks);
8181

app/code/Magento/Downloadable/Test/Unit/Block/Sales/Order/Email/Items/DownloadableTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testGetLinks()
5959
{
6060
$item = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
6161
->disableOriginalConstructor()
62-
->setMethods(['getId'])
62+
->setMethods(['getOrderItemId'])
6363
->getMock();
6464
$linkPurchased = $this->getMockBuilder(\Magento\Downloadable\Model\Link\Purchased::class)
6565
->disableOriginalConstructor()
@@ -73,12 +73,12 @@ public function testGetLinks()
7373

7474
$this->block->setData('item', $item);
7575
$this->purchasedFactory->expects($this->once())->method('create')->willReturn($linkPurchased);
76-
$linkPurchased->expects($this->once())->method('load')->with('itemId', 'order_item_id')->willReturnSelf();
77-
$item->expects($this->any())->method('getId')->willReturn('itemId');
76+
$linkPurchased->expects($this->once())->method('load')->with('orderItemId', 'order_item_id')->willReturnSelf();
77+
$item->expects($this->any())->method('getOrderItemId')->willReturn('orderItemId');
7878
$this->itemsFactory->expects($this->once())->method('create')->willReturn($itemCollection);
7979
$itemCollection->expects($this->once())
8080
->method('addFieldToFilter')
81-
->with('order_item_id', 'itemId')
81+
->with('order_item_id', 'orderItemId')
8282
->willReturnSelf();
8383

8484
$this->assertEquals($linkPurchased, $this->block->getLinks());

app/code/Magento/Indexer/etc/cron_groups.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<schedule_ahead_for>4</schedule_ahead_for>
1212
<schedule_lifetime>2</schedule_lifetime>
1313
<history_cleanup_every>10</history_cleanup_every>
14-
<history_success_lifetime>60</history_success_lifetime>
15-
<history_failure_lifetime>600</history_failure_lifetime>
14+
<history_success_lifetime>10080</history_success_lifetime>
15+
<history_failure_lifetime>10080</history_failure_lifetime>
1616
<use_separate_process>1</use_separate_process>
1717
</group>
1818
</config>

0 commit comments

Comments
 (0)