Skip to content

Commit

Permalink
Merge pull request #3717 from magento-arcticfoxes/MC-13852
Browse files Browse the repository at this point in the history
[arcticfoxes] MC-13852: Refactoring of BiC changes for 2.3.1
  • Loading branch information
rganin authored Feb 9, 2019
2 parents a4c3703 + 9b1d263 commit 00fb2aa
Show file tree
Hide file tree
Showing 37 changed files with 193 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;

use Magento\Customer\Api\Data\GroupInterface;

/**
* Products mass update inventory tab
*
Expand All @@ -31,29 +29,20 @@ class Inventory extends \Magento\Backend\Block\Widget implements \Magento\Backen
*/
protected $disabledFields = [];

/**
* @var \Magento\Framework\Serialize\SerializerInterface
*/
private $serializer;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\CatalogInventory\Model\Source\Backorders $backorders
* @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration
* @param array $data
* @param \Magento\Framework\Serialize\SerializerInterface|null $serializer
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\CatalogInventory\Model\Source\Backorders $backorders,
\Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration,
array $data = [],
\Magento\Framework\Serialize\SerializerInterface $serializer = null
array $data = []
) {
$this->_backorders = $backorders;
$this->stockConfiguration = $stockConfiguration;
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Serialize\SerializerInterface::class);
parent::__construct($context, $data);
}

Expand Down Expand Up @@ -85,9 +74,7 @@ public function getFieldSuffix()
*/
public function getStoreId()
{
$storeId = (int)$this->getRequest()->getParam('store');

return $storeId;
return (int)$this->getRequest()->getParam('store');
}

/**
Expand All @@ -101,22 +88,6 @@ public function getDefaultConfigValue($field)
return $this->stockConfiguration->getDefaultConfigValue($field);
}

/**
* Returns min_sale_qty configuration for the ALL Customer Group
*
* @return float
*/
public function getDefaultMinSaleQty()
{
$default = $this->stockConfiguration->getDefaultConfigValue('min_sale_qty');
if (!is_numeric($default)) {
$default = $this->serializer->unserialize($default);
$default = $default[GroupInterface::CUST_GROUP_ALL] ?? 1;
}

return (float) $default;
}

/**
* Tab settings
*
Expand Down
11 changes: 3 additions & 8 deletions app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements

const CACHE_TAG = 'cat_c';

/**
* Category Store Id
*/
const STORE_ID = 'store_id';

/**#@-*/
protected $_eventPrefix = 'catalog_category';

Expand Down Expand Up @@ -573,8 +568,8 @@ public function getStoreIds()
*/
public function getStoreId()
{
if ($this->hasData(self::STORE_ID)) {
return (int)$this->_getData(self::STORE_ID);
if ($this->hasData('store_id')) {
return (int)$this->_getData('store_id');
}
return (int)$this->_storeManager->getStore()->getId();
}
Expand All @@ -590,7 +585,7 @@ public function setStoreId($storeId)
if (!is_numeric($storeId)) {
$storeId = $this->_storeManager->getStore($storeId)->getId();
}
$this->setData(self::STORE_ID, $storeId);
$this->setData('store_id', $storeId);
$this->getResource()->setStoreId($storeId);
return $this;
}
Expand Down
5 changes: 0 additions & 5 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
*/
const STORE_ID = 'store_id';

/**
* Product Url path.
*/
const URL_PATH = 'url_path';

/**
* @var string
*/
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product/Copier.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function copy(Product $product)
? $matches[1] . '-' . ($matches[2] + 1)
: $urlKey . '-1';
$duplicate->setUrlKey($urlKey);
$duplicate->setData(Product::URL_PATH, null);
$duplicate->setData('url_path', null);
try {
$duplicate->save();
$isDuplicateSaved = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Edit\Action\Attribute\Tab;

use Magento\Customer\Api\Data\GroupInterface;

/**
* Class InventoryTest
*/
Expand Down Expand Up @@ -70,8 +68,7 @@ protected function setUp()
[
'context' => $this->contextMock,
'backorders' => $this->backordersMock,
'stockConfiguration' => $this->stockConfigurationMock,
'serializer' => new \Magento\Framework\Serialize\Serializer\Json(),
'stockConfiguration' => $this->stockConfigurationMock
]
);
}
Expand Down Expand Up @@ -129,32 +126,6 @@ public function testGetDefaultConfigValue()
$this->assertEquals('return-value', $this->inventory->getDefaultConfigValue('field-name'));
}

/**
* @dataProvider getDefaultMinSaleQtyDataProvider
* @param string $expected
* @param string $default
*/
public function testGetDefaultMinSaleQty($expected, $default)
{
$this->stockConfigurationMock->method('getDefaultConfigValue')->willReturn($default);
$this->assertEquals($expected, $this->inventory->getDefaultMinSaleQty());
}

public function getDefaultMinSaleQtyDataProvider()
{
return [
'single-default-value' => [
22, '22'
],
'no-default-for-all-group' => [
1, json_encode(['12' => '111'])
],
'default-for-all-group' => [
5, json_encode(['12' => '111', GroupInterface::CUST_GROUP_ALL => '5'])
]
];
}

/**
* Run test getTabLabel method
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
});
</script>

<?php
$defaultMinSaleQty = $block->getDefaultConfigValue('min_sale_qty');
if (!is_numeric($defaultMinSaleQty)) {
$defaultMinSaleQty = json_decode($defaultMinSaleQty, true);
$defaultMinSaleQty = (float) $defaultMinSaleQty[\Magento\Customer\Api\Data\GroupInterface::CUST_GROUP_ALL] ?? 1;
}
?>
<div class="fieldset-wrapper form-inline advanced-inventory-edit">
<div class="fieldset-wrapper-title">
<strong class="title">
Expand Down Expand Up @@ -132,7 +139,7 @@
<div class="field">
<input type="text" class="input-text validate-number" id="inventory_min_sale_qty"
name="<?= /* @escapeNotVerified */ $block->getFieldSuffix() ?>[min_sale_qty]"
value="<?= /* @escapeNotVerified */ $block->getDefaultMinSaleQty() * 1 ?>"
value="<?= /* @escapeNotVerified */ $defaultMinSaleQty ?>"
disabled="disabled"/>
</div>
<div class="field choice">
Expand Down
26 changes: 8 additions & 18 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,6 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
*/
const COL_NAME = 'name';

/**
* Column new_from_date.
*/
const COL_NEW_FROM_DATE = 'new_from_date';

/**
* Column new_to_date.
*/
const COL_NEW_TO_DATE = 'new_to_date';

/**
* Column product website.
*/
Expand Down Expand Up @@ -309,7 +299,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
ValidatorInterface::ERROR_INVALID_WEIGHT => 'Product weight is invalid',
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',
ValidatorInterface::ERROR_DUPLICATE_MULTISELECT_VALUES => 'Value for multiselect attribute %s contains duplicated values',
ValidatorInterface::ERROR_NEW_TO_DATE => 'Make sure new_to_date is later than or the same as new_from_date',
'invalidNewToDateValue' => 'Make sure new_to_date is later than or the same as new_from_date',
];
//@codingStandardsIgnoreEnd

Expand All @@ -331,8 +321,8 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
Product::COL_TYPE => 'product_type',
Product::COL_PRODUCT_WEBSITES => 'product_websites',
'status' => 'product_online',
'news_from_date' => self::COL_NEW_FROM_DATE,
'news_to_date' => self::COL_NEW_TO_DATE,
'news_from_date' => 'new_from_date',
'news_to_date' => 'new_to_date',
'options_container' => 'display_product_options_in',
'minimal_price' => 'map_price',
'msrp' => 'msrp_price',
Expand Down Expand Up @@ -2564,16 +2554,16 @@ public function validateRow(array $rowData, $rowNum)
}
}

if (!empty($rowData[self::COL_NEW_FROM_DATE]) && !empty($rowData[self::COL_NEW_TO_DATE])
if (!empty($rowData['new_from_date']) && !empty($rowData['new_to_date'])
) {
$newFromTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_FROM_DATE], false));
$newToTimestamp = strtotime($this->dateTime->formatDate($rowData[self::COL_NEW_TO_DATE], false));
$newFromTimestamp = strtotime($this->dateTime->formatDate($rowData['new_from_date'], false));
$newToTimestamp = strtotime($this->dateTime->formatDate($rowData['new_to_date'], false));
if ($newFromTimestamp > $newToTimestamp) {
$this->skipRow(
$rowNum,
ValidatorInterface::ERROR_NEW_TO_DATE,
'invalidNewToDateValue',
$errorLevel,
$rowData[self::COL_NEW_TO_DATE]
$rowData['new_to_date']
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ interface RowValidatorInterface extends \Magento\Framework\Validator\ValidatorIn

const ERROR_DUPLICATE_MULTISELECT_VALUES = 'duplicatedMultiselectValues';

const ERROR_NEW_TO_DATE = 'invalidNewToDateValue';

/**
* Value that means all entities (e.g. websites, groups etc.)
*/
Expand Down
8 changes: 2 additions & 6 deletions app/code/Magento/Customer/Api/AccountManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ interface AccountManagementInterface
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @param string $password
* @param string $redirectUrl
* @param string[] $extensions
* @return \Magento\Customer\Api\Data\CustomerInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function createAccount(
\Magento\Customer\Api\Data\CustomerInterface $customer,
$password = null,
$redirectUrl = '',
$extensions = []
$redirectUrl = ''
);

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

/**
Expand Down
Loading

0 comments on commit 00fb2aa

Please sign in to comment.