While creating products we have customizable options. After adding the option, in the add value field if I give 0(zero) its not taking.Giving Invalid option value error message.But its taking 00.How to solve this Magento bug.
1 Answer
In customizable options not taking '0'(Zero) as a value, for that you have to put one single space before '0'(Zero),because we have use '0'(Zero) as a option's title or sub option's title so we have just displaying '0'(Zero) as a title on front side, so you can put one single space before '0'(Zero).
If you have not put manually one space before '0'(Zero),then you have to done using programmatically.
1) In DefaultValidator.php you have to just put one condition.
Magento/vendor/magento/module-catalog/Model/Product/Option/Validator/DefaultValidator.php
if ($title == '0') {
return true;
}
protected function isValidOptionTitle($title, $storeId)
{
if ($title == '0') {
return true;
}
}
2) You will also changes in Value.php for save sub option's title.
Magento/vendor/magento/module-catalog/Model/ResourceModel/Product/Option/Value.php
protected function _saveValueTitles(AbstractModel $object)
{
$title = $object->getTitle();
if ($title == '0') {
$title = ' 0';
}
}
Replace $object->getTitle() To $title.
3) You will also changes in Option.php for save main option's title.
Magento/vendor/magento/module-catalog/Model/ResourceModel/Product/Option.php
protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object)
{
$title = $object->getTitle();
if ($title == '0') {
$title = ' 0';
}
}
Replace $object->getTitle() To $title.
I hope this will useful for you.:)
-
i have given space after '0'.its worked fine.Thank you. Commented May 22, 2018 at 9:31
-
Always welcome :).– user67659Commented May 22, 2018 at 10:08