Post by CedSha » Fri Aug 29, 2025 4:02 pm

Hi All,
I am reporting for OC V4.1.0.3.
When activating product discount the UI will accept no values to be filled in the date field.
strangely the record will be saved with a 0000-00-00 value, instead of null, which is not a valid one.
Therefore during a db restore an error will be thrown and the restore will be stopped as the
value of 0000-00-00 will be refused as a valid data of one of these two tables :
  • oc_product_discount
  • oc_product_special
If one have this issue restoring his database he can replace in the sql backup file all occurrences
of 0000-00-00 by null or any valid date.
As usual as a basic safety do not work with your original backup !

Code: Select all

# sample code to replace 0 based date
sed -i "s/'0000-00-00' /NULL /g" copy_of_backup.sql
hth

Image


User avatar
New member

Posts

Joined
Mon Sep 18, 2023 1:01 am


Post by ADD Creative » Fri Aug 29, 2025 5:23 pm

You can also just remove NO_ZERO_DATE from sql_mode. OpenCart 4 already does this.
https://github.com/opencart/opencart/co ... 11c5e3084f

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by CedSha » Fri Aug 29, 2025 10:31 pm

Thanks for pointing this out.
Due to an unidentified stop while restoring the base I was using CLI restore, this is why this problem occur.
If you only have Opencart on your system you could also globally accept 0000-00-00 type date in the configuration file :

Code: Select all

[mysqld]
sql_mode=NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION

Image


User avatar
New member

Posts

Joined
Mon Sep 18, 2023 1:01 am

Who is online

Users browsing this forum: No registered users and 13 guests