Version: Magento 2.1
I cannot update or save a product due to this validation message:
Make sure the To Date is later than or the same as the From Date.
I assume it is referring to "Set Product as New From" but it could also be " Schedule Design Update From"
I have tried many combinations of dates including no dates selected but always get the same result. This is not effecting other products.
I've traced the error message to this function in "vendor/magento/module-catalog/Model/Attribute/Backend/Startdate.php".
If I remove the content of the function and just return true the product can be saved but as soon as the function is replaced the error returns blocking any updates again
/**
* Product from date attribute validate function.
* In case invalid data throws exception.
*
* @param \Magento\Framework\DataObject $object
* @throws \Magento\Eav\Model\Entity\Attribute\Exception
* @return bool
*/
public function validate($object)
{
$attr = $this->getAttribute();
$maxDate = $attr->getMaxValue();
$startDate = $this->_getValueForSave($object);
if ($startDate === false) {
return true;
}
if ($maxDate) {
$date = $this->_date;
$value = $date->timestamp($startDate);
$maxValue = $date->timestamp($maxDate);
if ($value > $maxValue) {
$message = __('Make sure the To Date is later than or the same as the From Date.');
$eavExc = new \Magento\Eav\Model\Entity\Attribute\Exception($message);
$eavExc->setAttributeCode($attr->getName());
throw $eavExc;
}
}
return true;
}
I cannot be more specific about how to replicate this issue or why it's happening to this product. The obvious work around is to delete the product and re-enter it but I'd like to see if there's a reason this is happening.