Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 878082b

Browse files
merge magento/2.2-develop into magento-pangolin/2.2-dev-pan-2.3.10
2 parents e98a94f + 7695e8d commit 878082b

File tree

25 files changed

+171
-54
lines changed

25 files changed

+171
-54
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Catalog\Model;
77

8+
use \Magento\Framework\TranslateInterface;
9+
810
/**
911
* Catalog Custom Category design Model
1012
*
@@ -31,6 +33,11 @@ class Design extends \Magento\Framework\Model\AbstractModel
3133
*/
3234
protected $_localeDate;
3335

36+
/**
37+
* @var TranslateInterface
38+
*/
39+
private $translator;
40+
3441
/**
3542
* @param \Magento\Framework\Model\Context $context
3643
* @param \Magento\Framework\Registry $registry
@@ -47,10 +54,13 @@ public function __construct(
4754
\Magento\Framework\View\DesignInterface $design,
4855
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
4956
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
50-
array $data = []
57+
array $data = [],
58+
TranslateInterface $translator = null
5159
) {
5260
$this->_localeDate = $localeDate;
5361
$this->_design = $design;
62+
$this->translator = $translator ?:
63+
\Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
5464
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
5565
}
5666

@@ -63,6 +73,7 @@ public function __construct(
6373
public function applyCustomDesign($design)
6474
{
6575
$this->_design->setDesignTheme($design);
76+
$this->translator->loadData(null, true);
6677
return $this;
6778
}
6879

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,22 @@ protected function validatePrice(array $priceRow)
159159
*/
160160
protected function modifyPriceData($object, $data)
161161
{
162+
/** @var \Magento\Catalog\Model\Product $object */
162163
$data = parent::modifyPriceData($object, $data);
163164
$price = $object->getPrice();
165+
166+
$specialPrice = $object->getSpecialPrice();
167+
$specialPriceFromDate = $object->getSpecialFromDate();
168+
$specialPriceToDate = $object->getSpecialToDate();
169+
$today = time();
170+
171+
if ($specialPrice && ($object->getPrice() > $object->getFinalPrice())) {
172+
if ($today >= strtotime($specialPriceFromDate) && $today <= strtotime($specialPriceToDate) ||
173+
$today >= strtotime($specialPriceFromDate) && $specialPriceToDate === null) {
174+
$price = $specialPrice;
175+
}
176+
}
177+
164178
foreach ($data as $key => $tierPrice) {
165179
$percentageValue = $this->getPercentage($tierPrice);
166180
if ($percentageValue) {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ Subscribers,Subscribers
6767
"Something went wrong while saving this template.","Something went wrong while saving this template."
6868
"Newsletter Subscription","Newsletter Subscription"
6969
"Something went wrong while saving your subscription.","Something went wrong while saving your subscription."
70-
"We saved the subscription.","We saved the subscription."
71-
"We removed the subscription.","We removed the subscription."
70+
"We have saved your subscription.","We have saved your subscription."
71+
"We have removed your newsletter subscription.","We have removed your newsletter subscription."
7272
"Your subscription has been confirmed.","Your subscription has been confirmed."
7373
"This is an invalid subscription confirmation code.","This is an invalid subscription confirmation code."
7474
"This is an invalid subscription ID.","This is an invalid subscription ID."
7575
"This email address is already assigned to another user.","This email address is already assigned to another user."
7676
"Sorry, but the administrator denied subscription for guests. Please <a href=""%1"">register</a>.","Sorry, but the administrator denied subscription for guests. Please <a href=""%1"">register</a>."
7777
"Please enter a valid email address.","Please enter a valid email address."
7878
"This email address is already subscribed.","This email address is already subscribed."
79-
"The confirmation request has been sent.","The confirmation request has been sent."
79+
"A confirmation request has been sent.","A confirmation request has been sent."
8080
"Thank you for your subscription.","Thank you for your subscription."
8181
"There was a problem with the subscription: %1","There was a problem with the subscription: %1"
8282
"Something went wrong with the subscription.","Something went wrong with the subscription."
@@ -151,3 +151,4 @@ Unconfirmed,Unconfirmed
151151
Store,Store
152152
"Store View","Store View"
153153
"Newsletter Subscriptions","Newsletter Subscriptions"
154+
"We have updated your subscription.","We have updated your subscription."

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Directory\Model\Currency;
99
use Magento\Framework\Api\AttributeValueFactory;
1010
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\Locale\ResolverInterface;
1213
use Magento\Framework\Pricing\PriceCurrencyInterface;
1314
use Magento\Sales\Api\Data\OrderInterface;
@@ -977,10 +978,21 @@ public function setState($state)
977978
return $this->setData(self::STATE, $state);
978979
}
979980

981+
/**
982+
* Retrieve frontend label of order status
983+
*
984+
* @return string
985+
*/
986+
public function getFrontendStatusLabel()
987+
{
988+
return $this->getConfig()->getStatusFrontendLabel($this->getStatus());
989+
}
990+
980991
/**
981992
* Retrieve label of order status
982993
*
983994
* @return string
995+
* @throws LocalizedException
984996
*/
985997
public function getStatusLabel()
986998
{
@@ -1084,12 +1096,12 @@ public function place()
10841096

10851097
/**
10861098
* @return $this
1087-
* @throws \Magento\Framework\Exception\LocalizedException
1099+
* @throws LocalizedException
10881100
*/
10891101
public function hold()
10901102
{
10911103
if (!$this->canHold()) {
1092-
throw new \Magento\Framework\Exception\LocalizedException(__('A hold action is not available.'));
1104+
throw new LocalizedException(__('A hold action is not available.'));
10931105
}
10941106
$this->setHoldBeforeState($this->getState());
10951107
$this->setHoldBeforeStatus($this->getStatus());
@@ -1102,12 +1114,12 @@ public function hold()
11021114
* Attempt to unhold the order
11031115
*
11041116
* @return $this
1105-
* @throws \Magento\Framework\Exception\LocalizedException
1117+
* @throws LocalizedException
11061118
*/
11071119
public function unhold()
11081120
{
11091121
if (!$this->canUnhold()) {
1110-
throw new \Magento\Framework\Exception\LocalizedException(__('You cannot remove the hold.'));
1122+
throw new LocalizedException(__('You cannot remove the hold.'));
11111123
}
11121124

11131125
$this->setState($this->getHoldBeforeState())
@@ -1151,7 +1163,7 @@ public function isFraudDetected()
11511163
* @param string $comment
11521164
* @param bool $graceful
11531165
* @return $this
1154-
* @throws \Magento\Framework\Exception\LocalizedException
1166+
* @throws LocalizedException
11551167
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
11561168
*/
11571169
public function registerCancellation($comment = '', $graceful = true)
@@ -1190,7 +1202,7 @@ public function registerCancellation($comment = '', $graceful = true)
11901202
$this->addStatusHistoryComment($comment, false);
11911203
}
11921204
} elseif (!$graceful) {
1193-
throw new \Magento\Framework\Exception\LocalizedException(__('We cannot cancel this order.'));
1205+
throw new LocalizedException(__('We cannot cancel this order.'));
11941206
}
11951207
return $this;
11961208
}
@@ -1550,7 +1562,10 @@ public function getStatusHistoryById($statusId)
15501562
public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $history)
15511563
{
15521564
$history->setOrder($this);
1553-
$this->setStatus($history->getStatus());
1565+
$status = $history->getStatus();
1566+
if (null !== $status) {
1567+
$this->setStatus($status);
1568+
}
15541569
if (!$history->getId()) {
15551570
$this->setStatusHistories(array_merge($this->getStatusHistories(), [$history]));
15561571
$this->setDataChanges(true);

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

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Sales\Model\Order;
77

8+
use Magento\Framework\Exception\LocalizedException;
9+
810
/**
911
* Order configuration model
1012
*
@@ -85,7 +87,7 @@ protected function _getCollection()
8587

8688
/**
8789
* @param string $state
88-
* @return Status|null
90+
* @return Status
8991
*/
9092
protected function _getState($state)
9193
{
@@ -101,7 +103,7 @@ protected function _getState($state)
101103
* Retrieve default status for state
102104
*
103105
* @param string $state
104-
* @return string
106+
* @return string|null
105107
*/
106108
public function getStateDefaultStatus($state)
107109
{
@@ -115,24 +117,48 @@ public function getStateDefaultStatus($state)
115117
}
116118

117119
/**
118-
* Retrieve status label
120+
* Get status label for a specified area
119121
*
120-
* @param string $code
121-
* @return string
122+
* @param string $code
123+
* @param string $area
124+
* @return string
122125
*/
123-
public function getStatusLabel($code)
126+
private function getStatusLabelForArea(string $code, string $area): string
124127
{
125-
$area = $this->state->getAreaCode();
126128
$code = $this->maskStatusForArea($area, $code);
127129
$status = $this->orderStatusFactory->create()->load($code);
128130

129-
if ($area == 'adminhtml') {
131+
if ($area === 'adminhtml') {
130132
return $status->getLabel();
131133
}
132134

133135
return $status->getStoreLabel();
134136
}
135137

138+
/**
139+
* Retrieve status label for detected area
140+
*
141+
* @param string $code
142+
* @return string
143+
* @throws LocalizedException
144+
*/
145+
public function getStatusLabel($code)
146+
{
147+
$area = $this->state->getAreaCode() ?: \Magento\Framework\App\Area::AREA_FRONTEND;
148+
return $this->getStatusLabelForArea($code, $area);
149+
}
150+
151+
/**
152+
* Retrieve status label for area
153+
*
154+
* @param string $code
155+
* @return string
156+
*/
157+
public function getStatusFrontendLabel(string $code): string
158+
{
159+
return $this->getStatusLabelForArea($code, \Magento\Framework\App\Area::AREA_FRONTEND);
160+
}
161+
136162
/**
137163
* Mask status for order for specified area
138164
*

app/code/Magento/Sales/view/frontend/email/creditmemo_update.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"var this.getUrl($store, 'customer/account/')":"Customer Account URL",
1212
"var order.getCustomerName()":"Customer Name",
1313
"var order.increment_id":"Order Id",
14-
"var order.getStatusLabel()":"Order Status"
14+
"var order.getFrontendStatusLabel()":"Order Status"
1515
} @-->
1616
{{template config_path="design/email/header_template"}}
1717

@@ -24,7 +24,7 @@
2424
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2525

2626
increment_id=$order.increment_id
27-
order_status=$order.getStatusLabel()
27+
order_status=$order.getFrontendStatusLabel()
2828
|raw}}
2929
</p>
3030
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>

app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"var creditmemo.increment_id":"Credit Memo Id",
1111
"var billing.getName()":"Guest Customer Name",
1212
"var order.increment_id":"Order Id",
13-
"var order.getStatusLabel()":"Order Status"
13+
"var order.getFrontendStatusLabel()":"Order Status"
1414
} @-->
1515
{{template config_path="design/email/header_template"}}
1616

@@ -23,7 +23,7 @@
2323
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2424

2525
increment_id=$order.increment_id
26-
order_status=$order.getStatusLabel()
26+
order_status=$order.getFrontendStatusLabel()
2727
|raw}}
2828
</p>
2929
<p>

app/code/Magento/Sales/view/frontend/email/invoice_update.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"var comment":"Invoice Comment",
1212
"var invoice.increment_id":"Invoice Id",
1313
"var order.increment_id":"Order Id",
14-
"var order.getStatusLabel()":"Order Status"
14+
"var order.getFrontendStatusLabel()":"Order Status"
1515
} @-->
1616
{{template config_path="design/email/header_template"}}
1717

@@ -24,7 +24,7 @@
2424
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2525

2626
increment_id=$order.increment_id
27-
order_status=$order.getStatusLabel()
27+
order_status=$order.getFrontendStatusLabel()
2828
|raw}}
2929
</p>
3030
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>

app/code/Magento/Sales/view/frontend/email/invoice_update_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"var comment":"Invoice Comment",
1111
"var invoice.increment_id":"Invoice Id",
1212
"var order.increment_id":"Order Id",
13-
"var order.getStatusLabel()":"Order Status"
13+
"var order.getFrontendStatusLabel()":"Order Status"
1414
} @-->
1515
{{template config_path="design/email/header_template"}}
1616

@@ -23,7 +23,7 @@
2323
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2424

2525
increment_id=$order.increment_id
26-
order_status=$order.getStatusLabel()
26+
order_status=$order.getFrontendStatusLabel()
2727
|raw}}
2828
</p>
2929
<p>

app/code/Magento/Sales/view/frontend/email/order_update.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"var order.getCustomerName()":"Customer Name",
1111
"var comment":"Order Comment",
1212
"var order.increment_id":"Order Id",
13-
"var order.getStatusLabel()":"Order Status"
13+
"var order.getFrontendStatusLabel()":"Order Status"
1414
} @-->
1515
{{template config_path="design/email/header_template"}}
1616

@@ -23,7 +23,7 @@
2323
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2424

2525
increment_id=$order.increment_id
26-
order_status=$order.getStatusLabel()
26+
order_status=$order.getFrontendStatusLabel()
2727
|raw}}
2828
</p>
2929
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>

app/code/Magento/Sales/view/frontend/email/order_update_guest.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"var billing.getName()":"Guest Customer Name",
1010
"var comment":"Order Comment",
1111
"var order.increment_id":"Order Id",
12-
"var order.getStatusLabel()":"Order Status"
12+
"var order.getFrontendStatusLabel()":"Order Status"
1313
} @-->
1414
{{template config_path="design/email/header_template"}}
1515

@@ -22,7 +22,7 @@
2222
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2323

2424
increment_id=$order.increment_id
25-
order_status=$order.getStatusLabel()
25+
order_status=$order.getFrontendStatusLabel()
2626
|raw}}
2727
</p>
2828
<p>

app/code/Magento/Sales/view/frontend/email/shipment_update.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"var order.getCustomerName()":"Customer Name",
1111
"var comment":"Order Comment",
1212
"var order.increment_id":"Order Id",
13-
"var order.getStatusLabel()":"Order Status",
13+
"var order.getFrontendStatusLabel()":"Order Status",
1414
"var shipment.increment_id":"Shipment Id"
1515
} @-->
1616
{{template config_path="design/email/header_template"}}
@@ -24,7 +24,7 @@
2424
"Your order #%increment_id has been updated with a status of <strong>%order_status</strong>."
2525

2626
increment_id=$order.increment_id
27-
order_status=$order.getStatusLabel()
27+
order_status=$order.getFrontendStatusLabel()
2828
|raw}}
2929
</p>
3030
<p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>

0 commit comments

Comments
 (0)