Diferrent Sort Order For A Specific Category_Id

init.php


<br />
<?<br />
if (!defined('BOOTSTRAP')) { die('Access denied'); }<br />
<br />
fn_register_hooks('products_sorting');<br />
?><br />

```<br />
<br />
<br />
func.php<br />
<br />
<br />
```php
<br />
<?php<br />
function fn_my_changes_products_sorting(&$sorting)<br />
{<br />
<br />
if (AREA == 'C') {<br />
<br />
        if($category_data['category_id'] == "510") {<br />
        //print "<pre>";print_r($sorting);exit;<br />
<br />
          $sorting['timestamp']['default_order'] = 'desc';<br />
<br />
        }<br />
<br />
<br />
}<br />
<br />
<br />
return $sorting;<br />
}<br />

```<br />
<br />
<br />
doesnt work for me, any thing im missing ? seems category_data is empty how can i get this in latest cs-cart ? 4.X

anyone ?

Our Default Category Sorting addon here Addon: Default Category Sorting - Third-Party Add-ons - CS-Cart Community Forums might help.

thanks but this should be a 5 line code maximum i dont think its worth 69$, maybe 15$,





almost got it, just need the correct hook to add sorting… getting cat works



init.php


if (!defined('BOOTSTRAP')) { die('Access denied'); }

fn_register_hooks('get_category_data_post');
?>




func.php



function fn_my_changes_get_category_data_post(&$category_id, &$field_list, &$get_main_pair, &$skip_company_condition, &$lang_code, $

if (AREA == 'C' && !empty($category_data)) {

}

if ( !empty($category_data['category_id'])) {

if($category_data['category_id'] == "510") {

// $sorting = db_sort($params, $sortings, 'timestamp', 'desc');

// $default_sorting = fn_get_default_products_sorting();
$default_sorting=array('sort_by' => 'timestamp','sort_order' => 'desc');
$sorting=array('sort_by' => 'timestamp','sort_order' => 'desc');
// $params=array('sort_by' => 'timestamp','sort_order' => 'desc');
//print "

";print_r($default_sorting);exit;
$params['sort_order'] = 'desc';
$params['sort_by'] = 'timestamp';
$search['sort_by'] = 'timestamp';
$search['sort_order'] = 'desc';
$settings['default_products_sorting']= "timestamp-desc";
}


}


return true;
}

For your code maybe it worths 15 USD but not for an addon with easy admin setup. Also the addon is 49 USD instead of 69 USD. The original development cost for our client was more than 69 USD actually.

hmm my code ?



here it is… for 1$ ;)



init.php


fn_register_hooks(   'get_products');
```<br />
<br />
<br />
func.php<br />
<br />
<br />
<br />
```php
<br />
<br />
function fn_my_changes_get_products(&$params, &$items_per_page, &$lang_code) {<br />
<br />
if ($params['category_id']=='510' ) {<br />
<br />
if (empty($params['sort_by'])) {<br />
<br />
		$params['sort_by'] = 'timestamp';<br />
		$params['sort_order'] = 'desc';<br />
}<br />
<br />
}<br />
<br />
}
```<br />
<br />
im sure some would pay 68$ more to be able to choose in admin, altough it's not something you change often.... a simple mod to this can make any category sorted as you wish...<br />
<br />
btw: t[color=#282828][font=arial, verdana, tahoma, sans-serif]he original development cost for our client was more than 69 USD actually[/font][/color]<br />
<br />
i guess alot of the programming goes into the packaging and not the package.

You can charge whatever you want even 1$ if you like. The hard-coding category id already shows something. :)