2

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.

  • Hi @Tim, have you found the solution of this issue? I am facing the same. Please let me know if you have found anything about it. – Pribhav Sep 26 at 5:43
1

We were facing the similar issue with multi-store products.

We then tried to save the product at default level without any changes, and no error was observed. We then tried the same at different store levels and everything worked well and we were able to save the changes.

We are yet to find the root cause of this issue, but our assumption is that some data for the product was not saved at default level, due to which the issue was coming at store level.

If you are still facing this issue, you can try these steps.

0

If anyone ever comes across this issue, we found it was due to Configurable products having a "Special Price To Date" set - not sure how it ended up being set at the configurable product level but once we deleted these values from the database we no longer faced the error.

  • I am no longer active on this project so unfortunately I cannot confirm these solutions. Thanks for your input! – Tim Semple Oct 26 at 9:10
0

We found out that this is related with reindexing being stuck, or reindex crons not running for a long time.

0

On the product edit page > advanced price, Me sure that the dates are correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.