Skip to content

Commit 3e5be99

Browse files
authored
Merge pull request #8034 from magento-l3/DEC132022_PR_arul
[L3 Kings] Bugfix delivery
2 parents 1c553ec + 10a0cef commit 3e5be99

File tree

17 files changed

+328
-77
lines changed

17 files changed

+328
-77
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public function getOptionsJson()
105105
$optionItems['thumbmargin'] = (int)$this->escapeHtml($this->getVar("gallery/thumbmargin"));
106106
}
107107

108+
if ($this->getVar("product_image_white_borders")) {
109+
$optionItems['whiteBorders'] =
110+
(int)$this->escapeHtml($this->getVar("product_image_white_borders"));
111+
}
112+
108113
return $this->jsonSerializer->serialize($optionItems);
109114
}
110115

@@ -151,6 +156,11 @@ public function getFSOptionsJson()
151156
(int)$this->escapeHtml($this->getVar("gallery/fullscreen/thumbmargin"));
152157
}
153158

159+
if ($this->getVar("product_image_white_borders")) {
160+
$fsOptionItems['whiteBorders'] =
161+
(int)$this->escapeHtml($this->getVar("product_image_white_borders"));
162+
}
163+
154164
return $this->jsonSerializer->serialize($fsOptionItems);
155165
}
156166
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public function testGetOptionsJson()
108108
['Magento_Catalog', 'gallery/thumbmargin', '5'],
109109
['Magento_Catalog', 'gallery/transition/effect', 'slide'],
110110
['Magento_Catalog', 'gallery/transition/duration', '500'],
111+
['Magento_Catalog', 'product_image_white_borders', '1'],
111112
];
112113

113114
$imageAttributesMap = [
@@ -144,6 +145,7 @@ public function testGetOptionsJson()
144145
$this->assertSame(200, $decodedJson['width']);
145146
$this->assertSame(300, $decodedJson['thumbheight']);
146147
$this->assertSame(400, $decodedJson['thumbwidth']);
148+
$this->assertSame(1, $decodedJson['whiteBorders']);
147149
}
148150

149151
public function testGetFSOptionsJson()
@@ -159,7 +161,8 @@ public function testGetFSOptionsJson()
159161
['Magento_Catalog', 'gallery/fullscreen/navtype', 'thumbs'],
160162
['Magento_Catalog', 'gallery/fullscreen/thumbmargin', '10'],
161163
['Magento_Catalog', 'gallery/fullscreen/transition/effect', 'dissolve'],
162-
['Magento_Catalog', 'gallery/fullscreen/transition/duration', '300']
164+
['Magento_Catalog', 'gallery/fullscreen/transition/duration', '300'],
165+
['Magento_Catalog', 'product_image_white_borders', '1'],
163166
];
164167

165168
$this->configView->expects($this->any())
@@ -183,6 +186,7 @@ public function testGetFSOptionsJson()
183186
$this->assertSame('thumbs', $decodedJson['navtype']);
184187
$this->assertSame('dissolve', $decodedJson['transition']);
185188
$this->assertSame(300, $decodedJson['transitionduration']);
189+
$this->assertSame(1, $decodedJson['whiteBorders']);
186190
}
187191

188192
public function testGetOptionsJsonOptionals()

app/code/Magento/ProductAlert/Model/Mailing/AlertProcessor.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\ProductAlert\Model\Mailing;
99

10+
use Magento\Framework\App\Area;
1011
use Magento\Catalog\Api\Data\ProductInterface;
1112
use Magento\Catalog\Api\ProductRepositoryInterface;
1213
use Magento\Catalog\Helper\Data;
@@ -24,9 +25,15 @@
2425
use Magento\Store\Api\Data\WebsiteInterface;
2526
use Magento\Store\Model\StoreManagerInterface;
2627
use Magento\Store\Model\Website;
28+
use Magento\Framework\App\ObjectManager;
29+
use Magento\Framework\View\DesignInterface;
2730

2831
/**
2932
* Class for mailing Product Alerts
33+
*
34+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
35+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
36+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3037
*/
3138
class AlertProcessor
3239
{
@@ -78,6 +85,11 @@ class AlertProcessor
7885
*/
7986
private $errorEmailSender;
8087

88+
/**
89+
* @var DesignInterface
90+
*/
91+
private $design;
92+
8193
/**
8294
* @param EmailFactory $emailFactory
8395
* @param PriceCollectionFactory $priceCollectionFactory
@@ -88,6 +100,7 @@ class AlertProcessor
88100
* @param ProductSalability $productSalability
89101
* @param StoreManagerInterface $storeManager
90102
* @param ErrorEmailSender $errorEmailSender
103+
* @param DesignInterface|null $design
91104
*/
92105
public function __construct(
93106
EmailFactory $emailFactory,
@@ -98,7 +111,8 @@ public function __construct(
98111
Data $catalogData,
99112
ProductSalability $productSalability,
100113
StoreManagerInterface $storeManager,
101-
ErrorEmailSender $errorEmailSender
114+
ErrorEmailSender $errorEmailSender,
115+
DesignInterface $design = null
102116
) {
103117
$this->emailFactory = $emailFactory;
104118
$this->priceCollectionFactory = $priceCollectionFactory;
@@ -109,6 +123,8 @@ public function __construct(
109123
$this->productSalability = $productSalability;
110124
$this->storeManager = $storeManager;
111125
$this->errorEmailSender = $errorEmailSender;
126+
$this->design = $design ?: ObjectManager::getInstance()
127+
->get(DesignInterface::class);
112128
}
113129

114130
/**
@@ -142,6 +158,12 @@ public function process(string $alertType, array $customerIds, int $websiteId):
142158
*/
143159
private function processAlerts(string $alertType, array $customerIds, int $websiteId): array
144160
{
161+
//Set the current design theme
162+
$this->design->setDesignTheme(
163+
$this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND),
164+
Area::AREA_FRONTEND
165+
);
166+
145167
/** @var Email $email */
146168
$email = $this->emailFactory->create();
147169
$email->setType($alertType);

app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Sales\Controller\Adminhtml\Order;
77

88
use Magento\Framework\App\Action\HttpPostActionInterface;
9+
use Magento\Sales\Model\Order;
910
use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender;
1011

1112
/**
@@ -44,7 +45,8 @@ public function execute()
4445
);
4546
}
4647

47-
$order->setStatus($data['status']);
48+
$orderStatus = $this->getOrderStatus($order->getDataByKey('status'), $data['status']);
49+
$order->setStatus($orderStatus);
4850
$notify = $data['is_customer_notified'] ?? false;
4951
$visible = $data['is_visible_on_front'] ?? false;
5052

@@ -53,7 +55,7 @@ public function execute()
5355
}
5456

5557
$comment = trim(strip_tags($data['comment']));
56-
$history = $order->addStatusHistoryComment($comment, $data['status']);
58+
$history = $order->addStatusHistoryComment($comment, $orderStatus);
5759
$history->setIsVisibleOnFront($visible);
5860
$history->setIsCustomerNotified($notify);
5961
$history->save();
@@ -79,4 +81,17 @@ public function execute()
7981
}
8082
return $this->resultRedirectFactory->create()->setPath('sales/*/');
8183
}
84+
85+
/**
86+
* Get order status to set
87+
*
88+
* @param string $orderStatus
89+
* @param string $historyStatus
90+
* @return string
91+
*/
92+
private function getOrderStatus(string $orderStatus, string $historyStatus): string
93+
{
94+
return ($orderStatus === Order::STATE_PROCESSING || $orderStatus === Order::STATUS_FRAUD) ? $historyStatus
95+
: $orderStatus;
96+
}
8297
}

app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
118118

119119
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
120120
$order = $creditmemo->getOrder();
121+
$paymentHTML = $this->getPaymentHtml($order);
121122
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
122123
$transport = [
123124
'order' => $order,
@@ -126,7 +127,7 @@ public function send(Creditmemo $creditmemo, $forceSyncMode = false)
126127
'creditmemo_id' => $creditmemo->getId(),
127128
'comment' => $creditmemo->getCustomerNoteNotify() ? $creditmemo->getCustomerNote() : '',
128129
'billing' => $order->getBillingAddress(),
129-
'payment_html' => $this->getPaymentHtml($order),
130+
'payment_html' => $paymentHTML,
130131
'store' => $order->getStore(),
131132
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
132133
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),

app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
126126
$order->setBaseTaxAmount((float) $invoice->getBaseTaxAmount());
127127
$order->setBaseShippingAmount((float) $invoice->getBaseShippingAmount());
128128
}
129+
$paymentHTML = $this->getPaymentHtml($order);
129130
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
130131
$transport = [
131132
'order' => $order,
@@ -134,7 +135,7 @@ public function send(Invoice $invoice, $forceSyncMode = false)
134135
'invoice_id' => $invoice->getId(),
135136
'comment' => $invoice->getCustomerNoteNotify() ? $invoice->getCustomerNote() : '',
136137
'billing' => $order->getBillingAddress(),
137-
'payment_html' => $this->getPaymentHtml($order),
138+
'payment_html' => $paymentHTML,
138139
'store' => $order->getStore(),
139140
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
140141
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),

app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
120120
if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {
121121
$order = $shipment->getOrder();
122122
$this->identityContainer->setStore($order->getStore());
123+
$paymentHTML = $this->getPaymentHtml($order);
123124
$this->appEmulation->startEnvironmentEmulation($order->getStoreId(), Area::AREA_FRONTEND, true);
124125
$transport = [
125126
'order' => $order,
@@ -128,7 +129,7 @@ public function send(Shipment $shipment, $forceSyncMode = false)
128129
'shipment_id' => $shipment->getId(),
129130
'comment' => $shipment->getCustomerNoteNotify() ? $shipment->getCustomerNote() : '',
130131
'billing' => $order->getBillingAddress(),
131-
'payment_html' => $this->getPaymentHtml($order),
132+
'payment_html' => $paymentHTML,
132133
'store' => $order->getStore(),
133134
'formattedShippingAddress' => $this->getFormattedShippingAddress($order),
134135
'formattedBillingAddress' => $this->getFormattedBillingAddress($order),

app/code/Magento/Sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Sales\Plugin\Model\ResourceModel\Order;
88

9+
use DateTime;
10+
use DateTimeInterface;
911
use Magento\Framework\DB\Select;
1012
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1113
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
@@ -44,11 +46,12 @@ public function aroundAddFieldToFilter(
4446
$field,
4547
$condition = null
4648
) {
47-
4849
if ($field === 'created_at' || $field === 'order_created_at') {
4950
if (is_array($condition)) {
5051
foreach ($condition as $key => $value) {
51-
$condition[$key] = $this->timeZone->convertConfigTimeToUtc($value);
52+
if ($value = $this->isValidDate($value)) {
53+
$condition[$key] = $value->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
54+
}
5255
}
5356
}
5457

@@ -61,4 +64,21 @@ public function aroundAddFieldToFilter(
6164

6265
return $proceed($field, $condition);
6366
}
67+
68+
/**
69+
* Validate date string
70+
*
71+
* @param mixed $datetime
72+
* @return mixed
73+
*/
74+
private function isValidDate(mixed $datetime): mixed
75+
{
76+
try {
77+
return $datetime instanceof DateTimeInterface
78+
? $datetime : (is_string($datetime)
79+
? new DateTime($datetime, new \DateTimeZone($this->timeZone->getConfigTimezone())) : false);
80+
} catch (\Exception $e) {
81+
return false;
82+
}
83+
}
6484
}

app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/AddCommentTest.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,22 @@ protected function setUp(): void
108108

109109
/**
110110
* @param array $historyData
111+
* @param string $orderStatus
111112
* @param bool $userHasResource
112113
* @param bool $expectedNotify
113114
*
114115
* @dataProvider executeWillNotifyCustomerDataProvider
115116
*/
116-
public function testExecuteWillNotifyCustomer(array $historyData, bool $userHasResource, bool $expectedNotify)
117-
{
117+
public function testExecuteWillNotifyCustomer(
118+
array $historyData,
119+
string $orderStatus,
120+
bool $userHasResource,
121+
bool $expectedNotify
122+
) {
118123
$orderId = 30;
119124
$this->requestMock->expects($this->once())->method('getParam')->with('order_id')->willReturn($orderId);
125+
$this->orderMock->expects($this->atLeastOnce())->method('getDataByKey')
126+
->with('status')->willReturn($orderStatus);
120127
$this->orderRepositoryMock->expects($this->once())
121128
->method('get')
122129
->willReturn($this->orderMock);
@@ -129,7 +136,6 @@ public function testExecuteWillNotifyCustomer(array $historyData, bool $userHasR
129136
$this->objectManagerMock->expects($this->once())->method('create')->willReturn(
130137
$this->createMock(OrderCommentSender::class)
131138
);
132-
133139
$this->addCommentController->execute();
134140
}
135141

@@ -143,51 +149,57 @@ public function executeWillNotifyCustomerDataProvider()
143149
'postData' => [
144150
'comment' => 'Great Product!',
145151
'is_customer_notified' => true,
146-
'status' => 'Processing'
152+
'status' => 'processing'
147153
],
154+
'orderStatus' =>'processing',
148155
'userHasResource' => true,
149156
'expectedNotify' => true
150157
],
151158
'User Has Access - Notify False' => [
152159
'postData' => [
153160
'comment' => 'Great Product!',
154161
'is_customer_notified' => false,
155-
'status' => 'Processing'
162+
'status' => 'processing'
156163
],
164+
'orderStatus' =>'processing',
157165
'userHasResource' => true,
158166
'expectedNotify' => false
159167
],
160168
'User Has Access - Notify Unset' => [
161169
'postData' => [
162170
'comment' => 'Great Product!',
163-
'status' => 'Processing'
171+
'status' => 'processing'
164172
],
173+
'orderStatus' =>'fraud',
165174
'userHasResource' => true,
166175
'expectedNotify' => false
167176
],
168177
'User No Access - Notify True' => [
169178
'postData' => [
170179
'comment' => 'Great Product!',
171180
'is_customer_notified' => true,
172-
'status' => 'Processing'
181+
'status' => 'fraud'
173182
],
183+
'orderStatus' =>'processing',
174184
'userHasResource' => false,
175185
'expectedNotify' => false
176186
],
177187
'User No Access - Notify False' => [
178188
'postData' => [
179189
'comment' => 'Great Product!',
180190
'is_customer_notified' => false,
181-
'status' => 'Processing'
191+
'status' => 'processing'
182192
],
193+
'orderStatus' =>'complete',
183194
'userHasResource' => false,
184195
'expectedNotify' => false
185196
],
186197
'User No Access - Notify Unset' => [
187198
'postData' => [
188199
'comment' => 'Great Product!',
189-
'status' => 'Processing'
200+
'status' => 'processing'
190201
],
202+
'orderStatus' =>'complete',
191203
'userHasResource' => false,
192204
'expectedNotify' => false
193205
],

dev/tests/integration/framework/Magento/TestFramework/Application.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ private function initLogger()
373373
);
374374
$objectManager->removeSharedInstance(LoggerInterface::class, true);
375375
$objectManager->addSharedInstance($logger, LoggerInterface::class, true);
376+
$objectManager->removeSharedInstance(TestFramework\ErrorLog\Logger::class, true);
377+
$objectManager->addSharedInstance($logger, TestFramework\ErrorLog\Logger::class, true);
376378
return $logger;
377379
}
378380

0 commit comments

Comments
 (0)