Skip to content

Commit e406c82

Browse files
authored
Merge branch '2.4-develop' into add-AdminClickInvoiceButtonIntoOrderActionGroup
2 parents 3dd3bb9 + d4d757b commit e406c82

File tree

7 files changed

+76
-16
lines changed

7 files changed

+76
-16
lines changed

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ $_helper = $block->getData('outputHelper');
9898
<?= $block->getBlockHtml('formkey') ?>
9999
<button type="submit"
100100
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>"
101-
class="action tocart primary">
101+
class="action tocart primary"
102+
disabled>
102103
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
103104
</button>
104105
</form>

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ define([
3434
if (this.options.bindSubmit) {
3535
this._bindSubmit();
3636
}
37+
$(this.options.addToCartButtonSelector).attr('disabled', false);
3738
},
3839

3940
/**

app/code/Magento/Eav/Model/Entity/AbstractEntity.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,8 @@ protected function _isApplicableAttribute($object, $attribute)
626626
public function walkAttributes($partMethod, array $args = [], $collectExceptionMessages = null)
627627
{
628628
$methodArr = explode('/', $partMethod);
629+
$part = '';
630+
$method = '';
629631
switch (count($methodArr)) {
630632
case 1:
631633
$part = 'attribute';
@@ -642,6 +644,7 @@ public function walkAttributes($partMethod, array $args = [], $collectExceptionM
642644
}
643645
$results = [];
644646
$suffix = $this->getAttributesCacheSuffix($args[0]);
647+
$instance = null;
645648
foreach ($this->getAttributesByScope($suffix) as $attrCode => $attribute) {
646649
if (isset($args[0]) && is_object($args[0]) && !$this->_isApplicableAttribute($args[0], $attribute)) {
647650
continue;
@@ -1337,7 +1340,9 @@ protected function _collectSaveData($newObject)
13371340
if ($this->_canUpdateAttribute($attribute, $v, $origData)) {
13381341
if ($this->_isAttributeValueEmpty($attribute, $v)) {
13391342
$this->_aggregateDeleteData($delete, $attribute, $newObject);
1340-
} elseif (!is_numeric($v) && $v !== $origData[$k] || is_numeric($v) && $v != $origData[$k]) {
1343+
} elseif (!is_numeric($v) && $v !== $origData[$k]
1344+
|| is_numeric($v) && ($v != $origData[$k] || strlen($v) !== strlen($origData[$k]))
1345+
) {
13411346
$update[$attrId] = [
13421347
'value_id' => $attribute->getBackend()->getEntityValueId($newObject),
13431348
'value' => is_array($v) ? array_shift($v) : $v,//@TODO: MAGETWO-44182,
@@ -1739,6 +1744,7 @@ public function delete($object)
17391744
{
17401745
try {
17411746
$connection = $this->transactionManager->start($this->getConnection());
1747+
$id = 0;
17421748
if (is_numeric($object)) {
17431749
$id = (int) $object;
17441750
} elseif ($object instanceof \Magento\Framework\Model\AbstractModel) {

app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ protected function prepareIndex($storeId, $indexName, $mappedIndexerId)
497497
*/
498498
private function getMappingTotalFieldsLimit(array $allAttributeTypes): int
499499
{
500-
return count($allAttributeTypes) + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
500+
$count = count($allAttributeTypes);
501+
foreach ($allAttributeTypes as $attributeType) {
502+
if (isset($attributeType['fields'])) {
503+
$count += count($attributeType['fields']);
504+
}
505+
}
506+
return $count + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
501507
}
502508
}

app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/ElasticsearchTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ protected function setUp(): void
174174
->method('getAllAttributesTypes')
175175
->willReturn(
176176
[
177-
'name' => 'string',
177+
'name' => [
178+
'type' => 'string',
179+
'fields' => [
180+
'keyword' => [
181+
'type' => "keyword",
182+
],
183+
],
184+
],
178185
]
179186
);
180187
$this->clientConfig->expects($this->any())
@@ -564,6 +571,28 @@ public function testUpdateIndexMappingWithAliasDefinition(): void
564571
$this->model->updateIndexMapping($storeId, $mappedIndexerId, $attributeCode);
565572
}
566573

574+
/**
575+
* Test for get mapping total fields limit
576+
*
577+
* @return void
578+
*/
579+
public function testGetMappingTotalFieldsLimit(): void
580+
{
581+
$settings = [
582+
'index' => [
583+
'mapping' => [
584+
'total_fields' => [
585+
'limit' => 1002
586+
]
587+
]
588+
]
589+
];
590+
$this->client->expects($this->at(1))
591+
->method('createIndex')
592+
->with(null, ['settings' => $settings]);
593+
$this->model->cleanIndex(1, 'product');
594+
}
595+
567596
/**
568597
* Get elasticsearch client options
569598
*

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)