How can I add different stock labels
-
07-02-2021 - |
Solución
You 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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange