How to overwrite /includes/system/segments/sortable_product_columns.php?

Open to all! Ask other shopowners for help.
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?

Post by loop »

Hi ecartz

i Tried now what you suggested, but i had to change the code to that, that the $parameter are as the other column_list. do not know why..?

Code: Select all

class hook_shop_filter_sortableProductColumns{

    public function listen_filterStart($parameters) {
      $parameters['column_list'][] = "PRODUCT_LIST_BESTSELLER";
      $parameters['column_orderings']['PRODUCT_LIST_BESTSELLER'] = "ORDER BY test";
    }

  }
but my main problem is now, that the "PRODUCT_LIST_BESTSELLER" is now on array position 4 and the sortorder for the default order is already done before i inserted the hook (so also if i say in my cm_in_product_listing.php

Code: Select all

$default_column = 'PRODUCT_LIST_BESTSELLER';             
    require 'includes/system/segments/sortable_product_columns.php';
it does not change, as the sortorder is created before the hook insert.

do you have a idea how to fix that, without hardcoding?

thank you!


Join The Code Co-op to get access to your library in the Code Co-op Forum
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?

Post by ecartz »

loop wrote: Mon Oct 25, 2021 9:26 am but my main problem is now, that the "PRODUCT_LIST_BESTSELLER" is now on array position 4 and the sort order for the default order is already done before I inserted the hook (so also if I say in my cm_in_product_listing.php

Code: Select all

$default_column = 'PRODUCT_LIST_BESTSELLER';             
    require 'includes/system/segments/sortable_product_columns.php';
it does not change, as the sort order is created before the hook insert.

do you have a idea how to fix that, without hardcoding?
In the hook listener, after adding the new sort:

Code: Select all

   uksort($parameters['column_specifications'], function ($a, $b) {
    return (constant($a) <=> constant($b));
  }); 
Note that this may only work in the current form of the file, since 1.0.8.5, when the hook moved.
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?

Post by loop »

Hi Ecartz

I have now updatet to the newest phoenixcart. And made the Hookfillter like this:

Code: Select all

class hook_shop_filter_sortableProductColumns{

  public function listen_filterStart($parameters) {
    $parameters['column_specifications']['PRODUCT_LIST_BESTSELLER'] = [
      'order_by' => " ORDER BY products_bestseller DESC",
      'heading' => 'Bestseller',
      'sortable' => true,
    ];

    uksort($parameters['column_specifications'], function ($a, $b) {
      return (constant($a) <=> constant($b));
    }); 

  }

}
it seems that it now filters correct to the "bestseller" but i get a error in the top because of the sort
Warning
: constant(): Couldn't find constant PRODUCT_LIST_BESTSELLER in
/mnt/lamp-www-data/beta_shop/includes/hooks/shop/filter/sortableProductColumns.php
on line
23


Warning
: constant(): Couldn't find constant PRODUCT_LIST_BESTSELLER in
/mnt/lamp-www-data/beta_shop/includes/hooks/shop/filter/sortableProductColumns.php
on line
23


Warning
: constant(): Couldn't find constant PRODUCT_LIST_BESTSELLER in
/mnt/lamp-www-data/beta_shop/includes/hooks/shop/filter/sortableProductColumns.php
on line
23


Warning
: constant(): Couldn't find constant PRODUCT_LIST_BESTSELLER in
/mnt/lamp-www-data/beta_shop/includes/hooks/shop/filter/sortableProductColumns.php
on line
23
do you have a idea why the "constant()" error is there?
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?

Post by ecartz »

Have you created an entry in the configuration table for PRODUCT_LIST_BESTSELLER?
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?

Post by loop »

OMG, didn't know / thought of that, thank you! i added it and everything is fine now, thank you
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?

Post by loop »

one thing is still strange, since i updatet to 1.0.8.7

i have in the sort dropdown only the arrows, no text. i looked into it and in the default/includes/component/product_listing.php there is on line 46:
echo splitPageResults::create_sort_heading($_GET['sort'], $i+1, $column_specifications[$column]['heading']);

the $column_specifications[$column]['heading'] has the text in it so probably it has to be something in the function splitPageResults::create_sort_heading( ?
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?

Post by ecartz »

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?

Post by loop »

Thank you! foundout, that german didn't had that (but had parts of it in german.php) Maybe it's best to start from scratch with the languages if everything work in english....


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply