Skip to content

Commit 46cc318

Browse files
committed
Merge remote-tracking branch 'origin/MC-36953' into 2.4-develop-pr39
2 parents e521bf6 + 08c529f commit 46cc318

File tree

2 files changed

+29
-12
lines changed
  • app/code/Magento/Sales/Model/ResourceModel
  • dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice

2 files changed

+29
-12
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ protected function _construct()
5353

5454
/**
5555
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
56-
* @param Attribute $attribute
57-
* @param Manager $sequenceManager
5856
* @param Snapshot $entitySnapshot
5957
* @param RelationComposite $entityRelationComposite
58+
* @param Attribute $attribute
59+
* @param Manager $sequenceManager
6060
* @param StateHandler $stateHandler
61-
* @param string $connectionName
61+
* @param string|null $connectionName
6262
*/
6363
public function __construct(
6464
\Magento\Framework\Model\ResourceModel\Db\Context $context,
@@ -137,6 +137,8 @@ protected function calculateItems(\Magento\Sales\Model\Order $object)
137137
}
138138

139139
/**
140+
* Before save
141+
*
140142
* @param \Magento\Framework\Model\AbstractModel $object
141143
* @return $this
142144
*/
@@ -152,15 +154,15 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
152154
];
153155
$object->setStoreName(implode(PHP_EOL, $name));
154156
$object->setTotalItemCount($this->calculateItems($object));
157+
$object->setData(
158+
'protect_code',
159+
substr(
160+
hash('sha256', uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)),
161+
5,
162+
32
163+
)
164+
);
155165
}
156-
$object->setData(
157-
'protect_code',
158-
substr(
159-
hash('sha256', uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)),
160-
5,
161-
32
162-
)
163-
);
164166
$isNewCustomer = !$object->getCustomerId() || $object->getCustomerId() === true;
165167
if ($isNewCustomer && $object->getCustomer()) {
166168
$object->setCustomerId($object->getCustomer()->getId());
@@ -169,7 +171,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
169171
}
170172

171173
/**
172-
* {@inheritdoc}
174+
* @inheritdoc
173175
*/
174176
public function save(\Magento\Framework\Model\AbstractModel $object)
175177
{

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ public function testAclNoAccess()
7474
parent::testAclNoAccess();
7575
}
7676

77+
/**
78+
* Checks that order protect code is not changing after invoice submitting
79+
*
80+
* @return void
81+
*/
82+
public function testOrderProtectCodePreserveAfterInvoiceSave(): void
83+
{
84+
$order = $this->prepareRequest();
85+
$protectCode = $order->getProtectCode();
86+
$this->dispatch($this->uri);
87+
$invoicedOrder = $this->getOrder('100000001');
88+
89+
$this->assertEquals($protectCode, $invoicedOrder->getProtectCode());
90+
}
91+
7792
/**
7893
* @param array $params
7994
* @return \Magento\Sales\Api\Data\OrderInterface|null

0 commit comments

Comments
 (0)