4

I have been breaking my head on how to do a dynamic sort option, which will show/hide the sort option, depending on whether the category has the "Manufacturer" that the sorter is looking for...

private static $sort_options = array(
    'Alphabetical' => 'URLSegment',
    'Lowest Price' => 'BasePrice'
);

Normally the sorter gets its options like this, but this will not seem to cut it for the task at hand.

If anyone can give some tips or ideas of what I can try, that would be really helpful. What am I missing?

wmk
  • 4,598
  • 1
  • 20
  • 37
Skullies
  • 41
  • 2
  • Just to be clear about my problem Product Category has Many Products Products has Many Categories Product has one Manufacturer Manufacturer has many Products What I need to do is have a sorter that shows the Manufacturers that the products in that Category has and hide the Manufacturers that do not have Products in the Category – Skullies Nov 23 '16 at 08:07
  • Commenting on the obvious atleast: it should be private static $sort_options not public. Imho you should be getting a warning or an exception relating that. – Olli Tyynelä Nov 23 '16 at 08:36

1 Answers1

1

Your best bet is to override the getSorter method in ProductCategory_Controller and add any additional logic there:

https://github.com/silvershop/silvershop-core/blob/master/code/product/ProductCategory.php#L202

Mark Guinn
  • 619
  • 3
  • 8