How to overwrite /includes/system/segments/sortable_product_columns.php?
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
It isn't a class or template, so it can't be overridden.
Just override the thing that calls it and call something else. Or use the hook to customize the behavior, which could go as far as throwing out the previous result and starting over.
Just override the thing that calls it and call something else. Or use the hook to customize the behavior, which could go as far as throwing out the previous result and starting over.
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
oh i see...
i just wanted to add a "different" sort method:
like this (but different sort order)
'PRODUCT_LIST_ORDERED' => " ORDER BY p.products_ordered%s, pd.products_name",
...what would you suggest ist the best approach? copy the file and link it new from product_listing.php or is there a better way?
i just wanted to add a "different" sort method:
like this (but different sort order)
'PRODUCT_LIST_ORDERED' => " ORDER BY p.products_ordered%s, pd.products_name",
...what would you suggest ist the best approach? copy the file and link it new from product_listing.php or is there a better way?
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
You can just make a hook and add values to the $column_specifications array. Replace the whatevers with stuff that makes sense.
Code: Select all
class hook_shop_filter_whatever {
public function listen_filterStart($parameters) {
$parameters['column_specifications']['PRODUCT_LIST_WHATEVER'] = // whatever
-
loop
- Contributor
- Posts: 253
- Joined: Thu Mar 25, 2021 12:26 pm
- Phoenix Version:
- Has thanked: 7 times
- Been thanked: 3 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
Hi ecartz
that sounds pretty amazing!
Maybe i did something wrong, as it won't eject the hook.
i placed here a file: "includes\hooks\shop\system\sortableProductColumns.php"
can you help me where i missunderstood your solution? Is it not in the "system" hook? (i don't know exactly where's the difference of siteWide and system hooks)
thank you for your help
that sounds pretty amazing!
Maybe i did something wrong, as it won't eject the hook.
i placed here a file: "includes\hooks\shop\system\sortableProductColumns.php"
Code: Select all
class hook_shop_system_sortableProductColumns{
public function listen_filterStart($parameters) {
$parameters['column_specifications']['PRODUCT_LIST_BESTSELLER'] = " ORDER BY test";
}
}thank you for your help
-
Omar_one
- Senior Contributor
- Posts: 677
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
@ecartz
I am trying to do the something
after creating the hook I get error
and I added the new sort method to sortable_product_columns.php , nothing change the error still
I am trying to do the something
after creating the hook I get error
Code: Select all
Warning: Illegal string offset 'sortable' in \templates\override\includes\components\product_listing.php on line 45
Warning: Illegal string offset 'heading' in \templates\override\includes\components\product_listing.php on line 46-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
It has to look like the other entries:loop wrote: ↑Tue Oct 05, 2021 3:35 pmCode: Select all
class hook_shop_system_sortableProductColumns{ public function listen_filterStart($parameters) { $parameters['column_specifications']['PRODUCT_LIST_BESTSELLER'] = " ORDER BY test"; } }
Code: Select all
class hook_shop_filter_sortableProductColumns{
public function listen_filterStart($parameters) {
$parameters['column_specifications']['PRODUCT_LIST_BESTSELLER'] = [
'order_by' => " ORDER BY test",
'heading' => TABLE_HEADING_BESTSELLER,
'sortable' => false,
];
}
}-
Omar_one
- Senior Contributor
- Posts: 677
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
it's working after adding this to sortable_product_columns.php file
I tried to create another hook to customize the behavior but it was not working
Code: Select all
'PRODUCT_LIST_BESTSELLER' => [
'order_by' => " ORDER BY test",
'heading' => TABLE_HEADING_BESTSELLER,
'sortable' => true,
],
I tried to create another hook to customize the behavior but it was not working
Code: Select all
public function listen_injectApplicationTop() {
$column_specifications = array_filter([
'PRODUCT_LIST_BESTSELLER' => [
'order_by' => " ORDER BY test",
'heading' => TABLE_HEADING_BESTSELLER,
'sortable' => true,
],
]);-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
1. You don't want to put it in an injectApplicationTop listener. You want it in filterStart, as that happens after the column specification is created but before it is used.Omar_one wrote: ↑Wed Oct 06, 2021 7:41 pm I tried to create another hook to customize the behavior but it was not workingCode: Select all
public function listen_injectApplicationTop() { $column_specifications = array_filter([ 'PRODUCT_LIST_BESTSELLER' => [ 'order_by' => " ORDER BY test", 'heading' => TABLE_HEADING_BESTSELLER, 'sortable' => true, ], ]);
2. I would make it a filter hook, not system. If not filter, then a specific page.
3. It needs to look like the way that I wrote it previously. The way that you have it written won't do anything, even in the correct place.
-
Omar_one
- Senior Contributor
- Posts: 677
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: How to overwrite /includes/system/segments/sortable_product_columns.php?
Thank you @ecartz I get it
thank you for you help
thank you for you help