Skip to content

Commit

Permalink
Merge pull request #6109 from magento-tsg-csl3/2.4-develop-pr39
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4 (pr39)
  • Loading branch information
viktym authored Sep 9, 2020
2 parents 20b7e0d + c6985f6 commit d4d757b
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ $_helper = $block->getData('outputHelper');
<?= $block->getBlockHtml('formkey') ?>
<button type="submit"
title="<?= $escaper->escapeHtmlAttr(__('Add to Cart')) ?>"
class="action tocart primary">
class="action tocart primary"
disabled>
<span><?= $escaper->escapeHtml(__('Add to Cart')) ?></span>
</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define([
if (this.options.bindSubmit) {
this._bindSubmit();
}
$(this.options.addToCartButtonSelector).attr('disabled', false);
},

/**
Expand Down
8 changes: 7 additions & 1 deletion app/code/Magento/Eav/Model/Entity/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,8 @@ protected function _isApplicableAttribute($object, $attribute)
public function walkAttributes($partMethod, array $args = [], $collectExceptionMessages = null)
{
$methodArr = explode('/', $partMethod);
$part = '';
$method = '';
switch (count($methodArr)) {
case 1:
$part = 'attribute';
Expand All @@ -642,6 +644,7 @@ public function walkAttributes($partMethod, array $args = [], $collectExceptionM
}
$results = [];
$suffix = $this->getAttributesCacheSuffix($args[0]);
$instance = null;
foreach ($this->getAttributesByScope($suffix) as $attrCode => $attribute) {
if (isset($args[0]) && is_object($args[0]) && !$this->_isApplicableAttribute($args[0], $attribute)) {
continue;
Expand Down Expand Up @@ -1337,7 +1340,9 @@ protected function _collectSaveData($newObject)
if ($this->_canUpdateAttribute($attribute, $v, $origData)) {
if ($this->_isAttributeValueEmpty($attribute, $v)) {
$this->_aggregateDeleteData($delete, $attribute, $newObject);
} elseif (!is_numeric($v) && $v !== $origData[$k] || is_numeric($v) && $v != $origData[$k]) {
} elseif (!is_numeric($v) && $v !== $origData[$k]
|| is_numeric($v) && ($v != $origData[$k] || strlen($v) !== strlen($origData[$k]))
) {
$update[$attrId] = [
'value_id' => $attribute->getBackend()->getEntityValueId($newObject),
'value' => is_array($v) ? array_shift($v) : $v,//@TODO: MAGETWO-44182,
Expand Down Expand Up @@ -1739,6 +1744,7 @@ public function delete($object)
{
try {
$connection = $this->transactionManager->start($this->getConnection());
$id = 0;
if (is_numeric($object)) {
$id = (int) $object;
} elseif ($object instanceof \Magento\Framework\Model\AbstractModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ protected function prepareIndex($storeId, $indexName, $mappedIndexerId)
*/
private function getMappingTotalFieldsLimit(array $allAttributeTypes): int
{
return count($allAttributeTypes) + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
$count = count($allAttributeTypes);
foreach ($allAttributeTypes as $attributeType) {
if (isset($attributeType['fields'])) {
$count += count($attributeType['fields']);
}
}
return $count + self::MAPPING_TOTAL_FIELDS_BUFFER_LIMIT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ protected function setUp(): void
->method('getAllAttributesTypes')
->willReturn(
[
'name' => 'string',
'name' => [
'type' => 'string',
'fields' => [
'keyword' => [
'type' => "keyword",
],
],
],
]
);
$this->clientConfig->expects($this->any())
Expand Down Expand Up @@ -564,6 +571,28 @@ public function testUpdateIndexMappingWithAliasDefinition(): void
$this->model->updateIndexMapping($storeId, $mappedIndexerId, $attributeCode);
}

/**
* Test for get mapping total fields limit
*
* @return void
*/
public function testGetMappingTotalFieldsLimit(): void
{
$settings = [
'index' => [
'mapping' => [
'total_fields' => [
'limit' => 1002
]
]
]
];
$this->client->expects($this->at(1))
->method('createIndex')
->with(null, ['settings' => $settings]);
$this->model->cleanIndex(1, 'product');
}

/**
* Get elasticsearch client options
*
Expand Down
26 changes: 14 additions & 12 deletions app/code/Magento/Sales/Model/ResourceModel/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ protected function _construct()

/**
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
* @param Attribute $attribute
* @param Manager $sequenceManager
* @param Snapshot $entitySnapshot
* @param RelationComposite $entityRelationComposite
* @param Attribute $attribute
* @param Manager $sequenceManager
* @param StateHandler $stateHandler
* @param string $connectionName
* @param string|null $connectionName
*/
public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context,
Expand Down Expand Up @@ -137,6 +137,8 @@ protected function calculateItems(\Magento\Sales\Model\Order $object)
}

/**
* Before save
*
* @param \Magento\Framework\Model\AbstractModel $object
* @return $this
*/
Expand All @@ -152,15 +154,15 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
];
$object->setStoreName(implode(PHP_EOL, $name));
$object->setTotalItemCount($this->calculateItems($object));
$object->setData(
'protect_code',
substr(
hash('sha256', uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)),
5,
32
)
);
}
$object->setData(
'protect_code',
substr(
hash('sha256', uniqid(Random::getRandomNumber(), true) . ':' . microtime(true)),
5,
32
)
);
$isNewCustomer = !$object->getCustomerId() || $object->getCustomerId() === true;
if ($isNewCustomer && $object->getCustomer()) {
$object->setCustomerId($object->getCustomer()->getId());
Expand All @@ -169,7 +171,7 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function save(\Magento\Framework\Model\AbstractModel $object)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ public function testAclNoAccess()
parent::testAclNoAccess();
}

/**
* Checks that order protect code is not changing after invoice submitting
*
* @return void
*/
public function testOrderProtectCodePreserveAfterInvoiceSave(): void
{
$order = $this->prepareRequest();
$protectCode = $order->getProtectCode();
$this->dispatch($this->uri);
$invoicedOrder = $this->getOrder('100000001');

$this->assertEquals($protectCode, $invoicedOrder->getProtectCode());
}

/**
* @param array $params
* @return \Magento\Sales\Api\Data\OrderInterface|null
Expand Down

0 comments on commit d4d757b

Please sign in to comment.