Hi @ameephillips,
The plugin currently orders by product title and we’re not planning on adding an “order by” option, as you can easily do so afterward with Excel, Numbers, Google Sheets, or any other spreadsheet tool.
Thread Starter
amee
(@ameephillips)
Thanks for the quick reply. Whilst that is of course true, I find the HTML export to be the best feature of this plugin as it displays the images, rather than a link. This makes it excellent for quickly producing a pdf listing of products that can be referred to offline. That is the use case that leads me to want to sort by SKU when exporting to HTML – sorting by any other attribute doesn’t help me as we have sorted our products by SKU reference. As I mentioned I tried editing the plugin to do it but my skills weren’t up to the task. It would be a great enhancement to the tool but if it isn’t possible to edit the plugin to do so then I will have to accept that.
-
This reply was modified 5 years, 11 months ago by
amee.
Thread Starter
amee
(@ameephillips)
So I did manage to get it working as I described.
from:
//Order the products
public function order_products( $output_array, $title_index ) {
$product = array();
foreach ( $output_array as $key => $row ) {
$product[$key] = $row[$title_index];
}
array_multisort( $product, SORT_ASC, $output_array );
return $output_array;
}
to:
//Order the products
public function order_products( $output_array, $sku ) {
$sku = array();
foreach ( $output_array as $key => $row ) {
$sku[$key] = $row[$sku];
}
array_multisort( $sku, SORT_ASC, $output_array );
return $output_array;
}
It looks correct to me, but if you can see any issue with it please let me know.
Hi there @ameephillips,
The only problem I see in your code is that you’ll lose it on a next update.
Please update to 0.8.0, and add this to your child-theme functions.php file:
add_filter( 'wse_sort_field', function( $sort_field ) {
return 'sku';
} );