Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Sort The Database By Date Rate Topic   - - - - -

 
  • Enew
  • Senior Member
  • Members
  • Join Date: 22-Oct 14
  • 192 posts

Posted 17 April 2015 - 09:53 PM #1

Hello

Does someone can show me how to sort the database by recent date please?

My website is multivendor with 4.2.3

Thank in advance!

Franck

Attached Thumbnails

  • how to sort by date.jpg


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22889 posts

Posted 20 April 2015 - 09:39 AM #2

Please open the app\controllers\backend\database.php file and add this line:

$backup_files = fn_sort_array_by_key($backup_files, 'create');

before this one:

Registry::get('view')->assign('backup_files', $backup_files);

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Enew
  • Senior Member
  • Members
  • Join Date: 22-Oct 14
  • 192 posts

Posted 20 April 2015 - 06:01 PM #3

<p>

Please open the app\controllers\backend\database.php file and add this line:

$backup_files = fn_sort_array_by_key($backup_files, &#39;create&#39;);
before this one:
Registry::get(&#39;view&#39;)->assign(&#39;backup_files&#39;, $backup_files);

Dear, I have change like this: </p>
<div>        }</div>
<div>    }</div>
<div> </div>
<div>$backup_files = fn_sort_array_by_key($backup_files, &#39;create&#39;);</div>
<div>    Registry::get(&#39;view&#39;)->assign(&#39;backup_files&#39;, $backup_files);</div>
<div> </div>
<div>But it s can not sort by recent date, I have clear the cach too,  may be something wrong?</div>
<div> </div>
<div>Thanks</div>


 
  • cscartrocks
  • Member
  • Members
  • Join Date: 24-Jan 11
  • 1850 posts

Posted 21 April 2015 - 06:30 AM #4

You will need to put your code inside code block here so it will not look messy and hard to debug.

One Step Checkout Addon - The ultimate checkout experience
Best CS-Cart SEO addon - CS-Cart SEO Ultimate Addon
PM for 365-day support and custom development service


 
  • CS-Market
  • Senior Member
  • Authorized Reseller
  • Join Date: 06-Mar 13
  • 715 posts

Posted 21 April 2015 - 08:54 AM #5

After this code addition backups will be sorted by date. This code doesn't add sort direction to the backup page similar as to the product page.

Sincerely yours,
CS-Market.

GET A FREE QUOTE  │  CS-Cart add-ons   │   CS-Cart custom development   │  CS-Cart design integration  │  CS-Cart license

Сертифицированный разработчик на CS-Cart Русская Версия. More than 8 years experience in CS-Cart development.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22889 posts

Posted 21 April 2015 - 12:19 PM #6

Please try the following solution:

Replace:

if (is_array($files)) {
    foreach ($files as $file) {
        $backup_files[$file]['size'] = filesize(Registry::get('config.dir.database') . $file);
        $backup_files[$file]['type'] = strpos($file, '.tgz')===false ? 'sql' : 'tgz';
        $backup_files[$file]['create'] = fn_date_format(filemtime(Registry::get('config.dir.database') . $file), $date_format);
    }
}

Registry::get('view')->assign('backup_files', $backup_files);

with

if (is_array($files)) {
    foreach ($files as $file) {
        $backup_files[$file]['size'] = filesize(Registry::get('config.dir.database') . $file);
        $backup_files[$file]['type'] = strpos($file, '.tgz')===false ? 'sql' : 'tgz';
        $backup_files[$file]['create'] = fn_date_format(filemtime(Registry::get('config.dir.database') . $file), $date_format);
        $backup_files[$file]['date'] = filemtime(Registry::get('config.dir.database') . $file);
    }
}

$backup_files = fn_sort_array_by_key($backup_files, 'date');
Registry::get('view')->assign('backup_files', $backup_files);

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Enew
  • Senior Member
  • Members
  • Join Date: 22-Oct 14
  • 192 posts

Posted 21 April 2015 - 05:49 PM #7

Please try the following solution:

Replace:

if (is_array($files)) {
	foreach ($files as $file) {
		$backup_files[$file]['size'] = filesize(Registry::get('config.dir.database') . $file);
		$backup_files[$file]['type'] = strpos($file, '.tgz')===false ? 'sql' : 'tgz';
		$backup_files[$file]['create'] = fn_date_format(filemtime(Registry::get('config.dir.database') . $file), $date_format);
	}
}

Registry::get('view')->assign('backup_files', $backup_files);

with

if (is_array($files)) {
	foreach ($files as $file) {
		$backup_files[$file]['size'] = filesize(Registry::get('config.dir.database') . $file);
		$backup_files[$file]['type'] = strpos($file, '.tgz')===false ? 'sql' : 'tgz';
		$backup_files[$file]['create'] = fn_date_format(filemtime(Registry::get('config.dir.database') . $file), $date_format);
		$backup_files[$file]['date'] = filemtime(Registry::get('config.dir.database') . $file);
	}
}

$backup_files = fn_sort_array_by_key($backup_files, 'date');
Registry::get('view')->assign('backup_files', $backup_files);

Dear Ecomlabs

It's work for old > recent, can you show me how to make recent date > old date please?

Thank very much

Franck

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22889 posts

Posted 22 April 2015 - 08:52 AM #8

It's work for old > recent, can you show me how to make recent date > old date please?


Please try:

$backup_files = fn_sort_array_by_key($backup_files, 'date', SORT_DESC);

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • Enew
  • Senior Member
  • Members
  • Join Date: 22-Oct 14
  • 192 posts

Posted 22 April 2015 - 05:31 PM #9

Please try:

$backup_files = fn_sort_array_by_key($backup_files, 'date', SORT_DESC);

thank very much, it's work now.

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22889 posts

Posted 23 April 2015 - 09:06 AM #10

You are welcome!

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)