How can I add new stock labels to magento 2 so they appear in the product stock status select box ?
Thanks.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityYou should create a custom module to solve your problem. And then you can create a plugin to add more stock option by do following steps:
- app/code/YourVendor/YourModule/etc/di.xml
<type name="Magento\CatalogInventory\Model\Source\Stock">
<plugin name="training_source_stock" type="YourVendor\YourModule\Plugin\CatalogInventory\Model\Source\Stock"/>
</type>
- app/code/YourVendor/YourModule/Plugin/CatalogInventory/Model/Source/Stock.php
class Stock
{
const NEW_STOCK = 2;
public function afterGetAllOptions(\Magento\CatalogInventory\Model\Source\Stock $subject, $result)
{
$newStock = [
[
'value' => self::NEW_STOCK,
'label' => __('New Stock')
]
];
return array_merge($result, $newStock);
}
}
- Stock status will be show like this:
If this solves your issue, please give me a vote
Thanks