-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix mass product update with group min cart qty #19095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
*/ | ||
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Action\Attribute\Tab; | ||
|
||
use Magento\Customer\Api\Data\GroupInterface; | ||
|
||
/** | ||
* Products mass update inventory tab | ||
* | ||
|
@@ -29,20 +31,29 @@ 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 = [] | ||
array $data = [], | ||
\Magento\Framework\Serialize\SerializerInterface $serializer = null | ||
) { | ||
$this->_backorders = $backorders; | ||
$this->stockConfiguration = $stockConfiguration; | ||
$this->serializer = $serializer ?? \Magento\Framework\App\ObjectManager::getInstance() | ||
->get(\Magento\Framework\Serialize\SerializerInterface::class); | ||
parent::__construct($context, $data); | ||
} | ||
|
||
|
@@ -70,11 +81,13 @@ public function getFieldSuffix() | |
* Retrieve current store id | ||
* | ||
* @return int | ||
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod) | ||
*/ | ||
public function getStoreId() | ||
{ | ||
$storeId = $this->getRequest()->getParam('store'); | ||
return (int) $storeId; | ||
$storeId = (int)$this->getRequest()->getParam('store'); | ||
|
||
return $storeId; | ||
} | ||
|
||
/** | ||
|
@@ -88,6 +101,22 @@ public function getDefaultConfigValue($field) | |
return $this->stockConfiguration->getDefaultConfigValue($field); | ||
} | ||
|
||
/** | ||
* Returns min_sale_qty configuration for the ALL Customer Group | ||
* | ||
* @return int | ||
*/ | ||
public function getDefaultMinSaleQty() | ||
{ | ||
$default = $this->stockConfiguration->getDefaultConfigValue('min_sale_qty'); | ||
if (!is_numeric($default)) { | ||
$default = $this->serializer->unserialize($default); | ||
$default = isset($default[GroupInterface::CUST_GROUP_ALL]) ? $default[GroupInterface::CUST_GROUP_ALL] : 1; | ||
} | ||
|
||
return (int) $default; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @valdislav thanks b3a4058 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @valdislav Please let me know if any additional changes are requested. |
||
} | ||
|
||
/** | ||
* Tab settings | ||
* | ||
|
@@ -99,6 +128,8 @@ public function getTabLabel() | |
} | ||
|
||
/** | ||
* Return Tab title. | ||
* | ||
* @return \Magento\Framework\Phrase | ||
*/ | ||
public function getTabTitle() | ||
|
@@ -107,22 +138,24 @@ public function getTabTitle() | |
} | ||
|
||
/** | ||
* @return bool | ||
* @inheritdoc | ||
*/ | ||
public function canShowTab() | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return bool | ||
* @inheritdoc | ||
*/ | ||
public function isHidden() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* Get availability status. | ||
* | ||
* @param string $fieldName | ||
* @return bool | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,7 +132,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->getDefaultConfigValue('min_sale_qty') * 1 ?>" | ||
value="<?= /* @escapeNotVerified */ $block->getDefaultMinSaleQty() * 1 ?>" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use |
||
disabled="disabled"/> | ||
</div> | ||
<div class="field choice"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get used to
??
;)