Pagination not working in Admin Products list

This topic is: not resolved

This topic contains 3 replies, has 4 voices, and was last updated by  karencheah 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
Author Posts
Author Posts
November 2, 2012 at 1:22 pm #292045

BigYin

Products list – wp-admin/edit.php?post_type=wpsc-product
loses pagination if trying to go to second page – the link is wp-admin/edit.php?post_type=wpsc-product&paged=2 (or for last page paged=10) but when it next displays the URL has reset to wp-admin/edit.php?post_type=wpsc-product&paged=1 and all the page navigation has disappeared. This makes it impossible to edits products beyond the first page. Same problem occurs if filtering by Product Category. New install of WP e-Commerce version 3.8.9 (free version), no other plugins active and WP version 3.4.2

November 6, 2012 at 5:42 pm #292469

niall.campbell
New Member

Have the same problem here. Disabling pagination in wp e-commerce presentation settings fixes the issue (but of course this disables pagination for your products).

So the problem…

It is caused by the function _wpsc_pre_get_posts_reset_taxonomy_globals() located in wpsc-functions.php (line 655). This function was added in version 3.8.9 and I’m not sure of its intent yet.

I’ve written the following code and put it in my theme’s functions.php file to get around the issue. It will only override the code if its version 3.8.9 (I’m assuming that there’ll be a fix for this in 3.8.10). It also checks if its called from the dashboard and disables the code causing the pagination issues.


/**
* WPEC Admin pagination fix
* Fixes pagination issue in admin (Issue Description: http://getshopped.org/forums/topic/pagination-not-working-in-admin-products-list/)
*
* @original _wpsc_pre_get_posts_reset_taxonomy_globals() in wpsc-functions.php
*/
function override_wpsc_pre_get_posts_reset_taxonomy_globals( $query ) {
global $wp_the_query;

if ( $query !== $wp_the_query )
return;

if ( ! $query->get( 'page' ) && ! $query->get( 'paged' ) )
return;
if ( is_admin() )
return;
else
if (! get_option( 'use_pagination' ) )
return;

$query->set( 'posts_per_page', get_option( 'wpsc_products_per_page' ) );

$post_type_object = get_post_type_object( 'wpsc-product' );

if ( current_user_can( $post_type_object->cap->edit_posts ) )
$query->set( 'post_status', 'private,draft,pending,publish' );
else
$query->set( 'post_status', 'publish' );
}
//code only present from 3.8.9 (current version at time of writing) so
//only override it if the version is 3.8.9
if ( version_compare( WPSC_VERSION, '3.8.9', '=' ) ) {
remove_action( 'pre_get_posts', '_wpsc_pre_get_posts_reset_taxonomy_globals', 1);
add_action( 'pre_get_posts', 'override_wpsc_pre_get_posts_reset_taxonomy_globals', 1 );
}

November 20, 2012 at 9:08 pm #294301

cartkn
New Member

very nice niall.campbell its working :) thank u

November 23, 2012 at 12:23 am #294637

karencheah
New Member

I’m using version 3.8.8.5 with WP 3.4.2. I’m also having a pagination issue for the products in categories, the last page will not show in IE9 only!

Anyone have any ideas where I can start to look PLEASE???

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.