Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Easy Populate date fix


Jack_mcs

Recommended Posts

Easy Populate requires the date to be in the yyyy-mm-dd format. Excel won't let you save that as the default format without changing the systems format. This means the date columns had to be re-formatted every time the page was loaded into Excel.

 

The following code fixes that problem. I didn't post it as an update to the contribution yet since I wasn't sure if there were any other default formats (due to country standards). So if anyone that needs this fix will try it and let me know if it doesn't work, I would appreciate it. It does work if the default format in Excel is mm/dd/yyyy.

 

In admin/easypopulate.php, find this line around 1215:

function walk( $item1 ) {

and place the following before it

function ConvertDate($v_date_orig) {	
   if (strpos($v_date_orig, '/'))
   { 
      $dateNew = explode('/', $v_date_orig);
      $yr = explode(' ', $dateNew[2]);
      $dateNew = sprintf("%s-%s-%s", $yr[0],$dateNew[0],$dateNew[1]);
      if (! empty($yr[1]))
        $dateNew .= ' ' . $yr[1];
      $v_date_orig = '"' . $dateNew . '"';
   }
   else
   {
    $v_date_orig = '"' . $v_date_orig . '"'; // we put the quotes around it here because we can't put them into the query, because sometimes
                                               // we will use the "current_timestamp", which can't have quotes around it.
   }
   return $v_date_orig;
}

Then, find this section of code arount 1478

	if ($v_date_avail == '') {
//  $v_date_avail = "CURRENT_TIMESTAMP";
 $v_date_avail = "NULL";
} else {
 // we put the quotes around it here because we can't put them into the query, because sometimes
 //   we will use the "current_timestamp", which can't have quotes around it.
 $v_date_avail = '"' . $v_date_avail . '"';
}

if ($v_date_added == '') {
 $v_date_added = "CURRENT_TIMESTAMP";
} else {
 // we put the quotes around it here because we can't put them into the query, because sometimes
 //   we will use the "current_timestamp", which can't have quotes around it.
 $v_date_added = '"' . $v_date_added . '"';
}

and replace it with

	if ($v_date_avail == '') {
//  $v_date_avail = "CURRENT_TIMESTAMP";
 $v_date_avail = "NULL";
} else {
   $v_date_avail = ConvertDate($v_date_avail);
}

if ($v_date_added == '') {
 $v_date_added = "CURRENT_TIMESTAMP";
} else {
   $v_date_added = ConvertDate($v_date_added);   
}

 

That should do it. When you copy and paste, watch the long comments extending into a new line. They should be on one line.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Not on mine. All my EP files are .txt but if I don't change the format of the date, it doesn't get updated. My default date is mm/dd/yyyy which EP does not accept. Maybe yours is set differently.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 4 weeks later...
This fix works really great.  I was having lots of headaches with the dates, but not anymore!  :thumbsup:

 

Not working for me.

 

Why these two fields v_date_avail and v_date_added keep replacing my date, for example 8/3/2005 11:44:53 PM into a format and values of 0000-00-00 00:00:00? I am using Easy Populate Basic 2.75, Create Export Field Complete Download then do my updates using Excel then use Upload EP File for Import.

Link to comment
Share on other sites

Did you check first that you needed to make this change. Not everyone does for some reason. As for the date, it is changing it because that the is the format EP expects. Try removing the changes and uploading a file. Then view one of the products you just uploaded on your site. If the date added is correct, then you don't need the change.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 7 months later...
  • 11 months later...

Thanks for the fix but It did not work for me too.. I should mention here that my EP worked perfectly before, but recently i deleted one categorie and added another categories with the same name but different products.. but when I checked my website I can only see names of the products and their descriptions and prices.. but no pictures neither their places.. looking around i noticed that some of these hidden pictures are considered as UpComing products with a date expected (a past date)... I made the modification mentioned by Jack but there is still no pictures even if the Upcoming products message has disappeared..

 

Should I delete these products and upload them again?

 

Or is there something wrong?

Link to comment
Share on other sites

You don't need this change if Easy Populate was working OK. But if it never worked and the problem was to do with the dates as you describe, then you need it. Be sure that the dates in the Easy Populate file are set correctly. If you put an old date in there, then that is what will be used.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...