Hook is not callable

My store owner wanted his products sorted by price in each category, but he wanted them sorted descending. I found the line in the core/fn.catalog.php file where the 'products_sorting':


fn_set_hook('products_sorting', $sorting);




I tried to override this with the my_changes addon, but I'm getting an error:

[quote]Hook fn_my_changes_products_sorting is not callable[/quote]



/addons/my_changes/init.php:

```php

fn_register_hooks('products_sorting');
```

[b]/addons/my_changes/controllers/customer/init.post.php:[/b]
```php
function fn_my_changes_products_sorting(&$sorting)
{
$sorting['price']['default_order'] = 'desc';
}
?>

```



Any ideas why this isn't working? I guess I could change the /core.fn.catalog array to sort desc for price, but I'd rather not modify core files.

Put your hook in func.php versus the controller and it will work fine.

[quote name='tbirnseth' timestamp='1336502378' post='136082'] Put your hook in func.php versus the controller and it will work fine. [/quote]



Worked perfectly. Thank you sir!

hi,



I took this error,I faced white page.



[color=#000000]Hook fn_******_get_orders is not callable[/color]



how to get rid of this situation?



NOTE: I am using v401



regards,

may

Why are you deleting part of the error? That info would tell us what to tell you to change.

Whatever addon you are using “******” is using a fn_register_hooks() call for 'get_orders' and it cannot find the corresponding function.

Hi @grayloon,

The trick will work until you will have a catalog promotion ;), because the price will be recalculated after this particular hook



Please check controllers/customer/categories.php ```php


list($products, $search) = fn_get_products($params, Registry::get(‘settings.Appearance.products_per_page’));

fn_gather_additional_products_data($products, array(‘get_icon’ => true, ‘get_detailed’ => true, ‘get_options’ => true, ‘get_discounts’ => true, ‘get_features’ => false));

<br />
I consider you are using v2.2.3<br />
<br />
---<br />
Valentin<br />
[color=#808080][size=2]part of hungryweb.net[/size][/color]

Getting similar error after enabling reward points addon. Appreciate a fix. thanks.

Tygh\Exceptions\AException

Message

Hook fn_reward_points_load_products_extra_data is not callable

Error at

app/Tygh/Exceptions/DeveloperException.php, line: 41

The function should exist in the following file

app/addons/reward_points/func.php

Pelase check

Also ensure you clear your cache since hooks are cached.