Skip to content

Commit 00fb2aa

Browse files
authored
Merge pull request #3717 from magento-arcticfoxes/MC-13852
[arcticfoxes] MC-13852: Refactoring of BiC changes for 2.3.1
2 parents a4c3703 + 9b1d263 commit 00fb2aa

File tree

37 files changed

+193
-475
lines changed

37 files changed

+193
-475
lines changed

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/Inventory.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Products mass update inventory tab
1210
*
@@ -31,29 +29,20 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
3129
*/
3230
protected $disabledFields = [];
3331

34-
/**
35-
* @var \Magento\Framework\Serialize\SerializerInterface
36-
*/
37-
private $serializer;
38-
3932
/**
4033
* @param \Magento\Backend\Block\Template\Context $context
4134
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
4235
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
4336
* @param array $data
44-
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
4537
*/
4638
public function __construct(
4739
\Magento\Backend\Block\Template\Context $context,
4840
\Magento\CatalogInventory\Model\Source\Backorders $backorders,
4941
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
50-
array $data = [],
51-
\Magento\Framework\Serialize\SerializerInterface $serializer = null
42+
array $data = []
5243
) {
5344
$this->_backorders = $backorders;
5445
$this->stockConfiguration = $stockConfiguration;
55-
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance()
56-
->get(\Magento\Framework\Serialize\SerializerInterface::class);
5746
parent::__construct($context, $data);
5847
}
5948

@@ -85,9 +74,7 @@ public function getFieldSuffix()
8574
*/
8675
public function getStoreId()
8776
{
88-
$storeId = (int)$this->getRequest()->getParam('store');
89-
90-
return $storeId;
77+
return (int)$this->getRequest()->getParam('store');
9178
}
9279

9380
/**
@@ -101,22 +88,6 @@ public function getDefaultConfigValue($field)
10188
return $this->stockConfiguration->getDefaultConfigValue($field);
10289
}
10390

104-
/**
105-
* Returns min_sale_qty configuration for the ALL Customer Group
106-
*
107-
* @return float
108-
*/
109-
public function getDefaultMinSaleQty()
110-
{
111-
$default = $this->stockConfiguration->getDefaultConfigValue('min_sale_qty');
112-
if (!is_numeric($default)) {
113-
$default = $this->serializer->unserialize($default);
114-
$default = $default[GroupInterface::CUST_GROUP_ALL] ?? 1;
115-
}
116-
117-
return (float) $default;
118-
}
119-
12091
/**
12192
* Tab settings
12293
*

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
7272

7373
const CACHE_TAG = 'cat_c';
7474

75-
/**
76-
* Category Store Id
77-
*/
78-
const STORE_ID = 'store_id';
79-
8075
/**#@-*/
8176
protected $_eventPrefix = 'catalog_category';
8277

@@ -573,8 +568,8 @@ public function getStoreIds()
573568
*/
574569
public function getStoreId()
575570
{
576-
if ($this->hasData(self::STORE_ID)) {
577-
return (int)$this->_getData(self::STORE_ID);
571+
if ($this->hasData('store_id')) {
572+
return (int)$this->_getData('store_id');
578573
}
579574
return (int)$this->_storeManager->getStore()->getId();
580575
}
@@ -590,7 +585,7 @@ public function setStoreId($storeId)
590585
if (!is_numeric($storeId)) {
591586
$storeId = $this->_storeManager->getStore($storeId)->getId();
592587
}
593-
$this->setData(self::STORE_ID, $storeId);
588+
$this->setData('store_id', $storeId);
594589
$this->getResource()->setStoreId($storeId);
595590
return $this;
596591
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
7171
*/
7272
const STORE_ID = 'store_id';
7373

74-
/**
75-
* Product Url path.
76-
*/
77-
const URL_PATH = 'url_path';
78-
7974
/**
8075
* @var string
8176
*/

app/code/Magento/Catalog/Model/Product/Copier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function copy(Product $product)
8383
? $matches[1] . '-' . ($matches[2] + 1)
8484
: $urlKey . '-1';
8585
$duplicate->setUrlKey($urlKey);
86-
$duplicate->setData(Product::URL_PATH, null);
86+
$duplicate->setData('url_path', null);
8787
try {
8888
$duplicate->save();
8989
$isDuplicateSaved = true;

app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Action/Attribute/Tab/InventoryTest.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;
77

8-
use Magento\Customer\Api\Data\GroupInterface;
9-
108
/**
119
* Class InventoryTest
1210
*/
@@ -70,8 +68,7 @@ protected function setUp()
7068
[
7169
'context' => $this->contextMock,
7270
'backorders' => $this->backordersMock,
73-
'stockConfiguration' => $this->stockConfigurationMock,
74-
'serializer' => new \Magento\Framework\Serialize\Serializer\Json(),
71+
'stockConfiguration' => $this->stockConfigurationMock
7572
]
7673
);
7774
}
@@ -129,32 +126,6 @@ public function testGetDefaultConfigValue()
129126
$this->assertEquals('return-value', $this->inventory->getDefaultConfigValue('field-name'));
130127
}
131128

132-
/**
133-
* @dataProvider getDefaultMinSaleQtyDataProvider
134-
* @param string $expected
135-
* @param string $default
136-
*/
137-
public function testGetDefaultMinSaleQty($expected, $default)
138-
{
139-
$this->stockConfigurationMock->method('getDefaultConfigValue')->willReturn($default);
140-
$this->assertEquals($expected, $this->inventory->getDefaultMinSaleQty());
141-
}
142-
143-
public function getDefaultMinSaleQtyDataProvider()
144-
{
145-
return [
146-
'single-default-value' => [
147-
22, '22'
148-
],
149-
'no-default-for-all-group' => [
150-
1, json_encode(['12' => '111'])
151-
],
152-
'default-for-all-group' => [
153-
5, json_encode(['12' => '111', GroupInterface::CUST_GROUP_ALL => '5'])
154-
]
155-
];
156-
}
157-
158129
/**
159130
* Run test getTabLabel method
160131
*

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/action/inventory.phtml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
});
3131
</script>
3232

33+
<?php
34+
$defaultMinSaleQty = $block->getDefaultConfigValue('min_sale_qty');
35+
if (!is_numeric($defaultMinSaleQty)) {
36+
$defaultMinSaleQty = json_decode($defaultMinSaleQty, true);
37+
$defaultMinSaleQty = (float) $defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1;
38+
}
39+
?>
3340
<div class="fieldset-wrapper form-inline advanced-inventory-edit">
3441
<div class="fieldset-wrapper-title">
3542
<strong class="title">
@@ -132,7 +139,7 @@
132139
<div class="field">
133140
<input type="text" class="input-text validate-number" id="inventory_min_sale_qty"
134141
name="<?= /* @escapeNotVerified */ $block->getFieldSuffix() ?>[min_sale_qty]"
135-
value="<?= /* @escapeNotVerified */ $block->getDefaultMinSaleQty() * 1 ?>"
142+
value="<?= /* @escapeNotVerified */ $defaultMinSaleQty ?>"
136143
disabled="disabled"/>
137144
</div>
138145
<div class="field choice">

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
133133
*/
134134
const COL_NAME = 'name';
135135

136-
/**
137-
* Column new_from_date.
138-
*/
139-
const COL_NEW_FROM_DATE = 'new_from_date';
140-
141-
/**
142-
* Column new_to_date.
143-
*/
144-
const COL_NEW_TO_DATE = 'new_to_date';
145-
146136
/**
147137
* Column product website.
148138
*/
@@ -309,7 +299,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
309299
ValidatorInterface::ERROR_INVALID_WEIGHT => 'Product weight is invalid',
310300
ValidatorInterface::ERROR_DUPLICATE_URL_KEY => 'Url key: \'%s\' was already generated for an item with the SKU: \'%s\'. You need to specify the unique URL key manually',
311301
ValidatorInterface::ERROR_DUPLICATE_MULTISELECT_VALUES => 'Value for multiselect attribute %s contains duplicated values',
312-
ValidatorInterface::ERROR_NEW_TO_DATE => 'Make sure new_to_date is later than or the same as new_from_date',
302+
'invalidNewToDateValue' => 'Make sure new_to_date is later than or the same as new_from_date',
313303
];
314304
//@codingStandardsIgnoreEnd
315305

@@ -331,8 +321,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
331321
Product::COL_TYPE => 'product_type',
332322
Product::COL_PRODUCT_WEBSITES => 'product_websites',
333323
'status' => 'product_online',
334-
'news_from_date' => self::COL_NEW_FROM_DATE,
335-
'news_to_date' => self::COL_NEW_TO_DATE,
324+
'news_from_date' => 'new_from_date',
325+
'news_to_date' => 'new_to_date',
336326
'options_container' => 'display_product_options_in',
337327
'minimal_price' => 'map_price',
338328
'msrp' => 'msrp_price',
@@ -2564,16 +2554,16 @@ public function validateRow(array $rowData, $rowNum)
25642554
}
25652555
}
25662556

2567-
if (!empty($rowData[self::COL_NEW_FROM_DATE]) && !empty($rowData[self::COL_NEW_TO_DATE])
2557+
if (!empty($rowData['new_from_date']) && !empty($rowData['new_to_date'])
25682558
) {
2569-
$newFromTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_FROM_DATE], false));
2570-
$newToTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_TO_DATE], false));
2559+
$newFromTimestamp = strtotime($this->dateTime->formatDate($rowData['new_from_date'], false));
2560+
$newToTimestamp = strtotime($this->dateTime->formatDate($rowData['new_to_date'], false));
25712561
if ($newFromTimestamp > $newToTimestamp) {
25722562
$this->skipRow(
25732563
$rowNum,
2574-
ValidatorInterface::ERROR_NEW_TO_DATE,
2564+
'invalidNewToDateValue',
25752565
$errorLevel,
2576-
$rowData[self::COL_NEW_TO_DATE]
2566+
$rowData['new_to_date']
25772567
);
25782568
}
25792569
}

app/code/Magento/CatalogImportExport/Model/Import/Product/RowValidatorInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ interface RowValidatorInterface extends \Magento\Framework\Validator\ValidatorIn
8787

8888
const ERROR_DUPLICATE_MULTISELECT_VALUES = 'duplicatedMultiselectValues';
8989

90-
const ERROR_NEW_TO_DATE = 'invalidNewToDateValue';
91-
9290
/**
9391
* Value that means all entities (e.g. websites, groups etc.)
9492
*/

app/code/Magento/Customer/Api/AccountManagementInterface.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ interface AccountManagementInterface
3131
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
3232
* @param string $password
3333
* @param string $redirectUrl
34-
* @param string[] $extensions
3534
* @return \Magento\Customer\Api\Data\CustomerInterface
3635
* @throws \Magento\Framework\Exception\LocalizedException
3736
*/
3837
public function createAccount(
3938
\Magento\Customer\Api\Data\CustomerInterface $customer,
4039
$password = null,
41-
$redirectUrl = '',
42-
$extensions = []
40+
$redirectUrl = ''
4341
);
4442

4543
/**
@@ -50,7 +48,6 @@ public function createAccount(
5048
* @param string $hash Password hash that we can save directly
5149
* @param string $redirectUrl URL fed to welcome email templates. Can be used by templates to, for example, direct
5250
* the customer to a product they were looking at after pressing confirmation link.
53-
* @param string[] $extensions
5451
* @return \Magento\Customer\Api\Data\CustomerInterface
5552
* @throws \Magento\Framework\Exception\InputException If bad input is provided
5653
* @throws \Magento\Framework\Exception\State\InputMismatchException If the provided email is already used
@@ -59,8 +56,7 @@ public function createAccount(
5956
public function createAccountWithPasswordHash(
6057
\Magento\Customer\Api\Data\CustomerInterface $customer,
6158
$hash,
62-
$redirectUrl = '',
63-
$extensions = []
59+
$redirectUrl = ''
6460
);
6561

6662
/**

0 commit comments

Comments
 (0)